+
    /i                         ^ RI t ^ RIt^ RIHt ^RIHtHt ^RIH	t	H
t
 ^RIHtHtHtHtHt ^RIHt ^RIHt ]P*                  ! ]4      P.                  t]P*                  ! ]4      P2                  t ! R R	4      tR# )
    N)
lsq_linear)Models	Quadratic)Options	Constants)cauchy_geometryspider_geometrynormal_byrd_omojokuntangential_byrd_omojokun$constrained_tangential_byrd_omojokun)qr_tangential_byrd_omojokun)get_arrays_tolc                     a  ] tR t^t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]P                  R	 4       t]R
 4       t]P                  R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       tR tR tR tR tR tR tR tR tR,R ltR tR t R t!R  t"R! t#R" t$R# t%R$ t&R-R% lt'R& t(R' t)R( t*R) t+R* t,R+t-V t.R# ).TrustRegionz
Trust-region framework.
c                \   RV n         Wn        \        V P                  W P                  4      V n        W0n        ^ V n        V P                  4        \        P                  ! V P                  4      V n        \        P                  ! V P                  4      V n        \        P                  ! V P                  4      V n        \        P                  ! V P                   4      V n        V P%                  V P&                  4       V\(        P*                  ,          V n        V P.                  V n        R# )aa  
Initialize the trust-region framework.

Parameters
----------
pb : `cobyqa.problem.Problem`
    Problem to solve.
options : dict
    Options of the solver.
constants : dict
    Constants of the solver.

Raises
------
`cobyqa.utils.MaxEvalError`
    If the maximum number of evaluations is reached.
`cobyqa.utils.TargetSuccess`
    If a nearly feasible point has been found with an objective
    function value below the target.
`cobyqa.utils.FeasibleSuccess`
    If a feasible point has been found for a feasibility problem.
`numpy.linalg.LinAlgError`
    If the initial interpolation system is ill-defined.
        N)_penalty_pbr   penalty_models
_constants_best_indexset_best_indexnpzerosm_linear_ub_lm_linear_ubm_linear_eq_lm_linear_eqm_nonlinear_ub_lm_nonlinear_ubm_nonlinear_eq_lm_nonlinear_eqset_multipliersx_bestr   RHOBEG_resolution
resolution_radius)selfpboptions	constantss   &&&&Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/_lib/cobyqa/framework.py__init__TrustRegion.__init__   s    4  dhh>#   XXd&6&67XXd&6&67 ")<)< = ")<)< =T[[) #7>>2    c                .    V P                   P                  # )zD
Number of variables.

Returns
-------
int
    Number of variables.
)r   nr*   s   &r.   r3   TrustRegion.nL   s     xxzzr1   c                .    V P                   P                  # )zl
Number of linear inequality constraints.

Returns
-------
int
    Number of linear inequality constraints.
)r   r   r4   s   &r.   r   TrustRegion.m_linear_ubX        xx###r1   c                .    V P                   P                  # )zh
Number of linear equality constraints.

Returns
-------
int
    Number of linear equality constraints.
)r   r   r4   s   &r.   r   TrustRegion.m_linear_eqd   r8   r1   c                .    V P                   P                  # )zr
Number of nonlinear inequality constraints.

Returns
-------
int
    Number of nonlinear inequality constraints.
)r   r    r4   s   &r.   r    TrustRegion.m_nonlinear_ubp        xx&&&r1   c                .    V P                   P                  # )zn
Number of nonlinear equality constraints.

Returns
-------
int
    Number of nonlinear equality constraints.
)r   r"   r4   s   &r.   r"   TrustRegion.m_nonlinear_eq|   r=   r1   c                    V P                   # )zF
Trust-region radius.

Returns
-------
float
    Trust-region radius.
)r)   r4   s   &r.   radiusTrustRegion.radius        ||r1   c                    Wn         V P                  V P                  \        P                  ,          V P
                  ,          8:  d   V P
                  V n         R# R# )za
Set the trust-region radius.

Parameters
----------
radius : float
    New trust-region radius.
N)r)   rA   r   r   DECREASE_RADIUS_THRESHOLDr(   )r*   rA   s   &&r.   rA   rB      sE     KKyBBCoo  ??DL	r1   c                    V P                   # )z
Resolution of the trust-region framework.

The resolution is a lower bound on the trust-region radius.

Returns
-------
float
    Resolution of the trust-region framework.
r'   r4   s   &r.   r(   TrustRegion.resolution   s     r1   c                    Wn         R# )z
Set the resolution of the trust-region framework.

Parameters
----------
resolution : float
    New resolution of the trust-region framework.
NrG   )r*   r(   s   &&r.   r(   rH      s
     &r1   c                    V P                   # )zB
Penalty parameter.

Returns
-------
float
    Penalty parameter.
)r   r4   s   &r.   r   TrustRegion.penalty   s     }}r1   c                    V P                   # )z
Models of the objective function and constraints.

