+
    /iȱ                         ^ RI t ^ RIt^ RIHt ^RIHt ]P                  ! ]4      P                  t
]P                  ! ]4      P                  tR tR tR tR tR tR	 tR
 tR tR# )    N)qr)get_arrays_tolc                   V'       Ed|   \        V \        P                  4      '       d   V P                  ^8X  g   Q h\        P
                  ! V4      P                  V 4      '       g   Q h\        V\        P                  4      '       d   VP                  V P                  8X  g   Q h\        V\        P                  4      '       d   VP                  V P                  8X  g   Q h\        V\        4      '       g   Q h\        V\        4      '       g   Q h\        W#4      p\        P                  ! W'8*  4      '       g   Q h\        P                  ! W7) 8  4      '       g   Q h\        P                  ! V4      '       d   VR8  g   Q h\        P                  ! VR4      p\        P                  ! VR4      pV P                  p\        P                   ! V 4      p \        P                   ! V 4      p	VR8  V R8  ,          VR8  V R8  ,          ,          p
\        P"                  ! V 4      p\        P"                  ! V4      pW
,          ) W&   ^ pRpRpV\        P$                  ! V
4      8  Ed   W,          pVR
\&        ,          V,          \)        R\        P*                  P-                  V 4      4      ,          8  d   EM \/        WV4      pT) T,          RT,          8:  d   EMT! T4      pTT,          pT\2        \5        T4      ,          8  d   \)        T) T,          R4      pM\        P6                  p\9        TT4      pT) TRT,          T,          ,           ,          RT,          8:  d   EMT\        P6                  ) 8  T\2        ) \        P4                  ! Y+,
          4      ,          8  ,          pT\        P6                  8  T\2        \        P4                  ! Y;,
          4      ,          8  ,          p\        P:                  ! T\        P6                  4      p\        P:                  ! T\        P6                  4      p\        P                  ! TT,          TT,          ,
          TT,          ,          R4      TT&   \        P                  ! TT,          TT,          ,
          TT,          ,          R4      TT&   \        P8                  ! T4      p\        P8                  ! T4      p\9        TT4      p\9        TT4      pTR8  dv   \        P<                  ! Y,          TY,          ,          ,           Y*,          Y:,          4      Y&   T TT,          ,          p TTTRT,          T,          ,           ,          ,          pT\9        TT4      8  dM   Y
,          TT
,          ,          T,          pTY,          ,          Y
,          ,
          Y&   RY( &   T^,          pEK  TT8  dg   TT8:  d$   \        P>                  ! T4      pTT,          TT&   M"\        P>                  ! T4      pTT,          TT&   RT
T&   Y
,          ) Y&   RY( &   ^ pEK  TT8:  d   \A        T4      pTT,          TT&   RT
T&   TT8:  d   \A        T4      pTT,          TT&   RT
T&   Rp VPC                  RR4      '       Ed   V'       Ed   \        P                   ! V4      pV	V,          RV,          V! V4      ,          ,           p \        P$                  ! V
4      ^ 8  EdO   W,          W,          ,          p!W
,          W
,          ,          p"W
,          W,          ,          p#\        PD                  ! \)        V!V",          V#R,          ,
          R4      4      ) pV#W,          ,          V!W
,          ,          ,
          W&   RW( &   VRV,          8  gF   \        PF                  ! V\2        ) \        P4                  ! W,          4      ,          8  4      '       d   EMZW;;,          V) ,          uu&   \        PH                  ! V4      p$\        PH                  ! V4      p%W,          R,          W,          R,          ,           W*,          R,          ,
          V$V
&   W,          R,          W,          R,          ,           W:,          R,          ,
          V%V
