ó
    Eñi%  ã                   óL   • S r SSKrSSKrSSKJrJr  / rSS jr	 " S S\5      r
g)	z"Dog-leg trust-region optimization.é    Né   )Ú_minimize_trust_regionÚBaseQuadraticSubproblemc                 ó|   • Uc  [        S5      e[        U5      (       d  [        S5      e[        X4X#U[        S.UD6$ )aä  
Minimization of scalar function of one or more variables using
the dog-leg trust-region algorithm.

Options
-------
initial_trust_radius : float
    Initial trust-region radius.
max_trust_radius : float
    Maximum value of the trust-region radius. No steps that are longer
    than this value will be proposed.
eta : float
    Trust region related acceptance stringency for proposed steps.
gtol : float
    Gradient norm must be less than `gtol` before successful
    termination.

z,Jacobian is required for dogleg minimizationz+Hessian is required for dogleg minimization)ÚargsÚjacÚhessÚ
subproblem)Ú
ValueErrorÚcallabler   ÚDoglegSubproblem)ÚfunÚx0r   r   r	   Útrust_region_optionss         Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/scipy/optimize/_trustregion_dogleg.pyÚ_minimize_doglegr   	   sM   € ð( �{ÜÐGÓHÐHÜ�D�>‰>ÜÐFÓGÐGÜ! #ð :°ÀDÜ-=ñ:à$8ñ:ð :ó    c                   ó*   • \ rS rSrSrS rS rS rSrg)r   é&   z0Quadratic subproblem solved by the dogleg methodc                 óÚ   • U R                   cS  U R                  nU R                  U5      n[        R                  " X5      [        R                  " X5      -  * U-  U l         U R                   $ )zF
The Cauchy point is minimal along the direction of steepest descent.
)Ú_cauchy_pointr   ÚhesspÚnpÚdot)ÚselfÚgÚBgs      r   Úcauchy_pointÚDoglegSubproblem.cauchy_point)   sW   € ð ×ÑÑ%Ø—‘ˆAØ—‘˜A“ˆBÜ#%§6¢6¨!£<´"·&²&¸³-Ñ#?Ð!@À1Ñ!DˆDÔØ×!Ñ!Ð!r   c                 óì   • U R                   c\  U R                  nU R                  n[        R                  R                  U5      n[        R                  R                  X15      * U l         U R                   $ )zC
The Newton point is a global minimum of the approximate function.
)Ú_newton_pointr   r	   ÚscipyÚlinalgÚ
cho_factorÚ	cho_solve)r   r   ÚBÚcho_infos       r   Únewton_pointÚDoglegSubproblem.newton_point3   s\   € ð ×ÑÑ%Ø—‘ˆAØ—	‘	ˆAÜ—|‘|×.Ñ.¨qÓ1ˆHÜ"'§,¡,×"8Ñ"8¸Ó"EÐ!EˆDÔØ×!Ñ!Ð!r   c                 ó<  • U R                  5       n[        R                  R                  U5      U:  a  SnX#4$ U R	                  5       n[        R                  R                  U5      nXQ:¼  a  XAU-  -  nSnXc4$ U R                  XBU-
  U5      u  pxXHX$-
  -  -   nSnXc4$ )aÔ  
Minimize a function using the dog-leg trust-region algorithm.

This algorithm requires function values and first and second derivatives.
It also performs a costly Hessian decomposition for most iterations,
and the Hessian is required to be positive definite.

Parameters
----------
trust_radius : float
    We are allowed to wander only this far away from the origin.

Returns
-------
p : ndarray
    The proposed step.
hits_boundary : bool
    True if the proposed step is on the boundary of the trust region.

Notes
-----
The Hessian is required to be positive definite.

References
----------
.. [1] Jorge Nocedal and Stephen Wright,
       Numerical Optimization, second edition,
       Springer-Verlag, 2006, page 73.
FT)r(   r"   r#   Únormr   Úget_boundaries_intersections)	r   Útrust_radiusÚp_bestÚhits_boundaryÚp_uÚp_u_normÚ
p_boundaryÚ_Útbs	            r   ÚsolveÚDoglegSubproblem.solve>   sº   € ðD ×"Ñ"Ó$ˆÜ�<‰<×Ñ˜VÓ$ |Ó3Ø!ˆMØÐ(Ð(ð ×ÑÓ!ˆô —<‘<×$Ñ$ SÓ)ˆØÓ#Ø¨xÑ 7Ñ8ˆJØ ˆMØÐ,Ð,ð ×1Ñ1°#À±|Ø2>ó@‰ˆà ¡Ñ.Ñ.ˆ
ØˆØÐ(Ð(r   )r   r!   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r(   r5   Ú__static_attributes__© r   r   r   r   &   s   † Ù:ò"ò	"õ<)r   r   )r=   NN)r;   Únumpyr   Úscipy.linalgr"   Ú_trustregionr   r   Ú__all__r   r   r=   r   r   Ú<module>rB      s*   ðÙ (Û Û ß Kà
€ô:ô:T)Ð.õ T)r   