+
    LV-jPj  ã                   ó¾   € R t ^ RIHt ^RIHt ^ RIt. ROt ! R R]4      t	R t
RR ltRR lt]tRR	 ltRR
 ltR tR tR tRR ltRR ltRR ltRR ltRR ltR# )z·
Functions
---------
.. autosummary::
   :toctree: generated/

    line_search_armijo
    line_search_wolfe1
    line_search_wolfe2
    scalar_search_wolfe1
    scalar_search_wolfe2

)Úwarn)ÚDCSRCHNÚLineSearchWarningc                   ó   € ] tR t^tRtR# )r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Úk/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_linesearch.pyr   r      s   † Ûr   c                 óN   € ^ T u;8  d   Tu;8  d   ^8  g   M \        R4      hR# )é    z.'c1' and 'c2' do not satisfy'0 < c1 < c2 < 1'.N)Ú
ValueError)Úc1Úc2s   &&r   Ú_check_c1_c2r      s(   € Ø�ŽO�RŽO˜!ŽOÜð .ó /ð 	/ñ r   c                óü   a aaaaaaa€ Vf   S! S.SO5!  pV.o^ .o^ .oVV VVV3R lpVVVVVV3R lp\         P                  ! VS4      p\        WÞWVVW‰W«VR7
      w  pppVS^ ,          S^ ,          VVS^ ,          3# )aÁ  
As `scalar_search_wolfe1` but do a line search to direction `pk`

Parameters
----------
f : callable
    Function `f(x)`
fprime : callable
    Gradient of `f`
xk : array_like
    Current point
pk : array_like
    Search direction
gfk : array_like, optional
    Gradient of `f` at point `xk`
old_fval : float, optional
    Value of `f` at point `xk`
old_old_fval : float, optional
    Value of `f` at point preceding `xk`

The rest of the parameters are the same as for `scalar_search_wolfe1`.

Returns
-------
stp, f_count, g_count, fval, old_fval
    As in `line_search_wolfe1`
gval : array
    Gradient of `f` at the final point

Notes
-----
Parameters `c1` and `c2` must satisfy ``0 < c1 < c2 < 1``.

c                 ó^   <€ S^ ;;,          ^,          uu&   S! SV S,          ,           .SO5!  # ©r   r   )ÚsÚargsÚfÚfcÚpkÚxks   &€€€€€r   ÚphiÚline_search_wolfe1.<locals>.phiR   s(   ø€ Ø
ˆ1���
‹Ù��a˜•d•Ð"˜TÓ"Ð"r   c                 ó    <€ S! SV S,          ,           .SO5!  S^ &   S^ ;;,          ^,          uu&   \         P                  ! S^ ,          S4      # r   ©ÚnpÚdot)r   r   ÚfprimeÚgcÚgvalr   r   s   &€€€€€€r   ÚderphiÚ"line_search_wolfe1.<locals>.derphiV   s@   ø€ Ù˜˜a �d�Ð* TÓ*ˆˆQ‰Ø
ˆ1���
‹Ü�vŠv�d˜1•g˜rÓ"Ð"r   )r   r   ÚamaxÚaminÚxtol)r!   r"   Úscalar_search_wolfe1)r   r#   r   r   ÚgfkÚold_fvalÚold_old_fvalr   r   r   r(   r)   r*   r   r&   Úderphi0ÚstpÚfvalr   r$   r%   s   ffff&&&f&&&&&     @@@r   Úline_search_wolfe1r2   %   s”   ÿ€ ðL ‚{Ù�RÐ˜$Óˆàˆ5€DØ
ˆ€BØ
ˆ€B÷#ñ #÷#ò #ô
 �fŠf�S˜"‹o€Gä.Ø˜°Ø˜t°Tô;Ñ€Cˆˆxð ��1•�r˜!•u˜d H¨d°1­gÐ5Ð5r   c
           	     óø   € \        WV4       Vf	   V ! R4      pVf	   V! R4      pVe2   V^ 8w  d+   \        RRW#,
          ,          V,          4      p
V
^ 8  d   Rp
MRp
^dp\        WWVW˜V4      pV! W¢WKR7      w  rÞr/WÞV3# )aô  
Scalar function search for alpha that satisfies strong Wolfe conditions

