+
    LV-jZ.  ã                   ó†   € R t ^ RIt^ RIt^ RIt^ RIt^RIHtH	t	H
t
HtHt ^ RIHt ^ RIHt . tR t ! R R4      tR	R ltR# )
zTrust-region optimization.N)Ú_check_unknown_optionsÚ_status_messageÚOptimizeResultÚ_prepare_scalar_functionÚ_call_callback_maybe_halt)ÚHessianUpdateStrategy)Ú
FD_METHODSc                 ó6   a aa€ ^ .oS f   SR3# VV V3R lpSV3# )é    Nc                 óx   <€ S^ ;;,          ^,          uu&   S! \         P                  ! V 4      .VS,           O5!  # )r
   )ÚnpÚcopy)ÚxÚwrapper_argsÚargsÚfunctionÚncallss   &*€€€Úl/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_trustregion.pyÚfunction_wrapperÚ(_wrap_function.<locals>.function_wrapper   s-   ø€ Øˆq�	�Q�‹	áœŸš ›
Ð; l°TÕ&9Ó;Ð;ó    © )r   r   r   r   s   ff @r   Ú_wrap_functionr      s/   ú€ ð ˆS€FØÒØ�tˆ|Ð÷<ð
 Ð#Ð#Ð#r   c                   ó†   a € ] tR t^t o RtRR ltR t]R 4       t]R 4       t	]R 4       t
R t]R	 4       tR
 tR tRtV tR# )ÚBaseQuadraticSubproblema9  
Base/abstract class defining the quadratic model for trust-region
minimization. Child classes must implement the ``solve`` method.

Values of the objective function, Jacobian and Hessian (if provided) at
the current iterate ``x`` are evaluated on demand and then stored as
attributes ``fun``, ``jac``, ``hess``.
Nc                ó–   € Wn         R V n        R V n        R V n        R V n        R V n        R V n        W n        W0n        W@n	        WPn
        R # ©N)Ú_xÚ_fÚ_gÚ_hÚ_g_magÚ_cauchy_pointÚ_newton_pointÚ_funÚ_jacÚ_hessÚ_hessp)Úselfr   ÚfunÚjacÚhessÚhessps   &&&&&&r   Ú__init__Ú BaseQuadraticSubproblem.__init__(   sG   € ØŒØˆŒØˆŒØˆŒØˆŒØ!ˆÔØ!ˆÔØŒ	ØŒ	ØŒ
ØŽr   c                óÈ   € V P                   \        P                  ! V P                  V4      ,           R \        P                  ! WP	                  V4      4      ,          ,           # )g      à?)r)   r   Údotr*   r,   ©r(   Úps   &&r   Ú__call__Ú BaseQuadraticSubproblem.__call__5   s;   € Ø�x‰xœ"Ÿ&š& §¡¨1Ó-Õ-°´b·f²f¸QÇ
Á
È1ÃÓ6NÕ0NÕNÐNr   c                óv   € V P                   f!   V P                  V P                  4      V n         V P                   # )z1Value of objective function at current iteration.)r   r$   r   ©r(   s   &r   r)   ÚBaseQuadraticSubproblem.fun8   ó*   € ð �7‰7Š?Ø—i‘i §¡Ó(ˆDŒGØ�w‰wˆr   c                óv   € V P                   f!   V P                  V P                  4      V n         V P                   # )z=Value of Jacobian of objective function at current iteration.)r   r%   r   r6   s   &r   r*   ÚBaseQuadraticSubproblem.jac?   r8   r   c                óv   € V P                   f!   V P                  V P                  4      V n         V P                   # )z<Value of Hessian of objective function at current iteration.)r    r&   r   r6   s   &r   r+   ÚBaseQuadraticSubproblem.hessF   s*   € ð �7‰7Š?Ø—j‘j §¡Ó)ˆDŒGØ�w‰wˆr   c                ó˜   € V P                   e   V P                  V P                  V4      # \        P                  ! V P                  V4      # r   )r'   r   r   r0   r+   r1   s   &&r   r,   ÚBaseQuadraticSubproblem.hesspM   s6   € Ø�;‰;Ò"Ø—;‘;˜tŸw™w¨Ó*Ð*ä—6’6˜$Ÿ)™) QÓ'Ð'r   c                ó’   € V P                   f/   \        P                  P                  V P                  4      V n         V P                   # )zAMagnitude of jacobian of objective function at current iteration.)r!   ÚscipyÚlinalgÚnormr*   r6   s   &r   Újac_magÚBaseQuadraticSubproblem.jac_magS   s2   € ð �;‰;ÒÜŸ,™,×+Ñ+¨D¯H©HÓ5ˆDŒKØ�{‰{Ðr   c                ó¦  € \         P                  ! W"4      p^\         P                  ! W4      ,          p\         P                  ! W4      V^,          ,
          p\        P                  ! WU,          ^V,          V,          ,
          4      pV\        P                  ! Wu4      ,           pV) ^V,          ,          p	RV,          V,          p