&   \        PD                  ! V$V$R8  ,          4      VV$R8  ,          ,
          V$V$R8  &   \        PD                  ! V%V%R8  ,          4      VV%R8  ,          ,           V%V%R8  &   \        P                  ! W,
          R4      p&\        P                  ! W;,
          R4      p'V$\2        V&,          8  pV%\2        V',          8  p\        PJ                  ! V4      p(\        PJ                  ! V4      p)\        P                  ! V(V,          V&V,          V$V,          ,          4      V(V&   \        P                  ! V)V,          V'V,          V%V,          ,          4      V)V&   \        P8                  ! V(4      p*\        P8                  ! V)4      p+\9        V*V+4      p,V! V4      p-V! V4      pVV-,          p.VV,          pVV,          p/^p0\M        V0^,
          V,,          ^,           4      p0\        PN                  ! V,V0,          V,V04      p1RV1,          RV1R,          ,           ,          p2V2V#V1,          V,
          V1V.,          ,
          V2V1V/,          RVV.,
          ,          ,
          ,          ,           ,          p3\        P                  ! V3R8*  4      '       d   EM\        PP                  ! V34      p4RV1V4,          R,          ,
          RV1V4,          R,          ,           ,          p5V5W,          ,          V2V4,          W,          ,          ,           W&   V V5R,
          V-,          V2V4,          V,          ,           ,          p VV3V4,          ,          pV,R8  d[   V4V0^,
          8X  dM   V*V,8:  d   \A        V(4      pVV,          VV&   RV
V&   V+V,8:  d    \A        V)4      pVV,          VV&   RV
V&   EKf  EKi   W,          RV,          V! V4      ,          ,           V 8  d   TpV'       dn   \        P                  ! W+8*  4      '       g   Q h\        P                  ! W8*  4      '       g   Q h\        P*                  P-                  V4      R	V,          8  g   Q hV#   \0         d     EKv  i ; i)a  
Minimize approximately a quadratic function subject to bound constraints in
a trust region.

This function solves approximately

.. math::

    \min_{s \in \mathbb{R}^n} \quad g^{\mathsf{T}} s + \frac{1}{2}
    s^{\mathsf{T}} H s \quad \text{s.t.} \quad
    \left\{ \begin{array}{l}
        l \le s \le u\\
        \lVert s \rVert \le \Delta,
    \end{array} \right.

using an active-set variation of the truncated conjugate gradient method.

Parameters
----------
grad : `numpy.ndarray`, shape (n,)
    Gradient :math:`g` as shown above.
hess_prod : callable
    Product of the Hessian matrix :math:`H` with any vector.

        ``hess_prod(s) -> `numpy.ndarray`, shape (n,)``

    returns the product :math:`H s`.
xl : `numpy.ndarray`, shape (n,)
    Lower bounds :math:`l` as shown above.
xu : `numpy.ndarray`, shape (n,)
    Upper bounds :math:`u` as shown above.
delta : float
    Trust-region radius :math:`\Delta` as shown above.
debug : bool
    Whether to make debugging tests during the execution.

Returns
-------
`numpy.ndarray`, shape (n,)
    Approximate solution :math:`s`.

Other Parameters
----------------
improve_tcg : bool, optional
    If True, a solution generated by the truncated conjugate gradient
    method that is on the boundary of the trust region is improved by
    moving around the trust-region boundary on the two-dimensional space
    spanned by the solution and the gradient of the quadratic function at
    the solution (default is True).

Notes
-----
This function implements Algorithm 6.2 of [1]_. It is assumed that the
origin is feasible with respect to the bound constraints and that `delta`
is finite and positive.

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.
        F      ?:0yE>      ?Timprove_tcg       @皙?      $:0yE))
isinstancenpndarrayndiminspect	signaturebindshapefloatboolr   allisfiniteminimummaximumsizecopy
zeros_likecount_nonzeroEPSmaxlinalgnorm	_alpha_trZeroDivisionErrorTINYabsinfmin	full_likeclipargmin_argmingetsqrtanyzerosonesintlinspaceargmax)6grad	hess_prodxlxudeltadebugkwargstoln	grad_origfree_bdstepsdkreductboundary_reachedgrad_sdalpha_trhess_sdcurv_sd
alpha_quadalphai_xli_xuall_alpha_xlall_alpha_xualpha_xlalpha_xualpha_bdbetai_new	step_basestep_comparatorstep_sqgrad_sq	grad_steptemp_xltemp_xudist_xldist_xuall_t_xlall_t_xut_xlt_xut_bd	hess_step	curv_stepcurv_step_sd	n_samples	t_samples
sin_values
all_reducti_max	cos_values6   &&&&&&,                                               `/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/_lib/cobyqa/subsolvers/optim.pytangential_byrd_omojokunrn      sd
   @ u$

++		Q>>  +006666"bjj))bhh$**.DDD"bjj))bhh$**.DDD%''''%&&&&R$vvbi    vvbDj!!!!{{5!!eck11	B	B	B	B 			A774=DI STCZ(b3h4#:-FGG ==D	t	B=.BK	AF
bw'
')eckAoC1E(FFF	 51H 9w$-/ B-w,TCL((gX/5JJ Hj)6WsU{W445F bffWtebffRY.?&?!?@RVVTBFF29,=%= =>||D"&&1||D"&&1ZZXT
"bh.
T  ZZXT
"bh.
T 66,'66,'x* E8$3;GG 33DM
 EGO#Dewuw)>>??F3x** MGG$44?D,t}<BKBxLFAX 5 		,/ iU		,/ iU"GEN=.BKBxLA
 5 - iU!&5 - iU!&# zz-&&+;+;GGDM	#i/#	/IE
 3
 
 w'!+ mdm3Gmdm3G5Iwws7W#4y#~#EsKLLG#dm3g6MMBKBxL%&.(BFFD5266"+#666- - KG8#K
 hhqkGhhqkG$r{c'99BK3<NN G $r{c'99BK3<NN G #./"Ws]2CC GcM" #./"Ws]2CC GcM" jjC0GjjC0GTG^+DTG^+DwwqzHwwqzHZZ-HTN  ZZ-HTN 66(#D66(#DtT?D "$ImGy(I7lG'>L
 IY]d2Q67ID9$4dIFIyC)S.,@AJ#I%i'( |+cWy5H.IIKKJ vvjC'(( IIj)Ey/366i&#--I DM)Ju,=,KK M Y_	1Ju4E4OOODj''F
 czey1}44<#H-E"$U)DK%*GEN4<#H-E"$U)DK%*GEN  
  cDj9T?::_LDvvbj!!!!vvdj!!!!yy~~d#cEk111KY ! 		s   9s+ +s;:s;c	                V$   V'       Ed   \        V \        P                  4      '       d   V P                  ^8X  g   Q h\        P
                  ! V4      P                  V 4      '       g   Q h\        V\        P                  4      '       d   VP                  V P                  8X  g   Q h\        V\        P                  4      '       d   VP                  V P                  8X  g   Q h\        V\        P                  4      '       d4   VP                  ^8X  d#   VP                  ^,          V P                  8X  g   Q h\        V\        P                  4      '       d4   VP                  ^8X  d#   VP                  VP                  ^ ,          8X  g   Q h\        V\        P                  4      '       d4   VP                  ^8X  d#   VP                  ^,          V P                  8X  g   Q h\        V\        4      '       g   Q h\        V\        4      '       g   Q h\        W#4      p
\        P                  ! W*8*  4      '       g   Q h\        P                  ! W:) 8  4      '       g   Q h\        P                  ! WZ) 8  4      '       g   Q h\        P                  ! V4      '       d   VR8  g   Q h\        P                  ! VR4      p\        P                  ! VR4      p\        P                  ! VR4      pV P                  p\        P                   ! V 4      p \        P                   ! V 4      pVR8  V R8  ,          pVR8  V R8  ,          pVR8  W@,          R8  ,          p\#        WFWV4      w  pp\        P$                  ! V 4      pVRVR13,          ) VRVR13,          P&                  V ,          ,          p\        P                   ! V4      p^ pRpRpVVV,
          8  Edg   V V,          pVR\(        ,          V,          \+        R\        P,                  P/                  V 4      4      ,          8  d   EM \1        VVV4      pT) T,          RT,          8:  d   EMT! T4      pTT,          pT\4        \7        T4      ,          8  d   \+        T) T,          R4      pM\        P8                  p\;        TT4      pT) TRT,          T,          ,           ,          RT,          8:  d   EMdY\        P8                  ) 8  ,          T\4        ) \        P6                  ! TT,
          4      ,          8  ,          pY\        P8                  8  ,          T\4        \        P6                  ! TT,
          4      ,          8  ,          p\        P<                  ! T\        P8                  4      p \        P<                  ! T\        P8                  4      p!\        P                  ! TT,          TT,          ,
          TT,          ,          R4      T T&   \        P                  ! TT,          TT,          ,
          TT,          ,          R4      T!T&   \        P:                  ! T 4      p"\        P:                  ! T!4      p#\;        T"T#4      p$TT,          p%TT%\4        \        P6                  ! T4      ,          8  ,          p&\        P<                  ! T\        P8                  4      p'TT&,          T%T&,          ,          T'T&&   \        P:                  ! T'\        P8                  R7      p(\;        TT$T(4      pTR8  d   \        P>                  ! TTT,          ,           Y#4      pT TT,          ,          p \        P                  ! RTTT%,          ,
          4      pTTTRT,          T,          ,           ,          ,          pT\;        TT$T(4      8  d]   TRTR13,          TRTR13,          P&                  T ,          ,          p)T)T,          T,          p*T*T,          T),
          pT^,          pEK;  TT8  d   T"T8:  d)   \        P@                  ! T 4      p+TT+,          TT+&   RTT+&   MJT#T8:  d)   \        P@                  ! T!4      p+TT+,          TT+&   RTT+&   M\        P@                  ! T'4      p+RTT+&   \#        TTTTT4      w  ppTRTR13,          ) TRTR13,          P&                  T ,          ,          p^ pEK  T"T8:  d   \C        T 4      p+TT+,          TT+&   RTT+&   T#T8:  d   \C        T!4      p+TT+,          TT+&   RTT+&   T(T8:  d   \C        T'4      p+RTT+&   \#        TTTTT4      w  ppR	p V	PE                  R
R	4      '       Ed   V'       Ed   VV8  Ed   \        P                   ! V4      p,VV8  EdY   VRVR13,          VRVR13,          P&                  V,          ,          p-VRVR13,          VRVR13,          P&                  V ,          ,          p)V-V-,          p.V)V),          p/V)V-,          p0\        PF                  ! \+        V.V/,          V0R,          ,
          R4      4      ) pVRVR13,          VRVR13,          P&                  V0V,          V.V ,          ,
          ,          ,          pVRV,          8  g@   \        PH                  ! V\4        ) \        P6                  ! V4      ,          8  4      '       d   EMVV) ,          p\        PJ                  ! V4      p1\        PJ                  ! V4      p2\        P                  ! VV,
          R4      p3\        P                  ! VV,
          R4      p4VV,          R,          V3V,          V3V,          RV-V,          ,          ,
          ,          ,
          V1V&   VV,          R,          V4V,          V4V,          RV-V,          ,          ,           ,          ,
          V2V&   \        PF                  ! V1V1R8  ,          4      VV1R8  ,          ,
          V1V1R8  &   \        PF                  ! V2V2R8  ,          4      VV2R8  ,          ,           V2V2R8  &   V1\4        V3,          8  pV2\4        V4,          8  p\        PL                  ! V4      p5\        PL                  ! V4      p6\        P                  ! V5V,          V3V,          V1V,          ,          4      V5V&   \        P                  ! V6V,          V4V,          V2V,          ,          4      V6V&   \        P:                  ! V54      p7\        P:                  ! V64      p8\;        V7V84      p9\        P$                  ! V4      p:VV-,          p;VV,          p%V%V,          R,          VV,          VV,          RV;V,          ,          ,           ,          ,
          V:V&   \        PF                  ! V:V:R8  ,          4      V%V:R8  ,          ,           V:V:R8  &   V:\4        V,          8  p&\        PN                  ! V4      p<\        P                  ! V<V&,          VV&,          V:V&,          ,          4      V<V&&   \        P:                  ! V<RR7      p=\;        V9V=4      p>V! V-4      p?V! V4      pV-V?,          p@VV,          pV-V,          pA^pB\Q        VB^,
          V>,          ^,           4      pB\        PR                  ! V>VB,          V>VB4      pCRVC,          RVCR,          ,           ,          pDVDV0VC,          V,
          VDRVCR,          ,          V@,          RVC,          VA,          ,
          RV,          ,           ,          ,
          ,          pE\        P                  ! VER8*  4      '       d   EM\        PT                  ! XE4      pFRXCVF,          R,          ,
          RVCVF,          R,          ,           ,          pG\        P>                  ! VVGR,
          V-,          ,           XDVF,          V,          ,           VV4      pV VGR,
          V?,          VDVF,          V,          ,           ,          p \        P                  ! RVVGR,
          V;,          ,
          VDVF,          V%,          ,
          4      pVVEVF,          ,          pV>R8  d   XFXB^,
          8X  ds   V7V>8:  d   \C        V54      p+VV+,          VV+&   RVV+&   V8V>8:  d   \C        V64      p+VV+,          VV+&   RVV+&   V=V>8:  d   \C        V<4      p+RVV+&   \#        VVVVV4      w  ppEK_   VV,          RV,          V! V4      ,          ,           VV,,          RV,,          V! V,4      ,          ,           8  d   T,pV'       d   \        W#4      p
\        P                  ! VV8*  4      '       g   Q h\        P                  ! VV8*  4      '       g   Q h\        P                  ! VV,          WZ,           8*  4      '       g   Q h\        P                  ! \        P6                  ! VV,          4      V
8*  4      '       g   Q h\        P,                  P/                  V4      RV,          8  g   Q hV#   \2         d     EK  i ; i)az	  
Minimize approximately a quadratic function subject to bound and linear
constraints in a trust region.

This function solves approximately

.. math::

    \min_{s \in \mathbb{R}^n} \quad g^{\mathsf{T}} s + \frac{1}{2}
    s^{\mathsf{T}} H s \quad \text{s.t.} \quad
    \left\{ \begin{array}{l}
        l \le s \le u,\\
        A_{\scriptscriptstyle I} s \le b_{\scriptscriptstyle I},\\
        A_{\scriptscriptstyle E} s = 0,\\
        \lVert s \rVert \le \Delta,
    \end{array} \right.

using an active-set variation of the truncated conjugate gradient method.

Parameters
----------
grad : `numpy.ndarray`, shape (n,)
    Gradient :math:`g` as shown above.
hess_prod : callable
    Product of the Hessian matrix :math:`H` with any vector.

        ``hess_prod(s) -> `numpy.ndarray`, shape (n,)``

    returns the product :math:`H s`.
xl : `numpy.ndarray`, shape (n,)
    Lower bounds :math:`l` as shown above.
xu : `numpy.ndarray`, shape (n,)
    Upper bounds :math:`u` as shown above.
aub : `numpy.ndarray`, shape (m_linear_ub, n)
    Coefficient matrix :math:`A_{\scriptscriptstyle I}` as shown above.
bub : `numpy.ndarray`, shape (m_linear_ub,)
    Right-hand side :math:`b_{\scriptscriptstyle I}` as shown above.
aeq : `numpy.ndarray`, shape (m_linear_eq, n)
    Coefficient matrix :math:`A_{\scriptscriptstyle E}` as shown above.
delta : float
    Trust-region radius :math:`\Delta` as shown above.
debug : bool
    Whether to make debugging tests during the execution.

Returns
-------
`numpy.ndarray`, shape (n,)
    Approximate solution :math:`s`.

Other Parameters
----------------
improve_tcg : bool, optional
    If True, a solution generated by the truncated conjugate gradient
    method that is on the boundary of the trust region is improved by
    moving around the trust-region boundary on the two-dimensional space
    spanned by the solution and the gradient of the quadratic function at
    the solution (default is True).

Notes
-----
This function implements Algorithm 6.3 of [1]_. It is assumed that the
origin is feasible with respect to the bound and linear constraints, and
that `delta` is finite and positive.

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.
r   NNNNFr   r   r	   initialTr
   r   r   r   r   )+r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   qr_tangential_byrd_omojokunr   Tr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   	ones_liker4   r5   r6   )Hr7   r8   r9   r:   aubbubaeqr;   r<   r=   r>   r?   r@   free_xlfree_xufree_ubn_actqrB   rC   residrD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   aub_sdi_uball_alpha_ubalpha_ub	grad_projrT   rU   rV   	step_projrX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   temp_ubaub_stepall_t_ubt_ubt_minrd   re   rf   rg   rh   ri   rj   rk   rl   sH   &&&&&&&&&,                                                              rm   $constrained_tangential_byrd_omojokunr   C  s   f u$

++		Q>>  +006666"bjj))bhh$**.DDD"bjj))bhh$**.DDDsBJJ''A		!		)	
*
 sBJJ''ACIIaL(	
)
 sBJJ''A		!		)	
* %''''%&&&&R$vvbi    vvbDj!!!!vvcTk""""{{5!!eck11	B	B	B	B
**S#
C 			A774=DI CxD3J'GCxD3J'GSySZ#-.G*3WwOHE1 ==D
AuvI,!AuvI,..4/	0BGGCLE	AF
a%i-)eckAoC1E(FFF	 r51H 9w$-/ B-w,TCL((gX/5JJ Hj)6WsU{W445F w,'2rDy8I0I+IJrvv+&"tbffR$Y6G/G*GH||D"&&1||D"&&1ZZXT
"bh.
T  ZZXT
"bh.
T 66,'66,'x* r&4"&&-#778||C0"4[6$<7T66,7 E8X.3;774%"*,b5DEGO#DJJsEEFN$:;Eewuw)>>??F3x844 !UV)!UV)(=>I'72DY&BFAX 5 		,/ iU!&U"		,/ iU!&		,/!&2HE1 AuvI,!AuvI,..4"78BA
 5 - iU!&5 - iU!&5 -!&2HE1  $ zz-&&+;+;	GGDM	ai !UV)!UV)(=>I!UV)!UV)(=>I)+G)+G!I-Iwws7W#4y#~#EsKLLG1ef9!UV))d"2Wt^"CDB %&.(BFFD5266":--- - 7(NB hhqkGhhqkGjjC0GjjdC0G!'{c1GG4D 37);#;;5  GG  "'{c1GG4D 37);#;;5  GG #./"Ws]2CC GcM" #./"Ws]2CC GcM" TG^+DTG^+DwwqzHwwqzHZZ-HTN  ZZ-HTN 66(#D66(#DtT?D mmE*GYH2XF%g#5ggx'8!889  GG #./&32GG GcM" TE\)D||E*HZZdgdm+HTN 66(C0DdOE "),ImG!I-I7lG$w.L
 IY]e3a78IEI$5uiHIyC)S.,@AJ#I%)S.(94Io45Gm$	J vvjC'(( IIj)Ey/366i&#--I 77	C944z%7H27MMD
 Y_	1Ju4E4OOODJJs?h./U#f,-E j''F
 s{u	A55=#H-E"$U)DK%*GEN5=#H-E"$U)DK%*GEN5=#H-E%*GEN6q  tcDj9,
 
 
	!C)Oi	6J$JJK DR$vvbDj!!!!vvdbj!!!!vvcDjCI-....vvbffS4Z(C/0000yy~~d#cEk111Ke ! 		s   *AH HAH(H'AH(c           	     %   V'       Ede   \        V \        P                  4      '       d   V P                  ^8X  g   Q h\        V\        P                  4      '       d4   VP                  ^8X  d#   VP                  V P
                  ^ ,          8X  g   Q h\        V\        P                  4      '       d;   VP                  ^8X  d*   VP
                  ^,          V P
                  ^,          8X  g   Q h\        V\        P                  4      '       d4   VP                  ^8X  d#   VP                  VP
                  ^ ,          8X  g   Q h\        V\        P                  4      '       d$   VP
                  V P
                  ^,          38X  g   Q h\        V\        P                  4      '       d$   VP
                  V P
                  ^,          38X  g   Q h\        V\        4      '       g   Q h\        V\        4      '       g   Q h\        WE4      p	\        P                  ! WI8*  4      '       g   Q h\        P                  ! WY) 8  4      '       g   Q h\        P                  ! V4      '       d   VR8  g   Q h\        P                  ! VR4      p\        P                  ! VR4      pV P
                  w  r\        P                  VP                  V) ,          \        P                  ! RV) 4      3,          pVR8  VRV R8  ,          pVR8  VRV R8  ,          pVR8  pVR8  WRV ,          WR ,
          R8  ,          p\        V VVVV4      w  pp\        P                   ! W3,          WR WR ,          ,           4      p\        P"                  ! V4      pVRVR13,          ) VRVR13,          P                  V,          ,          pWVR ,           p^ pRpRpVW,           V,
          8  Ed|   VV,          pVR\$        ,          V,          \'        R\        P(                  P+                  V4      4      ,          8  d   EM) \-        VVRV V4      p \3        V\-        WR VVR V4      4      pV) V,          RV,          8:  d   EM\        P                  VP                  VVRV ,          ,          VVR 3,          pVV,          pV\4        \7        V4      ,          8  d   \'        V) V,          R4      pM\        P0                  p\3        VV4      pV) VRV,          V,          ,           ,          RV,          8:  d   EM*W\        P0                  ) 8  ,          VRV \4        ) \        P6                  ! VV,
          4      ,          8  ,          p W\        P0                  8  ,          VRV \4        \        P6                  ! VV,
          4      ,          8  ,          p!VVVR \4        ) \        P6                  ! WR 4      ,          8  ,          p"\        P8                  ! V\        P0                  4      p#\        P8                  ! V\        P0                  4      p$\        P8                  ! V\        P0                  4      p%\        P                  ! VV ,          VV ,          ,
          VRV V ,          ,          R4      V#V &   \        P                  ! VV!,          VV!,          ,
          VRV V!,          ,          R4      V$V!&   \        P                  ! WR V",          ) VVR V",          ,          R4      V%V"&   \        P2                  ! V#4      p&\        P2                  ! V$4      p'\        P2                  ! V%\        P0                  R7      p(\3        V&V'V(4      p)V VRV ,          VVR ,
          p*VV*\4        \        P6                  ! V4      ,          8  ,          p+\        P8                  ! V\        P0                  4      p,VV+,          V*V+,          ,          V,V+&   \        P2                  ! V,\        P0                  R7      p-\3        VV)V-4      pVR8  d   \        P:                  ! VVVRV ,          ,           WE4      pVVV,          ,          p\        P                  ! RVVV*,          ,
          4      pVVVRV,          V,          ,           ,          ,          pV\3        VV)V-4      8  d]   VRVR13,          VRVR13,          P                  V,          ,          p.V.V,          V,          p/V/V,          V.,
          pV^,          pEK^  VV8  d   V&V8:  d)   \        P<                  ! V#4      p0VV0,          VV0&   RVV0&   MmV'V8:  d)   \        P<                  ! V$4      p0VV0,          VV0&   RVV0&   M>V(V8:  d   \        P<                  ! V%4      p0RVV0&   M\        P<                  ! V,4      p0RVV0&   \        WWV4      w  ppVRVR13,          ) VRVR13,          P                  V,          ,          p^ pEKG  V&V8:  d   \?        V#4      p0VV0,          VV0&   RVV0&   V'V8:  d   \?        V$4      p0VV0,          VV0&   RVV0&   R	p VPA                  R
R	4      '       Ed   V'       Ed   \        PB                  ! V4      p1W,          p2V P                  \        P                  ! V V,          V,
          R4      ,          VP                  VV,          V,
          ,          ,           p\        P"                  ! V4      p\        PD                  ! V24      ^ 8  Edu   VV2,          VV2,          ,          p3VV2,          VV2,          ,          p4VV2,          VV2,          ,          p5\        P                   ! \'        V3V4,          V5R,          ,
          R4      4      ) pV5VV2,          ,          V3VV2,          ,          ,
          VV2&   RVV2( &   VRV,          8  gG   \        PF                  ! V\4        ) \        P6                  ! VV2,          4      ,          8  4      '       d   EMuVV2;;,          V) ,          uu&   \        P"                  ! V4      p6\        P"                  ! V4      p7VV2,          R,          VV2,          R,          ,           VV2,          R,          ,
          V6V2&   VV2,          R,          VV2,          R,          ,           VV2,          R,          ,
          V7V2&   \        P                   ! V6V6R8  ,          4      VV6R8  ,          ,
          V6V6R8  &   \        P                   ! V7V7R8  ,          4      VV7R8  ,          ,           V7V7R8  &   \        P                  ! VV,
          R4      p8\        P                  ! VV,
          R4      p9V6\4        V8,          8  p V7\4        V9,          8  p!\        PH                  ! V4      p:\        PH                  ! V4      p;\        P                  ! V:V ,          V8V ,          V6V ,          ,          4      V:V &   \        P                  ! V;V!,          V9V!,          V7V!,          ,          4      V;V!&   \        P2                  ! V:4      p<\        P2                  ! V;4      p=\3        V<V=4      p>^p?\K        V?^,
          V>,          ^,           4      p?\        PL                  ! V>V?,          V>V?4      p@\        P                  ! V V,          V,
          R4      pAVV,          V,
          pB\        PB                  ! V4      pCRVCV2( &   \        PN                  ! V?4      pD\Q        V?4       F  pERX@VE,          ,          RV@VE,          R,          ,           ,          pF\        P:                  ! VVFVV@VE,          XC,          ,
          ,          ,           VV4      pG\        P                  ! V VG,          V,
          R4      pHVVG,          V,
          pIRXAVA,          XBVB,          ,           VHVH,          ,
          VIVI,          ,
          ,          XDVE&   K  	  \        P                  ! XDR8*  4      '       d   EMk\        PR                  ! XD4      pJRX@VJ,          R,          ,
          RV@VJ,          R,          ,           ,          pKRV@VJ,          ,          RV@VJ,          R,          ,           ,          pFVKVV2,          ,          VFVV2,          ,          ,           VV2&   V P                  \        P                  ! V V,          V,
          R4      ,          VP                  VV,          V,
          ,          ,           pVVDVJ,          ,          pV>R8  d[   XJV?^,
          8X  dM   V<V>8:  d   \?        V:4      p0VV0,          VV0&   RV2V0&   V=V>8:  d    \?        V;4      p0VV0,          VV0&   RV2V0&   EK  EK   \        P                  ! V V,          V,
          R4      pA\        P                  ! V V1,          V,
          R4      pLVV,          V,
          pBVV1,          V,
          pMVAVA,          VBVB,          ,           VLVL,          VMVM,          ,           8  d   T1pV'       dp   \        P                  ! VV8*  4      '       g   Q h\        P                  ! VV8*  4      '       g   Q h\        P(                  P+                  V4      RV,          8  g   Q hV#   \.         d    \        P0                  p ELi ; i  \.         d     ELi ; i)a  
Minimize approximately a linear constraint violation subject to bound
constraints in a trust region.

This function solves approximately

.. math::

    \min_{s \in \mathbb{R}^n} \quad \frac{1}{2} \big( \lVert \max \{
    A_{\scriptscriptstyle I} s - b_{\scriptscriptstyle I}, 0 \} \rVert^2 +
    \lVert A_{\scriptscriptstyle E} s - b_{\scriptscriptstyle E} \rVert^2
    \big) \quad \text{s.t.}
    \quad
    \left\{ \begin{array}{l}
        l \le s \le u,\\
        \lVert s \rVert \le \Delta,
    \end{array} \right.

using a variation of the truncated conjugate gradient method.

Parameters
----------
aub : `numpy.ndarray`, shape (m_linear_ub, n)
    Matrix :math:`A_{\scriptscriptstyle I}` as shown above.
bub : `numpy.ndarray`, shape (m_linear_ub,)
    Vector :math:`b_{\scriptscriptstyle I}` as shown above.
aeq : `numpy.ndarray`, shape (m_linear_eq, n)
    Matrix :math:`A_{\scriptscriptstyle E}` as shown above.
beq : `numpy.ndarray`, shape (m_linear_eq,)
    Vector :math:`b_{\scriptscriptstyle E}` as shown above.
xl : `numpy.ndarray`, shape (n,)
    Lower bounds :math:`l` as shown above.
xu : `numpy.ndarray`, shape (n,)
    Upper bounds :math:`u` as shown above.
delta : float
    Trust-region radius :math:`\Delta` as shown above.
debug : bool
    Whether to make debugging tests during the execution.

Returns
-------
`numpy.ndarray`, shape (n,)
    Approximate solution :math:`s`.

Other Parameters
----------------
improve_tcg : bool, optional
    If True, a solution generated by the truncated conjugate gradient
    method that is on the boundary of the trust region is improved by
    moving around the trust-region boundary on the two-dimensional space
    spanned by the solution and the gradient of the quadratic function at
    the solution (default is True).

Notes
-----
This function implements Algorithm 6.4 of [1]_. It is assumed that the
origin is feasible with respect to the bound constraints and that `delta`
is finite and positive.

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.
r   Nrp   Fr   r   r	   rq   Tr
   r   r   r   r   )*r   r   r   r   r   r   r   r   r   r   r   r   r   r_rt   qr_normal_byrd_omojokunr0   r2   r!   r"   r#   r$   r%   r&   r)   r*   r'   r(   r+   r,   r-   r.   r/   r   r    r1   r3   r4   r5   emptyranger6   )Nrv   rw   rx   beqr9   r:   r;   r<   r=   r>   m_linear_ubr?   r7   ry   rz   
free_slackr{   r|   r}   delta_slackrB   rC   r~   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   i_slackrO   rP   all_alpha_slackrQ   rR   alpha_slackrS   r   r   r   r   r   rT   rU   rV   rA   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rg   rh   resid_ubresid_eqr   rj   i	sin_valuestep_altresid_ub_altresid_eq_altrk   rl   resid_ub_baseresid_eq_basesN   &&&&&&&&,                                                                     rm   normal_byrd_omojokunr     s>   F u#rzz**sxx1}<<sBJJ''ACIIaL(	
)
 sBJJ''A		!		!,	
-
 sBJJ''ACIIaL(	
) "bjj))bhh399Q</.III"bjj))bhh399Q</.III%''''%&&&&R$vvbi    vvbDj!!!!{{5!!eck11	B	B	B	B YYNK55#rzz#t445DCxD!HsN+GCxD!HsN+GsJSyS8^d2h6<=G&HE1 ''#)d2hb&99:K 88A;D
AuvI,!AuvI,..4/	0Bqr(NE	AF
ao%
%)eckAoC1E(FFF	 r"1vu5H	8YtBxAB%MNH 9w$-/ %%r"1v.1267w,TCL((gX/5JJ Hj)6WsU{W445F w,'2bq6TEBFF29<M4M+MNrvv+&"Ra&4"&&d:K3K*KL12$R1A)A AB||D"&&1||D"&&1,,sBFF3ZZXT
"b!fTl2
T  ZZXT
"b!fTl2
T $&::"XgAB0$
  66,'66,'ff_bff=x;7 r"1v12&&4"&&-#778||C0"4[6$<7T66,7 E8X.3;774%"Ra&.0"9DEGO#DJJsEEFN$:;Eewuw)>>??F3x844 !UV)!UV)(=>I'72DY&BFAX 5 		,/ iU!&U"		,/ iU!&%		/2$)
5!		,/!&.g7HE1 AuvI,!AuvI,..4"78BA
 5 - iU!&5 - iU!&# zz-&&+;+;GGDM	#uurzz#*s"2C88355$J<
 
 XXa[w'!+ 7md7m3G7md7m3GWW5Iwws7W#4y#~#EsKLLG#d7m3gW6MMBwKBxL%&.(BFFD5266"W+#666- - wKG8#K
 hhqkGhhqkGW$r'{c'99BwK3<NN G W$r'{c'99BwK3<NN G #./"Ws]2CC GcM" #./"Ws]2CC GcM" jjC0GjjdC0GTG^+DTG^+DwwqzHwwqzHZZ-HTN  ZZ-HTN 66(#D66(#DtT?D
 IY]d2Q67ID9$4dIFIzz#*s"2C8HTzC'HI"%Iwh),J9%)A,.#	!8K2KL	779Yq\I-E(EFF
  "zz#.3*>D"X~3 #x')*"\12 #\12!
1 & vvjC'(( IIj)Ey/366i&#--I y//)E"2c"99;I%W5	BwK8OODM552::cDj3&6<<suud
S @ D j''F
 czey1}44<#H-E"$U)DK%*GEN4<#H-E"$U)DK%*GEN  
  ::cDj3.4

3?S#8#>:#i#-x(X"55m+mm.KKL DvvbDj!!!!vvdbj!!!!yy~~d#cEk111Km ! 	vvH	 ! 		s.   5AJ5 AK J5AKKAKKAK&K%AK&c                 t   VP                   p\        P                  ! V4      p\        \        P                  ! V.W( R 3,          .Wb( R 3,          ) .Wc( R 3,          ..4      P
                  RR7      w  rxp	\        P                  ! \        P                  ! \        P                  ! V4      4      R\        ,          V,          \        P                  P                  VR\        P                  ! VP                  4      1R\        P                  ! VP                  4      13,          ^ R7      ,          8  4      p
W3# rp   T)pivotingg      $@N)axis)r   r   eyer   blockrt   r    r(   diagr!   r#   r$   r*   r   )rv   rx   ry   rz   r{   r?   identityr}   r_r|   s   &&&&&      rm   rs   rs   c  s   AvvayH
Xq[!"8Q;''((A+&'		
 !
GA! 
rwwqz

 ))..,RVVAGG_,.?qww.??@q.
IJ	JE 8O    c                    V P                   w  rV\        P                  ! V4      p\        P                  ! V4      p\        \        P                  ! W( R 3,          W( R 3,          ) .\        P
                  ! V\        P                  ! V4      ,
          V34      W( R 3,          ) .Wq( R 3,          ) \        P
                  ! V\        P                  ! V4      ,
          V34      .Wr( R 3,          \        P
                  ! V\        P                  ! V4      ,
          V34      ..4      P                  RR7      w  rp\        P                  ! \        P                  ! \        P                  ! V
4      4      R\        ,          We,           ,          \        P                  P                  V
R\        P                  ! V
P                   4      1R\        P                  ! V
P                   4      13,          ^ R7      ,          8  4      pW3# r   )r   r   r   r   r   r2   r    rt   r(   r   r!   r#   r$   r*   )rv   ry   rz   r   r{   r   r?   
identity_n
identity_mr}   r   r   r|   s   &&&&&        rm   r   r   {  s   YYNKJ$J
 !$!,,
 HHkB,<,<Z,HH!LMQ//
  !,,HHa""2"27";;[IJ
 x{+HHa""2"27";;[IJ	
& !+GA!. 
rwwqz
? ))..,RVVAGG_,.?qww.??@q.
IJ	JE 8Or   c                    W,          pW,          pVR ,          W ,          ,
          p\         P                  ! \        VR ,          WE,          ,           R4      4      pVR8:  d=   V\        \	        Wc,
          4      ,          8  d   \        Wc,
          V,          R4      pV# \	        Wc,           4      \        V,          8  d   \        WVV,           ,          R4      pV# \
        h)r   r   )r   r0   r"   r'   r(   r&   )rB   rC   r;   step_sdsd_sq
dist_tr_sqtemprH   s   &&&     rm   r%   r%     s    iGGEdk)J773w|e&88#>?D#~%$T^)<"<<%/5
 O	 
T^	tj0	0zG^4c: O  r   c                 \    \         P                  ! V \         P                  ! V 4      8  4      # N)r   flatnonzeror"   xs   &rm   _argmaxr         >>!rvvay.))r   c                 \    \         P                  ! V \         P                  ! V 4      8*  4      # r   )r   r   r*   r   s   &rm   r.   r.     r   r   )r   numpyr   scipy.linalgr   utilsr   finfor   tinyr'   epsr!   rn   r   r   rs   r   r%   r   r.    r   rm   <module>r      sh       " 
xxhhuosl	`Fzz0"J**r   