alpha > 0 is assumed to be a descent direction.

Parameters
----------
phi : callable phi(alpha)
    Function at point `alpha`
derphi : callable phi'(alpha)
    Objective function derivative. Returns a scalar.
phi0 : float, optional
    Value of phi at 0
old_phi0 : float, optional
    Value of phi at previous point
derphi0 : float, optional
    Value derphi at 0
c1 : float, optional
    Parameter for Armijo condition rule.
c2 : float, optional
    Parameter for curvature condition rule.
amax, amin : float, optional
    Maximum and minimum step size
xtol : float, optional
    Relative tolerance for an acceptable step.

Returns
-------
alpha : float
    Step size, or None if no suitable step was found
phi : float
    Value of `phi` at the new point `alpha`
phi0 : float
    Value of `phi` at `alpha=0`

Notes
-----
Uses routine DCSRCH from MINPACK.

Parameters `c1` and `c2` must satisfy ``0 < c1 < c2 < 1`` as described in [1]_.

References
----------

.. [1] Nocedal, J., & Wright, S. J. (2006). Numerical optimization.
   In Springer Series in Operations Research and Financial Engineering.
   (Springer Series in Operations Research and Financial Engineering).
   Springer Nature.

ç        ç      ð?)Úphi0r/   Úmaxiterç)\�Âõ( @)r   Úminr   )r   r&   r6   Úold_phi0r/   r   r   r(   r)   r*   Úalpha1r7   Údcsrchr0   Úphi1Útasks   &&&&&&&&&&      r   r+   r+   d   s”   € ôj �Ôà‚|Ù�2‹wˆØ‚Ù˜“*ˆàÒ ¨1¤Ü�S˜& $¥/Õ2°7Õ:Ó;ˆØ�AŒ:ØˆFøàˆà€Gä�C ¨°TÓ:€FÙ"Ø 7ôÑ€Cˆtð �dˆ?Ðr   c                óf  a aaaaaaaaaa€ ^ .o^ .oR.oR.oVV VVV3R lpVoVVVVVVV3R loVf   S! S.SO5!  p\         P                  ! VS4      pSe   VVVVVV3R lpMRp\        VSWVWèWšWüR7
      w  ppppVf   \        R\        ^R7       M	S^ ,          pVS^ ,          S^ ,          VVV3# )aÊ  Find alpha that satisfies strong Wolfe conditions.

Parameters
----------
f : callable f(x,*args)
    Objective function.
myfprime : callable f'(x,*args)
    Objective function gradient.
xk : ndarray
    Starting point.
pk : ndarray
    Search direction. The search direction must be a descent direction
    for the algorithm to converge.
gfk : ndarray, optional
    Gradient value for x=xk (xk being the current parameter
    estimate). Will be recomputed if omitted.
old_fval : float, optional
    Function value for x=xk. Will be recomputed if omitted.
old_old_fval : float, optional
    Function value for the point preceding x=xk.
args : tuple, optional
    Additional arguments passed to objective function.
c1 : float, optional
    Parameter for Armijo condition rule.
c2 : float, optional
    Parameter for curvature condition rule.
amax : float, optional
    Maximum step size
extra_condition : callable, optional
    A callable of the form ``extra_condition(alpha, x, f, g)``
    returning a boolean. Arguments are the proposed step ``alpha``
    and the corresponding ``x``, ``f`` and ``g`` values. The line search
    accepts the value of ``alpha`` only if this
    callable returns ``True``. If the callable returns ``False``
    for the step length, the algorithm will continue with
    new iterates. The callable is only called for iterates
    satisfying the strong Wolfe conditions.
maxiter : int, optional
    Maximum number of iterations to perform.

Returns
-------
alpha : float or None
    Alpha for which ``x_new = x0 + alpha * pk``,
    or None if the line search algorithm did not converge.
fc : int
    Number of function evaluations made.
gc : int
    Number of gradient evaluations made.
new_fval : float or None
    New function value ``f(x_new)=f(x0+alpha*pk)``,
    or None if the line search algorithm did not converge.
old_fval : float
    Old function value ``f(x0)``.
new_slope : float or None
    The local slope along the search direction at the
    new value ``<myfprime(x_new), pk>``,
    or None if the line search algorithm did not converge.