\        Wš.4      # )z¤
Solve the scalar quadratic equation ``||z + t d|| == trust_radius``.
This is like a line-sphere intersection.
Return the two values of t, sorted from low to high.
éþÿÿÿ)r   r0   ÚmathÚsqrtÚcopysignÚsorted)r(   ÚzÚdÚtrust_radiusÚaÚbÚcÚsqrt_discriminantÚauxÚtaÚtbs   &&&&       r   Úget_boundaries_intersectionsÚ4BaseQuadraticSubproblem.get_boundaries_intersectionsZ   s•   € ô �FŠF�1‹LˆØ”—’�q“ÕˆÜ�FŠF�1‹L˜<¨�?Õ*ˆÜ ŸIšI a¥c¨A¨a­C°­E¥kÓ2Ðð ”$—-’-Ð 1Ó5Õ5ˆØˆT�Q�q•S�\ˆØ��T�C�ZˆÜ�r�hÓÐr   c                ó   € \        R 4      h)z9The solve method should be implemented by the child class)ÚNotImplementedError)r(   rM   s   &&r   ÚsolveÚBaseQuadraticSubproblem.solveq   s   € Ü!ð #4ó 5ð 	5r   )r"   r   r$   r   r!   r    r&   r'   r%   r#   r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r-   r3   Úpropertyr)   r*   r+   r,   rC   rU   rY   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r      sy   ø‡ € ñôòOð ñó ðð ñó ðð ñó ðò(ð ñó ðò ÷.5ð 5r   r   c                óØ  a&€ \        V4       Vf   \        R4      hVf   Vf   \        R4      hVf   \        R4      h^ T	u;8:  d   R8  g   M \        R4      hV^ 8:  d   \        R4      hV^ 8:  d   \        R4      hWx8¼  d   \        R	4      h\        P                  ! V4      P                  4       p\        WW4VVR
7      o&S&P                  p S&P                  p\        V4      '       d   S&P                  pMG\        V4      '       d   M5V\        9   g   \        V\        4      '       d
   RpV&3R lpM\        R4      h\        WR4      w  ppVf   \        V4      ^È,          p^ pTpTpV'       d   V.p/ p\!        VR4      '       d   VVR&   V! VWWE3/ VB p^ pVP"                  V
8¼  Ed4    VP%                  V4      w  ppT! T4      pTT,           pT! TYYE3/ TB pTP                  TP                  ,
          p TP                  T,
          p!T!^ 8:  d   ^pMÈT T!,          p"T"R8  d   TR,          pM"T"R8”  d   T'       d   \+        ^T,          T4      pT"T	8”  d   TpTpT'       d&   XP-                  \        P.                  ! T4      4       T^,          p\1        TTP                  R7      p#\3        TT#4      '       d   M!TP"                  T
8  d   ^ pMTT8¼  g   EKB  ^p \4        R,          \4        R,          RR3p$V'       dÀ   V^ 8X  d   \7        V$V,          4       M$\8        P:                  ! V$V,          \<        ^R7       \7        RVP                  R 24       \7        RVR 24       \7        RS&P>                  R 24       \7        RS&P@                  R 24       \7        RS&PB                  V^ ,          ,           R 24       \1        VV^ 8H  VVP                  VPD                  S&P>                  S&P@                  S&PB                  V^ ,          ,           VV$V,          R7
      p%Ve   VP                  V%R&   V'       d   XV%R&   V%#   \        P&                  P(                   d    ^p EK‰  i ; i)av  
Minimization of scalar function of one or more variables using a
trust-region algorithm.

Options for the trust-region algorithm are:
    initial_trust_radius : float
        Initial trust radius.
    max_trust_radius : float
        Never propose steps that are longer than this value.
    eta : float
        Trust region related acceptance stringency for proposed steps.
    gtol : float
        Gradient norm must be less than `gtol`
        before successful termination.
    maxiter : int
        Maximum number of iterations to perform.
    disp : bool
        If True, print convergence message.
    inexact : bool
        Accuracy to solve subproblems. If True requires less nonlinear
        iterations, but more vector products. Only effective for method
        trust-krylov.
    workers : int, map-like callable, optional
        A map-like callable, such as `multiprocessing.Pool.map` for evaluating
        any numerical differentiation in parallel.
        This evaluation is carried out as ``workers(fun, iterable)``.
        Only for 'trust-krylov', 'trust-ncg'.

        .. versionadded:: 1.16.0
    subproblem_maxiter : int, optional
        Maximum number of iterations to perform per subproblem. Only affects
        trust-exact. Default is 25.

        .. versionadded:: 1.17.0


This function is called by the `minimize` function.
It is not supposed to be called directly.
Nz7Jacobian is currently required for trust-region methodsz_Either the Hessian or the Hessian-vector product is currently required for trust-region methodszBA subproblem solving strategy is required for trust-region methodsg      Ð?zinvalid acceptance stringencyz%the max trust radius must be positivez)the initial trust radius must be positivez?the initial trust radius must be less than the max trust radius)r*   r+   r   Úworkersc                 óD   <€ SP                  V 4      P                  V4      # r   )r+   r0   )r   r2   r   Úsfs   &&*€r   r,   Ú%_minimize_trust_region.<locals>.hesspÔ   s   ø€ Ø—7‘7˜1“:—>‘> !Ó$Ð$r   ÚMAXITER_DEFAULTÚmaxiterg      è?)r   r)   Úsuccessz:A bad approximation caused failure to predict improvement.z3A linalg error occurred, such as a non-psd Hessian.)Ú
stacklevelz!         Current function value: Úfz         Iterations: rL   z         Function evaluations: z         Gradient evaluations: z         Hessian evaluations: )
r   rk   Ústatusr)   r*   ÚnfevÚnjevÚnhevÚnitÚmessager+   Úallvecs)#r   Ú
ValueErrorÚ	Exceptionr   ÚasarrayÚflattenr   r)   ÚgradÚcallabler+   r   Ú
isinstancer   r   ÚlenÚhasattrrC   rY   rA   ÚLinAlgErrorÚminÚappendr   r   r   r   ÚprintÚwarningsÚwarnÚRuntimeWarningro   Úngevrq   r*   )'r)   Úx0r   r*   r+   r,   Ú
subproblemÚinitial_trust_radiusÚmax_trust_radiusÚetaÚgtolrj   ÚdispÚ
return_allÚcallbackÚinexactre   Úsubproblem_maxiterÚunknown_optionsÚnhesspÚwarnflagrM   r   rt   Úsubproblem_init_kwÚmÚkr2   Úhits_boundaryÚpredicted_valueÚ
x_proposedÚ
m_proposedÚactual_reductionÚpredicted_reductionÚrhoÚintermediate_resultÚstatus_messagesÚresultrg   s'   &&&&&&&&&&&&&&&&&&,                   @r   Ú_minimize_trust_regionr¡   v   sR  ø€ ôZ ˜?Ô+à
‚{Üð #ó $ð 	$à‚|˜šÜð Jó Kð 	KàÒÜð 0ó 1ð 	1à�ŽO�tŽOÜÐ7Ó8Ð8Ø˜1ÔÜÐ?Ó@Ð@Ø˜qÔ ÜÐDÓEÐEØÔ/Üð ,ó -ð 	-ô 
�Š�B‹×	Ñ	Ó	!€Bô 
"Ø�S¨$¸ô
€Bð �&‰&€CØ
�'‰'€CÜ�‡~‚~Ø�w‰w‰Ü	�%�Šð 	Ø
”*Ô
¤
¨4Ô1F× GÒ Gð ˆö	%ô ð Jó Kð 	Kô # 5Ó/�M€FˆEð ‚Ü�b“'˜#•+ˆð €Hð (€LØ
€AßØ�#ˆàÐÜˆzÐ,×-Ò-Ø(:Ð˜9Ñ%á�1�c ÑBÐ/AÑB€AØ	€Að �)‰)�tÕ
ð	Ø Ÿw™w |Ó4ÑˆAˆ}ñ ˜A›$ˆð ˜•Uˆ
Ù 
¨C°dÑXÐEWÑXˆ
ð Ÿ5™5 :§>¡>Õ1ÐØŸe™e oÕ5ÐØ !Ô#ØˆHØØÐ!4Õ4ˆð �Œ:Ø˜DÕ ‰LØ�4ŒZŸMÜ˜q �~Ð/?Ó@ˆLð �Œ9ØˆAØˆA÷ Ø�N‰Nœ2Ÿ7š7 1›:Ô&Ø	ˆQ�ˆä,¨q°a·e±eÔ<ÐÜ$ XÐ/B×CÒCØð �9‰9�tÔØˆHØð ��<ØˆHØô ˜IÕ&Ü˜IÕ&ØHØAð	€O÷ Ø�qŒ=Ü�/ (Õ+Õ,ä�MŠM˜/¨(Õ3´^ÐPQÕRÜÐ1°!·%±%¸°Ð;Ô<ÜÐ% a¨ UÐ+Ô,ÜÐ/°·±¸¨{Ð;Ô<ÜÐ/°·±¸¨{Ð;Ô<ÜÐ.¨r¯w©w¸À½Õ/BÀ1Ð.EÐFÔGä˜a¨(°a©-ÀØ !§¡¨1¯5©5°r·w±wÀRÇWÁWØ!#§¡¨6°!­9Õ!4¸!Ø$3°HÕ$=ô?€Fð
 ÒØŸ™ˆˆv‰çØ#ˆˆyÑà€Møô] �y‰y×$Ñ$ô 	ØˆHÛð	ús   Æ-Q Ñ!Q)Ñ(Q))r   NNNNg      ð?g     @�@g333333Ã?g-Cëâ6?NFFNTNN)r_   rG   r‚   Únumpyr   Úscipy.linalgr@   Ú	_optimizer   r   r   r   r   Ú'scipy.optimize._hessian_update_strategyr   Ú(scipy.optimize._differentiable_functionsr   Ú__all__r   r   r¡   r   r   r   Ú<module>r¨      sD   ðÙ  Û Û ã Û ÷3õ 3õ JÝ ?Ø
€ò$÷U5ñ U5öpSr   