Returns
-------
`cobyqa.models.Models`
    Models of the objective function and constraints.
)r   r4   s   &r.   modelsTrustRegion.models   rC   r1   c                    V P                   # )zh
Index of the best interpolation point.

Returns
-------
int
    Index of the best interpolation point.
)r   r4   s   &r.   
best_indexTrustRegion.best_index   s     r1   c                `    V P                   P                  P                  V P                  4      # )z
Best interpolation point.

Its value is interpreted as relative to the origin, not the base point.

Returns
-------
`numpy.ndarray`
    Best interpolation point.
)rM   interpolationpointrP   r4   s   &r.   r%   TrustRegion.x_best   s#     {{((..t??r1   c                P    V P                   P                  V P                  ,          # )zv
Value of the objective function at `x_best`.

Returns
-------
float
    Value of the objective function at `x_best`.
)rM   fun_valrP   r4   s   &r.   fun_bestTrustRegion.fun_best   s     {{""4??33r1   c                T    V P                   P                  V P                  R3,          # )z
Values of the nonlinear inequality constraints at `x_best`.

Returns
-------
`numpy.ndarray`, shape (m_nonlinear_ub,)
    Values of the nonlinear inequality constraints at `x_best`.
NNN)rM   cub_valrP   r4   s   &r.   cub_bestTrustRegion.cub_best   "     {{""4??A#566r1   c                T    V P                   P                  V P                  R3,          # )z
Values of the nonlinear equality constraints at `x_best`.

Returns
-------
`numpy.ndarray`, shape (m_nonlinear_eq,)
    Values of the nonlinear equality constraints at `x_best`.
r[   )rM   ceq_valrP   r4   s   &r.   ceq_bestTrustRegion.ceq_best
  r_   r1   c                   V P                   P                  V4      V P                  V P                  P                  P
                  V,          V P                  P                  P                  ,
          ,          ,           V P                  V P                  P                  P                  V,          V P                  P                  P                  ,
          ,          ,           V P                  V P                   P                  V4      ,          ,           V P                  V P                   P                  V4      ,          ,           # )z
Evaluate the Lagrangian model at a given point.

Parameters
----------
x : `numpy.ndarray`, shape (n,)
    Point at which the Lagrangian model is evaluated.

Returns
-------
float
    Value of the Lagrangian model at `x`.
)rM   funr   r   lineara_ubb_ubr   a_eqb_eqr!   cubr#   ceqr*   xs   &&r.   	lag_modelTrustRegion.lag_model  s     KKOOA  xx##a'$((//*>*>>@@   xx##a'$((//*>*>>@@
 ##dkkooa&889 ##dkkooa&889	
r1   c                   V P                   P                  V4      V P                  V P                  P                  P
                  ,          ,           V P                  V P                  P                  P                  ,          ,           V P                  V P                   P                  V4      ,          ,           V P                  V P                   P                  V4      ,          ,           # )a  
Evaluate the gradient of the Lagrangian model at a given point.

Parameters
----------
x : `numpy.ndarray`, shape (n,)
    Point at which the gradient of the Lagrangian model is evaluated.

Returns
-------
`numpy.ndarray`, shape (n,)
    Gradient of the Lagrangian model at `x`.
)rM   fun_gradr   r   rf   rg   r   ri   r!   cub_gradr#   ceq_gradrm   s   &&r.   lag_model_gradTrustRegion.lag_model_grad.  s     KK  #  488??#7#778  488??#7#778 ##dkk&:&:1&==> ##dkk&:&:1&==	>	
r1   c                B   V P                   P                  4       pV P                  ^ 8  d2   WP                  V P                   P	                  4       ,          ,          pV P
                  ^ 8  d2   WP                  V P                   P                  4       ,          ,          pV# )z
Evaluate the Hessian matrix of the Lagrangian model at a given point.

Returns
-------
`numpy.ndarray`, shape (n, n)
    Hessian matrix of the Lagrangian model at `x`.
)rM   fun_hessr    r!   cub_hessr"   r#   ceq_hess)r*   hesss   & r.   lag_model_hessTrustRegion.lag_model_hessD  sw     {{##%"))DKK,@,@,BBBD"))DKK,@,@,BBBDr1   c                    V P                   P                  V4      V P                  V P                   P                  V4      ,          ,           V P                  V P                   P                  V4      ,          ,           # )at  
Evaluate the right product of the Hessian matrix of the Lagrangian
model with a given vector.

Parameters
----------
v : `numpy.ndarray`, shape (n,)
    Vector with which the Hessian matrix of the Lagrangian model is
    multiplied from the right.

Returns
-------
`numpy.ndarray`, shape (n,)
    Right product of the Hessian matrix of the Lagrangian model with
    `v`.
)rM   fun_hess_prodr!   cub_hess_prodr#   ceq_hess_prodr*   vs   &&r.   lag_model_hess_prodTrustRegion.lag_model_hess_prodT  sa    $ KK%%a(##dkk&?&?&BBC##dkk&?&?&BBC	
r1   c                    V P                   P                  V4      V P                  V P                   P                  V4      ,          ,           V P                  V P                   P                  V4      ,          ,           # )a  
Evaluate the curvature of the Lagrangian model along a given direction.

Parameters
----------
v : `numpy.ndarray`, shape (n,)
    Direction along which the curvature of the Lagrangian model is
    evaluated.

Returns
-------
float
    Curvature of the Lagrangian model along `v`.
)rM   fun_curvr!   cub_curvr#   ceq_curvr   s   &&r.   lag_model_curvTrustRegion.lag_model_curvk  s_      KK  ###dkk&:&:1&==>##dkk&:&:1&==>	
r1   c                    VV P                   P                  V P                  4      RV P                  V4      ,          ,           ,          # )a%  
Evaluate the objective function of the SQP subproblem.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Step along which the objective function of the SQP subproblem is
    evaluated.

Returns
-------
float
    Value of the objective function of the SQP subproblem along `step`.
g      ?)rM   rr   r%   r   r*   steps   &&r.   sqp_funTrustRegion.sqp_fun  s?     KK  -D,,T223
 	
r1   c                    V P                   P                  V P                  4      V P                   P                  V P                  4      V,          ,           # )as  
Evaluate the linearization of the nonlinear inequality constraints.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Step along which the linearization of the nonlinear inequality
    constraints is evaluated.

Returns
-------
`numpy.ndarray`, shape (m_nonlinear_ub,)
    Value of the linearization of the nonlinear inequality constraints
    along `step`.
)rM   rk   r%   rs   r   s   &&r.   sqp_cubTrustRegion.sqp_cub  =    " KKOODKK(kk""4;;/$67	
r1   c                    V P                   P                  V P                  4      V P                   P                  V P                  4      V,          ,           # )am  
Evaluate the linearization of the nonlinear equality constraints.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Step along which the linearization of the nonlinear equality
    constraints is evaluated.

Returns
-------
`numpy.ndarray`, shape (m_nonlinear_ub,)
    Value of the linearization of the nonlinear equality constraints
    along `step`.
)rM   rl   r%   rt   r   s   &&r.   sqp_ceqTrustRegion.sqp_ceq  r   r1   Nc                ^   Ve	   Ve   Vf   V P                  WP                  4      w  r#pTpV P                  R8  dp   V P                   P                  WVR7      p\        P
                  ! V4      '       d7   WPP                  \        P                  P                  V4      ,          ,          pV# )a  
Evaluate the merit function at a given point.

Parameters
----------
x : `numpy.ndarray`, shape (n,)
    Point at which the merit function is evaluated.
fun_val : float, optional
    Value of the objective function at `x`. If not provided, the
    objective function is evaluated at `x`.
cub_val : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
    Values of the nonlinear inequality constraints. If not provided,
    the nonlinear inequality constraints are evaluated at `x`.
ceq_val : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
    Values of the nonlinear equality constraints. If not provided,
    the nonlinear equality constraints are evaluated at `x`.

Returns
-------
float
    Value of the merit function at `x`.
r   )r\   ra   )r   r   r   	violationr   count_nonzerolinalgnorm)r*   rn   rW   r\   ra   m_valc_vals   &&&&&  r.   meritTrustRegion.merit  s    . ?go(,LL(A%Gg==3HH&&q7&KE&&)>>>r1   c                >   \         P                  ! V P                  P                  P                  .V P
                  P                  V4      ..4      p\         P                  ! V P                  P                  P                  V P                  P                  P                  V,          ,
          V P
                  P                  V4      ) .4      p\         P                  ! V P                  P                  P                  .V P
                  P                  V4      ..4      p\         P                  ! V P                  P                  P                  V P                  P                  P                  V,          ,
          V P
                  P                  V4      ) .4      pW#WE3# )a  
Get the linearizations of the constraints at a given point.

Parameters
----------
x : `numpy.ndarray`, shape (n,)
    Point at which the linearizations of the constraints are evaluated.

Returns
-------
`numpy.ndarray`, shape (m_linear_ub + m_nonlinear_ub, n)
    Left-hand side matrix of the linearized inequality constraints.
`numpy.ndarray`, shape (m_linear_ub + m_nonlinear_ub,)
    Right-hand side vector of the linearized inequality constraints.
`numpy.ndarray`, shape (m_linear_eq + m_nonlinear_eq, n)
    Left-hand side matrix of the linearized equality constraints.
`numpy.ndarray`, shape (m_linear_eq + m_nonlinear_eq,)
    Right-hand side vector of the linearized equality constraints.
)r   blockr   rf   rg   rM   rs   rh   rk   ri   rt   rj   rl   )r*   rn   aubbubaeqbeqs   &&    r.   get_constraint_linearizations)TrustRegion.get_constraint_linearizations  s-   ( hh%%&%%a()
 hh$$txx';';a'??##
 hh%%&%%a()
 hh$$txx';';a'??##
 !!r1   c                   V P                  V P                  4      w  r#rEV P                  P                  P                  V P                  ,
          pV P                  P                  P
                  V P                  ,
          pV P                  \        P                  ,          V P                  ,          p\        VVVVVVVV\        P                  ,          3/ V P                  B p	V\        P                  ,          '       d   \        Wg4      p
\        P                  ! W,           V8  4      '       g&   \        P                  ! WyV
,
          8  4      '       d   \         P"                  ! R\$        ^4       \        P&                  P)                  V	4      RV,          8  d   \         P"                  ! R\$        ^4       \        P*                  ! V P                  R,          W,          ,
          4      pWi,          pWy,          p\        P,                  ! W2V	,          ,
          R4      pV P.                  P1                  V P                  4      V P3                  V	4      ,           pV P                  P4                  R	9   d<   \7        VV P2                  VVVV\        P                  ,          3/ V P                  B pM/\9        VV P2                  VVVVVVVR,          3	/ V P                  B pV\        P                  ,          '       d   \        Wg4      p
\        P                  ! W,           V8  4      '       g&   \        P                  ! W|V
,
          8  4      '       d   \         P"                  ! R\$        ^4       \        P&                  P)                  W,           4      R\        P*                  ! R4      ,          V P                  ,          8  d   \         P"                  ! R\$        ^4       W3# )
a  
Get the trust-region step.

The trust-region step is computed by solving the derivative-free
trust-region SQP subproblem using a Byrd-Omojokun composite-step
approach. For more details, see Section 5.2.3 of [1]_.

Parameters
----------
options : dict
    Options of the solver.

Returns
-------
`numpy.ndarray`, shape (n,)
    Normal step.
`numpy.ndarray`, shape (n,)
    Tangential step.

References
----------
.. [1] T. M. Ragonneau. *Model-Based Derivative-Free Optimization
   Methods and Software*. PhD thesis, Department of Applied
   Mathematics, The Hong Kong Polytechnic University, Hong Kong, China,
   2022. URL: https://theses.lib.polyu.edu.hk/handle/200/12294.
z6the normal step does not respect the bound constraint.皙?z=the normal step does not respect the trust-region constraint.       @r   debugz;The tangential step does not respect the bound constraints.z<The trial step does not respect the trust-region constraint.)unconstrainedzbound-constrained)r   r%   r   boundsxlxur   r   BYRD_OMOJOKUN_FACTORrA   r
   r   DEBUGr   r   anywarningswarnRuntimeWarningr   r   sqrtmaximumrM   rr   r   typer   r   )r*   r,   r   r   r   r   r   r   rA   normal_steptolg_besttangential_steps   &&           r.   get_trust_region_step!TrustRegion.get_trust_region_step  s   8 "??L#XX__$++-XX__$++- !?!?@4;;N*GMM"

 oo

 7==!! (C{(2-..vvb#4455L"
 yy~~k*S6\9""	 c)K,EEF

jj[00#6%%dkk2T5M5M6
 
 88==BB6((& //O C((  //O 7==!! (Cvvo+b011RVVs**6 6 #"	 		{<=$t{{23 ""	 ++r1   c                4  a a V\         P                  ,          '       d   VS P                  8w  g   Q R4       h\        P                  ! \        P
                  ! ^S P                  P                  V4      4      p\        S P                  P                  VV\         P                  ,          4      oSP                  S P                  S P                  P                  4      pS P                  P                  P                  S P                  ,
          pS P                  P                  P                  S P                  ,
          p\!        RVVV 3R lVVS P"                  V\         P                  ,          4      pS P                  P%                  S P                  V,           V4      pS P                  P                  P&                  S P                  P                  P&                  RS P                  \        P(                  3,          ,
          p	V	RS P                  ^ .3,          V	R^ S P                  .3&   \+        RVVV 3R lV	R,          VVS P"                  V\         P                  ,          4      p
S P                  P%                  S P                  V
,           V4      p\-        V4      \-        V4      8  d   T
pTpS P                  P.                  R9   Ed   S P1                  S P                  4      w  rr\3        WV4      p\3        V4      pVV) 8*  pVV8  pVV8  p\5        VVVVV4      w  ppVRVR13,          VRVR13,          P6                  V,          ,          p\        P8                  P;                  V4      p^ Tu;8  d   S P                  P<                  8  Ed   M EMV\>        S P"                  ,          8  Ed   S P"                  V,          V,          p
SPA                  V
S P                  P                  4      R8  d   V
) p
\        PB                  ! WZ,
          W,
          .4      pW,          V,
          pW,          V,
          p\E        R VV\        P,                  ! V4      3 4       4      p\        PD                  ! \        P,                  ! V
V( ,          4      RR7      p\        PD                  ! \        P,                  ! V
V( ,          4      VR7      p\        PD                  ! \        P,                  ! VV( R3,          V
,          4      VR7      p\G        R	V,          R
\        P8                  P;                  V
4      ,          4      pVV8:  de   S P                  P%                  S P                  V
,           V4      p\-        V4      R\-        V4      ,          8  d   \        PH                  ! WV4      pV\         P                  ,          '       d   \3        WV4      p\        PJ                  ! VV,           V8  4      '       g&   \        PJ                  ! WgV,
          8  4      '       d   \L        PN                  ! R\P        ^4       \        P8                  P;                  V4      RS P"                  ,          8  d   \L        PN                  ! R\P        ^4       V# )a  
Get the geometry-improving step.

Three different geometry-improving steps are computed and the best one
is returned. For more details, see Section 5.2.7 of [1]_.

Parameters
----------
k_new : int
    Index of the interpolation point to be modified.
options : dict
    Options of the solver.

Returns
-------
`numpy.ndarray`, shape (n,)
    Geometry-improving step.

Raises
------
`numpy.linalg.LinAlgError`
    If the computation of a determinant fails.

References
----------
.. [1] T. M. Ragonneau. *Model-Based Derivative-Free Optimization
   Methods and Software*. PhD thesis, Department of Applied
   Mathematics, The Hong Kong Polytechnic University, Hong Kong, China,
   2022. URL: https://theses.lib.polyu.edu.hk/handle/200/12294.
z8The index `k_new` must be different from the best index.r   c                 P   < SP                  V SP                  P                  4      # NcurvrM   rS   r   lagr*   s   &r.   <lambda>/TrustRegion.get_geometry_step.<locals>.<lambda>      chhq$++";";<r1   r[   c                 P   < SP                  V SP                  P                  4      # r   r   r   s   &r.   r   r     r   r1   Nc              3   R   "   T F  p\         P                  ! VR R7      x  K  	  R# 5i)r   initialN)r   max).0arrays   & r.   	<genexpr>0TrustRegion.get_geometry_step.<locals>.<genexpr>  s%       !8 FF5#..!8s   %'r         $@g{Gz?g?z9The geometry step does not respect the bound constraints.r   z?The geometry step does not respect the trust-region constraint.)r[   :   NN)zlinearly constrainedznonlinearly constrained))r   r   rP   r   squeezeeyerM   nptr   rS   gradr%   r   r   r   r   r   rA   determinantsxptnewaxisr	   absr   r   r   r   Tr   r   r3   TINYr   r   r   minclipr   r   r   r   )r*   k_newr,   	coord_vecg_lagr   r   r   sigmar   step_alt	sigma_altr   r   r   r   tol_bdtol_ubfree_xlfree_xufree_ubn_actq
g_lag_projnorm_g_lag_projcbdrk   rl   	maxcv_valr   r   s   f&&                           @r.   get_geometry_stepTrustRegion.get_geometry_step  s   > 7==!!(JIJ( JJrvva%@A	KK%%GMM"

 dkk&?&?@ XX__$++-XX__$++-<KKGMM"
 ((t);UC KK%%))kk''++At

,JKL 	 (+1t.B+B'CA4??##$"<JKKGMM"	
 KK,,T[[8-CUK	y>CJ&DE 88== 
 

 224;;? Cc#B+F#C(FVGmGFlGVmG 3HE1 1ef91ef9%)?@J iinnZ8O5%488::%%/D4;;<N*N KK/9ZG88Hdkk&?&?@3F (yH hhx}=>ns*ns*  "%sBFF3K!8  	 ffRVVHgX$67EffRVVHgX$67EffRVVC!$4x$?@#N$*dRYY^^H-E&EF# $ 8 8h.!I 9~s5z)99!wwxR87==!! (CvvdSj2o&&"&&Sj*A*A#"	 yy~~d#cDKK&77/"	 r1   c                R   V P                  V P                  4      w  r4rVV P                  P                  P                  V P                  ,
          pV P                  P                  P
                  V P                  ,
          p\        P                  P                  V4      p	\        VVVVVVV	V\        P                  ,          3/ V P                  B p
V\        P                  ,          '       d   \        Wx4      p\        P                  ! W,           V8  4      '       g&   \        P                  ! WV,
          8  4      '       d   \        P                   ! R\"        ^4       \        P                  P                  V
4      RV	,          8  d   \        P                   ! R\"        ^4       V
# )z
Get the second-order correction step.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Trust-region step.
options : dict
    Options of the solver.

Returns
-------
`numpy.ndarray`, shape (n,)
    Second-order correction step.
zHThe second-order correction step does not respect the bound constraints.r   zNThe second-order correction step does not respect the trust-region constraint.)r   r%   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   )r*   r   r,   r   r   r   r   r   r   rA   soc_stepr   s   &&&         r.    get_second_order_correction_step,TrustRegion.get_second_order_correction_step  s6   " "??L#XX__$++-XX__$++-%'GMM"

 oo

 7==!! (Cvvhnr)**bffRS.5H.I.I5"	 yy~~h'#,6;"	 r1   c                   V P                  V P                  V P                  V P                  V P                  4      pV P                  V P                  V,           W#V4      pV P                  V P                  RV P
                  P                  V P                  4      V P
                  P                  V P                  4      4      pV P                  V P                  V,           V P                  V4      V P                  V4      V P                  V4      4      p\        Wx,
          4      \        \        WV,
          4      ,          8  d   WV,
          \        Wx,
          4      ,          # R# )a  
Get the reduction ratio.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Trust-region step.
fun_val : float
    Objective function value at the trial point.
cub_val : `numpy.ndarray`, shape (m_nonlinear_ub,)
    Nonlinear inequality constraint values at the trial point.
ceq_val : `numpy.ndarray`, shape (m_nonlinear_eq,)
    Nonlinear equality constraint values at the trial point.

Returns
-------
float
    Reduction ratio.
r         )r   r%   rX   r]   rb   rM   rk   rl   r   r   r   r   r   )	r*   r   rW   r\   ra   	merit_old	merit_newmerit_model_oldmerit_model_news	   &&&&&    r.   get_reduction_ratioTrustRegion.get_reduction_ratioI  s   ( JJKKMMMMMM	
	 JJt{{T17WM	**KKKKOODKK(KKOODKK(	
 **KK$LLLLLL	
 01D3!<
 5
 
 )S1.   Kr1   c                6   V P                  V P                  4      w  r#rE\        \        P                  P                  \        P                  ! \        P                  ! RV) 4      V.4      4      \        P                  P                  \        P                  ! \        P                  ! RW!,          V,
          4      WA,          V,
          .4      4      ,
          R4      pV P                  V4      p\        P                  P                  \        P                  ! V P                  V P                  V P                  V P                  .4      4      p\        V4      \        \        V4      ,          8  d   \        WV,          4      pV P                  p	V P                   V P"                  \$        P&                  ,          V,          8:  dH   \        V P"                  \$        P(                  ,          V,          R4      V n        V P+                  4        WP                  8H  # )zr
Increase the penalty parameter.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Trust-region step.
r         ?)r   r%   r   r   r   r   r   r   r   r   r   r!   r#   r   r   rP   r   r   r   PENALTY_INCREASE_THRESHOLDPENALTY_INCREASE_FACTORr   )
r*   r   r   r   r   r   	viol_diffsqp_val	thresholdbest_index_saves
   &&        r.   increase_penaltyTrustRegion.increase_penaltyy  s    "??L#IINN

3- iinn

3
S(89
S(  #
	& ,,t$IINNHH&&&&))))		
	 y>D3w<//I':;I//MMyCCD  	 A ABYNDM !//11r1   c                x    \        V P                  V P                  4       4      V n        V P                  4        R# )z!
Decrease the penalty parameter.
N)r   r   _get_low_penaltyr   r4   s   &r.   decrease_penaltyTrustRegion.decrease_penalty  s+     DMM4+@+@+BCr1   c           	        V P                   pV P                  V P                  V P                  P                  V,          V P                  P
                  VR3,          V P                  P                  VR3,          4      pV P                  P                  V P                  V P                  P
                  VR3,          V P                  P                  VR3,          4      pR\        ,          \        V P                  P                  V P                  P                  4      ,          \        \        V4      R4      ,          p\        V P                  P                  4       EF   pWPP                   8w  g   K  V P                  P                  P!                  V4      pV P                  VV P                  P                  V,          V P                  P
                  VR3,          V P                  P                  VR3,          4      pV P                  P                  VV P                  P
                  VR3,          V P                  P                  VR3,          4      pWr8  g   WrV,           8  g   EK  W8  g   EK  TpTpTpEK#  	  Wn        R# )z"
Set the index of the best point.
r[   r   r  N)rP   r   r%   rM   rW   r\   ra   r   maxcvEPSr   r3   r   r   rangerS   rT   r   )	r*   rP   m_bestr_bestr   kx_valr   r_vals	   &        r.   r   TrustRegion.set_best_index  s    __
KKKK
+KK
A.KK
A.	
 KKKK
A.KK
A.
 $++--12 #f+s#$ 	 t{{'AOO#1177:

KK''*KK''1-KK''1-	 KK''1-KK''1-
 >esl&:u~!"J"F"F# ($ &r1   c                   \         P                  ! V P                  P                  P                  V P                  P                  P                  RV P
                  \         P                  3,          ,
          R,          ^ R7      pVf   RpTpMV P                  P                  V4      p\         P                  ! RV\        V P                  \        P                  ,          V P                  ,          V P                  4      R,          ,          4      R,          pRW@P
                  &   \         P                  ! V\         P                   ! V4      ,          4      pV\         P"                  ! W%,          4      3# )aO  
Get the index of the interpolation point to remove.

If `x_new` is not provided, the index returned should be used during
the geometry-improvement phase. Otherwise, the index returned is the
best index for included `x_new` in the interpolation set.

Parameters
----------
x_new : `numpy.ndarray`, shape (n,), optional
    New point to be included in the interpolation set.

Returns
-------
int
    Index of the interpolation point to remove.
float
    Distance between `x_best` and the removed point.

Raises
------
`numpy.linalg.LinAlgError`
    If the computation of a determinant fails.
r[   r   axisr  g      @r   )r   sumrM   rS   r   rP   r   r   r   r   r   r   LOW_RADIUS_FACTORrA   r(   argmaxr   r   )r*   x_newdist_sqr   weightsk_maxs   &&    r.   get_index_to_removeTrustRegion.get_index_to_remove  s"   2 &&))--++++//4??BJJ0NOP 	
 
 =EGKK,,U3E

	(C(CD++&
 	 
  (,GOO$		'BFF5M12bgggn---r1   c                   \         P                  P                  V4      pW P                  \        P
                  ,          8:  d;   V ;P                  V P                  \        P                  ,          ,          un        R# W P                  \        P                  ,          8:  dD   \        V P                  \        P                  ,          V P                  ,          V4      V n        R# \        V P                  \        P                  ,          V P                  ,          \        V P                  \        P                  ,          V P                  ,          V P                  \        P                  ,          V,          4      4      V n        R# )z
Update the trust-region radius.

Parameters
----------
step : `numpy.ndarray`, shape (n,)
    Trust-region step.
ratio : float
    Reduction ratio.
N)r   r   r   r   r   	LOW_RATIOrA   DECREASE_RADIUS_FACTOR
HIGH_RATIOr   r   INCREASE_RADIUS_FACTORINCREASE_RADIUS_THRESHOLD)r*   r   ratios_norms   &&& r.   update_radiusTrustRegion.update_radius  s     %OOI$7$788KK4??9+K+KLLKooi&:&:;;	 @ @A++DK 	 @ @A++OOI$D$DEkk"OOI$G$GH	DKr1   c                   V P                   \        P                  ,          V\        P                  ,          ,          V P
                  8  d:   V ;P
                  V P                   \        P                  ,          ,          un        MV P                   \        P                  ,          V\        P                  ,          ,          V P
                  8  dC   \        P                  ! V P
                  V\        P                  ,          ,          4      V n        MV\        P                  ,          V n        \        V P                   \        P                  ,          V P                  ,          V P
                  4      V n        R# )zx
Enhance the resolution of the trust-region framework.

Parameters
----------
options : dict
    Options of the solver.
N)r   r   LARGE_RESOLUTION_THRESHOLDr   RHOENDr(   DECREASE_RESOLUTION_FACTORMODERATE_RESOLUTION_THRESHOLDr   r   r   r&  r)   r*   r,   s   &&r.   enhance_resolutionTrustRegion.enhance_resolution9  s     OOI@@Agnn%&oo OOt44  O OOICCDgnn%&oo !ggdoo(/(?'@ ADO &gnn5DO OOI<<=LOO
r1   c                z    V P                   P                  \        P                  ! V P                  4      V4       R# )zd
Shift the base point to `x_best`.

Parameters
----------
options : dict
    Options of the solver.
N)rM   shift_x_baser   copyr%   r3  s   &&r.   r7  TrustRegion.shift_x_baseZ  s%     	  !5w?r1   c           	     h   V P                   P                  P                  V,          V P                   P                  P                  8  pV P                  R8  pV P                   P
                  P                  V8  pV P                   P
                  P                  V8*  p\        P                  ! V4      p\        P                  ! V4      p\        P                  ! V4      p\        P                  ! V4      p	Wg,           V P                  ,           V P                  ,           ^ 8  Ed   \        P                  ! V P                   P                  4      p
\        P                  WR3,          ) WR3,          V P                   P                  P                  VR3,          V P                  P!                  W4      V P                   P                  P"                  V P                  P%                  V4      3,          pV P                  P'                  V4      p\        P(                  ! VP*                  ^ ,          \        P,                  ) 4      pRVRW,           V,           V,           % \/        VP0                  V) V\        P,                  3RR7      pVP2                  W,           W,           V,            V P4                  V&   RV P4                  V( &   VP2                  VV	,           V,           VV	,           V,           V,            V P6                  V&   RV P6                  V( &   VP2                  VV	,           V,           V,           VV	,           V,           V,           V P                  ,            V P8                  R&   VP2                  W,           V,           V,           V P                  ,           R V P:                  R&   R# R# )a	  
Set the Lagrange multipliers.

This method computes and set the Lagrange multipliers of the linear and
nonlinear constraints to be the QP multipliers.

Parameters
----------
x : `numpy.ndarray`, shape (n,)
    Point at which the Lagrange multipliers are computed.
r   r[   Nbvls)r   method)r   rf   rg   rh   r]   r   r   r   r   r   r   r"   r   r3   r_rM   rs   ri   rt   rr   fullshapeinfr   r   rn   r   r!   r   r#   )r*   rn   incl_linear_ubincl_nonlinear_ubincl_xlincl_xur   r    m_xlm_xuidentityc_jacr   xl_lmress   &&             r.   r$   TrustRegion.set_multiplierse  s    --1TXX__5I5II MMS0((//$$)((//$$)&&~6))*;<(( (4+;+;;%%&()* vvdhhjj)HEE1*%%!$$$^Q%67$$Q:$$$$Q')E [[))!,FGGEKKNRVVG4EBEE>DK+->?rvv	C 25DK+52D~. 36D/7:uu" !!8D!!"34 9<D!!#4"45$'EE !! "&"" !"! ""	"#		%Dq! (+uuk)N:T=M=MMN(D!!!$a*r1   c                   \         P                  V P                  P                  P                  \         P
                  R 3,          V P                  P                  P                  P                  ,           V P                  P                  P                  P                  ,          V P                  P                  P                  \         P
                  R 3,          ,
          V P                  P                  3,          pV P                  P                  P                  \         P
                  R 3,          V P                  P                  P                  P                  ,           V P                  P                  P                  P                  ,          V P                  P                  P                  \         P
                  R 3,          ,
          p\         P                  ! VV) V P                  P                   V P                  P                   ) .4      p\         P                  ! W.4      p\         P"                  ! V^ R7      p\         P$                  ! V^ R7      pVV P&                  \(        P*                  ,          V,          8  p\         P,                  ! V4      '       d   \         P"                  ! V P                  P.                  4      p\         P$                  ! V P                  P.                  4      p\         P0                  ! RWF,          4      p	\         P2                  ! WV,          V	,
          4      p
V
\4        W,
          ,          8  d   W,
          V
,          pV# \         P6                  p V# RpV# )r[   r  r   )r   c_rM   rS   x_baser   r   r   r   rf   rg   rh   r\   ri   rj   r   ra   nanminnanmaxr   r   THRESHOLD_RATIO_CONSTRAINTSr   rW   minimumr   r   r@  )r*   r_val_ubr_val_eqr  c_minc_maxindicesf_minf_max	c_min_negc_diffr   s   &           r.   r  TrustRegion._get_low_penalty  sa   55))00Q?++++//112 hhoo""$$	%
 hhoo""2::q=12 KK!
 KK%%,,RZZ];kk''++--.HHOO  ""# &*XX__%9%9"**a-%HI 88	##$$$	
 (-.		%a(		%a(ooiCCDuLM 	 66'??IIdkk112EIIdkk112E

37IVVENY67F.. =F2
  &&  Gr1   )r   r   r   r   r#   r!   r   r   r   r)   r'   rA   r(   )NNNr   )/__name__
__module____qualname____firstlineno____doc__r/   propertyr3   r   r   r    r"   rA   setterr(   r   rM   rP   r%   rX   r]   rb   ro   ru   r|   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r"  r,  r4  r7  r$   r  __static_attributes____classdictcell__)__classdict__s   @r.   r   r      s    .'` 	 	 	$ 	$ 	$ 	$ 	' 	' 	' 	' 	 	 ]]+ +"     	& 	& 	 	 	 	 	  	  @ @ 	4 	4 	7 	7 	7 	7
0
, 
.
*
(
*
*@,"\r,hUn0d.`62p(&T5.n@
B	@IV( (r1   r   )r   numpyr   scipy.optimizer   rM   r   r   settingsr   r   
subsolversr   r	   r
   r   r   subsolvers.optimr   utilsr   finfofloattinyr   epsr  r    r1   r.   <module>rr     sZ      % % (  : ! 
xxhhuoA Ar1   