Notes
-----
Uses the line search algorithm to enforce strong Wolfe
conditions. See Wright and Nocedal, 'Numerical Optimization',
1999, pp. 59-61.

The search direction `pk` must be a descent direction (e.g.
``-myfprime(xk)``) to find a step length that satisfies the strong Wolfe
conditions. If the search direction is not a descent direction (e.g.
``myfprime(xk)``), then `alpha`, `new_fval`, and `new_slope` will be None.

Examples
--------
>>> import numpy as np
>>> from scipy.optimize import line_search

An objective function and its gradient are defined.

>>> def obj_func(x):
...     return (x[0])**2+(x[1])**2
>>> def obj_grad(x):
...     return [2*x[0], 2*x[1]]

We can find alpha that satisfies strong Wolfe conditions.

>>> start_point = np.array([1.8, 1.7])
>>> search_gradient = np.array([-1.0, -1.0])
>>> line_search(obj_func, obj_grad, start_point, search_gradient)
(1.0, 2, 1, 1.1300000000000001, 6.13, [1.6, 1.4])

Nc                 ó^   <€ S^ ;;,          ^,          uu&   S! SV S,          ,           .SO5!  # r   r   )Úalphar   r   r   r   r   s   &€€€€€r   r   Úline_search_wolfe2.<locals>.phi  s(   ø€ Ø
ˆ1���
‹Ù��e˜b•j•Ð( 4Ó(Ð(r   c                 óª   <€ S^ ;;,          ^,          uu&   S! SV S,          ,           .SO5!  S^ &   V S^ &   \         P                  ! S^ ,          S4      # r   r    )rA   r   r#   r$   r%   Ú
gval_alphar   r   s   &€€€€€€€r   r&   Ú"line_search_wolfe2.<locals>.derphi#  sI   ø€ Ø
ˆ1���
‹Ù˜˜e b�j�Ð0¨4Ó0ˆˆQ‰Øˆ
�1‰Ü�vŠv�d˜1•g˜rÓ"Ð"r   c                 ór   <€ S^ ,          V 8w  d	   S! V 4       SV S,          ,           pS! WVS^ ,          4      # r   r   )	rA   r   Úxr&   Úextra_conditionr%   rD   r   r   s	   && €€€€€€r   Úextra_condition2Ú,line_search_wolfe2.<locals>.extra_condition20  s6   ø€ Ø˜!�} Ô%Ù�u”Ø�U˜R•Z•ˆAÙ" 5¨S°$°qµ'Ó:Ð:r   )r7   ú*The line search algorithm did not converge©Ú
stacklevel)r!   r"   Úscalar_search_wolfe2r   r   )r   Úmyfprimer   r   r,   r-   r.   r   r   r   r(   rH   r7   r   r/   rI   Ú
alpha_starÚphi_starÚderphi_starr&   r   r#   r$   r%   rD   s   f&ff&&&f&&&f&      @@@@@@r   Úline_search_wolfe2rS   º   sÚ   ÿú€ ð| ˆ€BØ
ˆ€BØˆ6€DØ�€J÷)ñ )ð €F÷#ó #ð ‚{Ù�RÐ˜$ÓˆÜ�fŠf�S˜"‹o€GàÒ"÷	;ó 	;ð  Ðä2FØ�˜°¸bØô3/Ñ/€J�˜( Kð ÒÜÐ9Ü¨1ö	.ð ˜1•gˆà�r˜!•u˜b �e X¨x¸ÐDÐDr   c
                ól  € \        WV4       Vf	   V ! R4      pVf	   V! R4      p^ p
Ve)   V^ 8w  d"   \        RR
W#,
          ,          V,          4      pMRpV^ 8  d   RpVe   \        W·4      pV ! V4      pTpTpVf   R p\        V	4       EF	  pV^ 8X  g   Ve9   W§8”  d3   RpTpTpRpV^ 8X  d   RpMRRV 2,           p\        V\        ^R7        MßV^ 8„  pWÂW[,          V,          ,           8”  g   WÍ8¼  d    V'       d   \        W«VWÎWW$WVV4      w  ppp M›V! V4      p\        V4      V) V,          8:  d   V! W¼4      '       d	   TpTpTp MeV^ 8¼  d   \        WºVVVWW$WVV4      w  ppp MF^V,          pVe   \        VV4      pTp
TpTpV ! V4      pTpEK  	  TpTpRp\        R	\        ^R7       VVVV3# )aõ  Find alpha that satisfies strong Wolfe conditions.

alpha > 0 is assumed to be a descent direction.

Parameters
----------
phi : callable phi(alpha)
    Objective scalar function.
derphi : callable phi'(alpha)
    Objective function derivative. Returns a scalar.
phi0 : float, optional
    Value of phi at 0.
old_phi0 : float, optional
    Value of phi at previous point.
derphi0 : float, optional
    Value of derphi at 0
c1 : float, optional
    Parameter for Armijo condition rule.
c2 : float, optional
    Parameter for curvature condition rule.
amax : float, optional
    Maximum step size.
extra_condition : callable, optional
    A callable of the form ``extra_condition(alpha, phi_value)``
    returning a boolean. The line search accepts the value
    of ``alpha`` only if this callable returns ``True``.
    If the callable returns ``False`` for the step length,
    the algorithm will continue with new iterates.
    The callable is only called for iterates satisfying
    the strong Wolfe conditions.
maxiter : int, optional
    Maximum number of iterations to perform.

Returns
-------
alpha_star : float or None
    Best alpha, or None if the line search algorithm did not converge.
phi_star : float
    phi at alpha_star.
phi0 : float
    phi at 0.
derphi_star : float or None
    derphi at alpha_star, or None if the line search algorithm
    did not converge.

Notes
-----
Uses the line search algorithm to enforce strong Wolfe
conditions. See Wright and Nocedal, 'Numerical Optimization',
1999, pp. 59-61.

Nr4   r5   c                 ó   € R # )Tr   )rA   r   s   &&r   rH   Ú-scalar_search_wolfe2.<locals>.extra_conditionœ  s   € Ùr   z7Rounding errors prevent the line search from convergingz4The line search algorithm could not find a solution zless than or equal to amax: rL   rK   r8   )r   r9   Úranger   r   Ú_zoomÚabs)r   r&   r6   r:   r/   r   r   r(   rH   r7   Úalpha0r;   Úphi_a1Úphi_a0Ú	derphi_a0ÚirP   rQ   rR   ÚmsgÚnot_first_iterationÚ	derphi_a1Úalpha2s   &&&&&&&&&&             r   rN   rN   I  s  € ôp �Ôà‚|Ù�2‹wˆà‚Ù˜“*ˆà€FØÒ ¨1¤Ü�S˜& $¥/Õ2°7Õ:Ó;‰àˆà�„zØˆàÒÜ�VÓ"ˆá�‹[€Fð €FØ€IàÒò	ô �7�^ˆØ�QŒ;˜4Ò+°´ð ˆJØˆHØˆDØˆKà˜Œ{ØO‘àLØ4°T°FÐ;õ<�ô �Ô'°AÕ6Ùà !™eÐØ˜B�K¨'Õ1Õ1Ô1ØÔ×#6ä˜f¨fØ$°Ø"¨R°_óFñ .ˆJ˜ +ñ á˜6“Nˆ	Ü�	‹N˜r˜c '�kÔ)Ù˜v×.Ò.Ø#�
Ø!�Ø'�Ùà˜ŒNä˜f¨fØ$ i°Ø"¨R°_óFñ .ˆJ˜ +ñ à�V•ˆØÒÜ˜ Ó&ˆFØˆØˆØˆÙ�V“ˆØ‹	ñc ðj ˆ
ØˆØˆÜÐ9Ü¨1õ	.ð �x  {Ð2Ð2r   c                ód  € \         P                  ! RRRR7      ;_uu_ 4         TpW0,
          pWP,
          p	W‰,          ^,          W‰,
          ,          p
\         P                  ! R4      pV	^,          VR&   V^,          ) VR&   V	^,          ) VR&   V^,          VR&   \         P                  ! V\         P                  ! WA,
          Wx,          ,
          Wa,
          Wy,          ,
          .4      P                  4       4      w  rÍWÊ,          pWÚ,          pWÝ,          ^V,          V,          ,
          pW) \         P                  ! V4      ,           ^V,          ,          ,           p RRR4       \         P                  ! X4      '       g   R# T#   \         d     RRR4       R# i ; i  + '       g   i     LJ; i)	z®
Finds the minimizer for a cubic polynomial that goes through the
points (a,fa), (b,fb), and (c,fc) with derivative at a of fpa.

If no minimizer can be found, return None.

Úraise©ÚdivideÚoverÚinvalidN)é   ri   )r   r   )r   é   )rj   r   )rj   rj   )	r!   ÚerrstateÚemptyr"   ÚasarrayÚflattenÚsqrtÚArithmeticErrorÚisfinite)ÚaÚfaÚfpaÚbÚfbÚcr   ÚCÚdbÚdcÚdenomÚd1ÚAÚBÚradicalÚxmins   &&&&&&&         r   Ú	_cubicminr�   Ý  sQ  € ô 
�Š˜G¨'¸7×	CÖ	Cð	ØˆAØ•ˆBØ•ˆBØ•W •N b¥gÕ.ˆEÜ—’˜&Ó!ˆBØ˜Q•wˆBˆt‰HØ˜a��xˆBˆt‰HØ˜a��xˆBˆt‰HØ˜Q•wˆBˆt‰HÜ—V’V˜B¤§
¢
¨B­G°aµfÕ,<Ø,.­G°aµfÕ,<ð,>ó !?ß?F¹w»yóJ‰FˆQà�JˆAØ�JˆAØ•e˜a !�e a�iÕ'ˆGØ˜œRŸWšW WÓ-Õ-°!°aµ%Õ8Õ8‰D÷! 
Dô& �;Š;�t×ÒÙØ€Køô	 ô 	Ø÷% 
DÑ	Cð"	ú÷# 
D×	Cús)   ¢F¤D8FÆFÆFÆFÆFÆF/	c                óŠ  € \         P                  ! RRRR7      ;_uu_ 4         TpTpW0R,          ,
          pWE,
          Wg,          ,
          Ww,          ,          pWRV,          ,          ,
          p	 RRR4       \         P                  ! X	4      '       g   R# T	#   \         d     RRR4       R# i ; i  + '       g   i     LJ; i)zz
Finds the minimizer for a quadratic polynomial that goes through
the points (a,fa), (b,fb) with derivative at a of fpa.

rd   re   r5   ç       @N)r!   rk   rp   rq   )
rr   rs   rt   ru   rv   ÚDrx   ry   r~   r€   s
   &&&&&     r   Ú_quadminr…   ÿ  s›   € ô 
�Š˜G¨'¸7×	CÖ	Cð	ØˆAØˆAØ˜•W•ˆBØ•˜!�&• R¥WÕ-ˆAØ˜C !�G•}Õ$‰D÷ 
Dô �;Š;�t×ÒÙØ€Køô	 ô 	Ø÷ 
DÑ	Cð	ú÷ 
D×	Cús)   ¢B2¤ABÂB/Â#B2Â.B/Â/B2Â2C	c           	     ó¼  € ^
p^ pRpRpTp^ p W,
          pV^ 8  d   YppMYppV^ 8”  d   VV,          p\        WWAVVV4      pV^ 8X  g!   Xe   VVX,
          8”  g   VVV,           8  dG   VV,          p\        WWAV4      pVe   VVV,
          8”  g   VVV,           8  d   V RV,          ,           pV! V4      pVWyV,          V,          ,           8”  g   VV8¼  d
   TpTpTpTpM]V! V4      p\        V4      V
) V,          8:  d   V! VV4      '       d   TpTpTpM@VW,
          ,          ^ 8¼  d
   TpTpT pTpMTpT pTp TpTpV^,          pWÜ8”  g   EKE  RpRpRp VVV3# )zõZoom stage of approximate linesearch satisfying strong Wolfe conditions.

Part of the optimization algorithm in `scalar_search_wolfe2`.

Notes
-----
Implements Algorithm 3.6 (zoom) in Wright and Nocedal,
'Numerical Optimization', 1999, pp. 61.

gš™™™™™É?çš™™™™™¹?Nç      à?)r�   r…   rY   )Úa_loÚa_hiÚphi_loÚphi_hiÚ	derphi_lor   r&   r6   r/   r   r   rH   r7   r^   Údelta1Údelta2Úphi_recÚa_recÚdalpharr   ru   ÚcchkÚa_jÚqchkÚphi_ajÚ	derphi_ajÚa_starÚval_starÚvalprime_stars   &&&&&&&&&&&&                 r   rX   rX     s¤  € ð €GØ	€AØ€FØ€FØ€GØ€EØ
ð •ˆØ�AŒ:ØˆqˆAˆqàˆqˆAð �ŒEØ˜F•?ˆDÜ˜D¨)¸6Ø! 7ó,ˆCà�ŒF˜š¨¨q°4­x¬¸SÀ1ÀtÅ8¼^Ø˜F•?ˆDÜ˜4¨¸&ÓAˆCØ’  q¨¥v¤°3¸¸4½´<Ø˜S �ZÕ'�ñ �S“ˆØ�T˜s�F 7�NÕ*Ô*°¸&Ô0@ØˆGØˆEØˆDØ‰Fá˜s›ˆIÜ�9‹~ "  W¥Ô,±ÀÀf×1MÒ1MØ�Ø!�Ø )�ØØ˜$�+Õ&¨!Ô+Ø �Ø�Ø�Ø‘à �Ø�ØˆDØˆFØ!ˆIØ	ˆQ�ˆØ�KàˆFØˆHØ ˆMØØ�8˜]Ð*Ð*r   c                óÖ   a aaaa€ \         P                  ! S4      o^ .oVV VVV3R lpVf
   V! R4      p	MTp	\         P                  ! VS4      p
\        W‰W¦VR7      w  r¼VS^ ,          V3# )a£  Minimize over alpha, the function ``f(xk+alpha pk)``.

Parameters
----------
f : callable
    Function to be minimized.
xk : array_like
    Current point.
pk : array_like
    Search direction.
gfk : array_like
    Gradient of `f` at point `xk`.
old_fval : float
    Value of `f` at point `xk`.
args : tuple, optional
    Optional arguments.
c1 : float, optional
    Value to control stopping criterion.
alpha0 : scalar, optional
    Value of `alpha` at start of the optimization.

Returns
-------
alpha
f_count
f_val_at_alpha

Notes
-----
Uses the interpolation algorithm (Armijo backtracking) as suggested by
Wright and Nocedal in 'Numerical Optimization', 1999, pp. 56-57

c                 ó^   <€ S^ ;;,          ^,          uu&   S! SV S,          ,           .SO5!  # r   r   )r;   r   r   r   r   r   s   &€€€€€r   r   Úline_search_armijo.<locals>.phi”  s(   ø€ Ø
ˆ1���
‹Ù��f˜R•i•Ð' $Ó'Ð'r   r4   )r   rZ   )r!   Ú
atleast_1dr"   Úscalar_search_armijo)r   r   r   r,   r-   r   r   rZ   r   r6   r/   rA   r=   r   s   fff&&f&&     @r   Úline_search_armijor    o  sn   ü€ ôD 
�Š�rÓ	€BØ
ˆ€B÷(ñ (ð ÒÙ�2‹w‰àˆä�fŠf�S˜"‹o€GÜ& s°'Ø.4ô6�K€Eà�"�Q•%˜ÐÐr   c                óX   € \        WW#WEVVR7      pV^ ,          V^,          ^ V^,          3# )z0
Compatibility wrapper for `line_search_armijo`
)r   r   rZ   )r    )	r   r   r   r,   r-   r   r   rZ   Úrs	   &&&&&&&& r   Úline_search_BFGSr£   £  s4   € ô 	˜1 "¨8À2Ø"(ô	*€AàˆQ�4��1•�q˜!˜A�$ÐÐr   c                ó
  € V ! V4      pWaW4,          V,          ,           8:  d   WF3# V) V^,          ,          R,          Wa,
          W$,          ,
          ,          pV ! V4      pW�W7,          V,          ,           8:  d   Wx3# Wu8”  Ed~   V^,          V^,          ,          Wt,
          ,          p	V^,          W�,
          W',          ,
          ,          V^,          Wa,
          W$,          ,
          ,          ,
          p
W©,          p
V^,          ) W�,
          W',          ,
          ,          V^,          Wa,
          W$,          ,
          ,          ,           pW¹,          pV) \         P                  ! \        V^,          ^V
,          V,          ,
          4      4      ,           RV
,          ,          pV ! V4      pWÑW<,          V,          ,           8:  d   WÍ3# W|,
          VR,          8”  g   ^WÇ,          ,
          R8  d
   VR,          pTpTpTpTpEK„  RV3# )a  Minimize over alpha, the function ``phi(alpha)``.

Uses the interpolation algorithm (Armijo backtracking) as suggested by
Wright and Nocedal in 'Numerical Optimization', 1999, pp. 56-57

alpha > 0 is assumed to be a descent direction.

Returns
-------
alpha
phi1

rƒ   g      @g¸…ëQ¸î?N)r!   ro   rY   )r   r6   r/   r   rZ   r)   r\   r;   r[   Úfactorrr   ru   rb   Úphi_a2s   &&&&&&        r   rŸ   rŸ   ¬  sž  € ñ �‹[€FØ˜�	 'Õ)Õ)Ô)Øˆ~Ðð ˆZ˜& !�)Õ# cÕ)¨V­]¸WÕ=MÕ-MÕN€FÙ�‹[€Fà˜� 7Õ*Õ*Ô*Øˆ~Ðð �-Ø˜•˜V Q�YÕ&¨&­-Õ8ˆØ�A�I˜�¨­Õ7Õ8Ø�A�I˜�¨­Õ7Õ8õ9ˆà�JˆØ�Q�YˆJ˜&�-¨'­.Õ8Õ9Ø�A�I˜�¨­Õ7Õ8õ9ˆà�Jˆà�"”r—w’wœs 1 a¥4¨!¨a­%°'­/Õ#9Ó:Ó;Õ;ÀÀAÅÕFˆÙ�V“ˆà˜R�Y wÕ.Õ.Ô.Ø�>Ð!à�O˜v¨�|Ô+°°FµMÕ0AÀTÔ/IØ˜c•\ˆFàˆØˆØˆØ‹ð �ˆ<Ðr   c                ó´  € VR,          p\        V4      p	^p
^p^p WV,          ,           pV ! V4      w  rïWéV,           WZ^,          ,          V,          ,
          8:  d   T
pMöV
^,          V,          V^V
,          ^,
          V,          ,           ,          pWV,          ,
          pV ! V4      w  rïWéV,           W[^,          ,          V,          ,
          8:  d   V) pM~V^,          V,          V^V,          ^,
          V,          ,           ,          p\        P                  ! VWj,          Wz,          4      p
\        P                  ! VWk,          W{,          4      pEK;  WÍWï3# )a¼  
Nonmonotone backtracking line search as described in [1]_

Parameters
----------
f : callable
    Function returning a tuple ``(f, F)`` where ``f`` is the value
    of a merit function and ``F`` the residual.
x_k : ndarray
    Initial position.
d : ndarray
    Search direction.
prev_fs : float
    List of previous merit function values. Should have ``len(prev_fs) <= M``
    where ``M`` is the nonmonotonicity window parameter.
eta : float
    Allowed merit function increase, see [1]_
gamma, tau_min, tau_max : float, optional
    Search parameters, see [1]_

Returns
-------
alpha : float
    Step length
xp : ndarray
    Next position
fp : float
    Merit function value at next position
Fp : ndarray
    Residual at next position

References
----------
[1] "Spectral residual method without gradient information for solving
    large-scale nonlinear systems of equations." W. La Cruz,
    J.M. Martinez, M. Raydan. Math. Comp. **75**, 1429 (2006).

éÿÿÿÿ)Úmaxr!   Úclip)r   Úx_kÚdÚprev_fsÚetaÚgammaÚtau_minÚtau_maxÚf_kÚf_barÚalpha_pÚalpha_mrA   ÚxpÚfpÚFpÚalpha_tpÚalpha_tms   &&&&&&&&          r   Ú_nonmonotone_line_search_cruzr»   ê  s$  € ðP �"�+€CÜ�‹L€Eà€GØ€GØ€Eà
Ø˜Q•;ÕˆÙ�2“‰ˆà˜•˜u°¥zÕ1°CÕ7Õ7Ô7ØˆEØà˜A•: Õ# r¨Q¨w­Y¸­]¸CÕ,?Õ'?Õ@ˆà˜Q•;ÕˆÙ�2“‰ˆà˜•˜u°¥zÕ1°CÕ7Õ7Ô7Ø�HˆEØà˜A•: Õ# r¨Q¨w­Y¸­]¸CÕ,?Õ'?Õ@ˆä—'’'˜( GÕ$5°wÕ7HÓIˆÜ—'’'˜( GÕ$5°wÕ7HÓI‹à�bÐÐr   c                óü  € ^p^p^p WV,          ,           pV ! V4      w  ppWôV,           W{^,          ,          V,          ,
          8:  d   TpM÷V^,          V,          V^V,          ^,
          V,          ,           ,          pWV,          ,
          pV ! V4      w  ppWôV,           W|^,          ,          V,          ,
          8:  d   V) pM~V^,          V,          V^V,          ^,
          V,          ,           ,          p\         P                  ! VW‹,          W›,          4      p\         P                  ! VWŒ,          Wœ,          4      pEK=  W¥,          ^,           pW¥,          WF,           ,          V,           V,          pTpWÞVVWE3# )aî  
Nonmonotone line search from [1]

Parameters
----------
f : callable
    Function returning a tuple ``(f, F)`` where ``f`` is the value
    of a merit function and ``F`` the residual.
x_k : ndarray
    Initial position.
d : ndarray
    Search direction.
f_k : float
    Initial merit function value.
C, Q : float
    Control parameters. On the first iteration, give values
    Q=1.0, C=f_k
eta : float
    Allowed merit function increase, see [1]_
nu, gamma, tau_min, tau_max : float, optional
    Search parameters, see [1]_

Returns
-------
alpha : float
    Step length
xp : ndarray
    Next position
fp : float
    Merit function value at next position
Fp : ndarray
    Residual at next position
C : float
    New value for the control parameter C
Q : float
    New value for the control parameter Q

References
----------
.. [1] W. Cheng & D.-H. Li, ''A derivative-free nonmonotone line
       search and its application to the spectral residual
       method'', IMA J. Numer. Anal. 29, 814 (2009).

)r!   rª   )r   r«   r¬   r²   rx   ÚQr®   r¯   r°   r±   Únur´   rµ   rA   r¶   r·   r¸   r¹   rº   ÚQ_nexts   &&&&&&&&&&&         r   Ú_nonmonotone_line_search_chengrÀ   2  sD  € ð^ €GØ€GØ€Eà
Ø˜Q•;ÕˆÙ�2“‰ˆˆBà�S•˜5¨A¥:Õ-°Õ3Õ3Ô3ØˆEØà˜A•: Õ# r¨Q¨w­Y¸­]¸CÕ,?Õ'?Õ@ˆà˜Q•;ÕˆÙ�2“‰ˆˆBà�S•˜5¨A¥:Õ-°Õ3Õ3Ô3Ø�HˆEØà˜A•: Õ# r¨Q¨w­Y¸­]¸CÕ,?Õ'?Õ@ˆä—'’'˜( GÕ$5°wÕ7HÓIˆÜ—'’'˜( GÕ$5°wÕ7HÓI‹ð �V�a�Z€FØ	��1•7Õ	˜bÕ	  FÕ*€AØ€Aà�b˜"˜aÐ"Ð"r   )r   r2   rS   r+   rN   r    )	NNNr   ç-Cëâ6?çÍÌÌÌÌÌì?é2   ç:Œ0âŽyE>ç›+¡†›„=)NNNrÁ   rÂ   rÃ   rÄ   rÅ   )	NNNr   rÁ   rÂ   NNé
   )NNNrÁ   rÂ   NNrÆ   )r   rÁ   rj   )rÁ   rj   r   )rÁ   r‡   rˆ   )rÁ   r‡   rˆ   g333333ë?)Ú__doc__Úwarningsr   Ú_dcsrchr   Únumpyr!   Ú__all__ÚRuntimeWarningr   r   r2   r+   Úline_searchrS   rN   r�   r…   rX   r    r£   rŸ   r»   rÀ   r   r   r   Ú<module>rÎ      s€   ðñõ å Û ò!€ô	˜ô 	ò/ô<6ô~JðZ !€ôLEô^Q3òhòDò*T+ôv1ôhô7ô|EöPN#r   