Ë
    âQ(hô—  ã                   óø   — d dl Z d dlZd dlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZmZmZmZmZ ddlmZ ddlmZ  ej*                  e«      j.                  Z ej*                  e«      j2                  Z G d	„ d
«      Zy)é    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                   óÌ  — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zej                  d	„ «       Zed
„ «       Zej                  d„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd+d„Zd„ Zd„ Zd„ Z d „ Z!d!„ Z"d"„ Z#d#„ Z$d$„ Z%d,d%„Z&d&„ Z'd'„ Z(d(„ Z)d)„ Z*d*„ Z+y)-ÚTrustRegionz!
    Trust-region framework.
    c                 óP  — d| _         || _        t        | j                  || j                  «      | _        || _        d| _        | j                  «        t        j                  | j                  «      | _        t        j                  | j                  «      | _        t        j                  | j                  «      | _        t        j                  | j                   «      | _        | j%                  | j&                  «       |t(        j*                     | _        | j.                  | _        y)a	  
        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.
        ç        r   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/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/_lib/cobyqa/framework.pyÚ__init__zTrustRegion.__init__   s×   € ð4 ˆŒð ˆŒÜ˜dŸh™h¨°·±Ó>ˆŒØ#ˆŒð ˆÔØ×ÑÔô  ŸX™X d×&6Ñ&6Ó7ˆÔÜŸX™X d×&6Ñ&6Ó7ˆÔÜ "§¡¨×)<Ñ)<Ó =ˆÔÜ "§¡¨×)<Ñ)<Ó =ˆÔØ×Ñ˜TŸ[™[Ô)ð #¤7§>¡>Ñ2ˆÔØ—‘ˆ�ó    c                 ó.   — | j                   j                  S )zt
        Number of variables.

        Returns
        -------
        int
            Number of variables.
        )r   Ún©r+   s    r/   r3   zTrustRegion.nL   s   € ð �x‰x�z‰zÐr1   c                 ó.   — | j                   j                  S )zœ
        Number of linear inequality constraints.

        Returns
        -------
        int
            Number of linear inequality constraints.
        )r   r   r4   s    r/   r   zTrustRegion.m_linear_ubX   ó   € ð �x‰x×#Ñ#Ð#r1   c                 ó.   — | j                   j                  S )z˜
        Number of linear equality constraints.

        Returns
        -------
        int
            Number of linear equality constraints.
        )r   r   r4   s    r/   r   zTrustRegion.m_linear_eqd   r6   r1   c                 ó.   — | j                   j                  S )z¢
        Number of nonlinear inequality constraints.

        Returns
        -------
        int
            Number of nonlinear inequality constraints.
        )r   r!   r4   s    r/   r!   zTrustRegion.m_nonlinear_ubp   ó   € ð �x‰x×&Ñ&Ð&r1   c                 ó.   — | j                   j                  S )zž
        Number of nonlinear equality constraints.

        Returns
        -------
        int
            Number of nonlinear equality constraints.
        )r   r#   r4   s    r/   r#   zTrustRegion.m_nonlinear_eq|   r9   r1   c                 ó   — | j                   S )zv
        Trust-region radius.

        Returns
        -------
        float
            Trust-region radius.
        )r*   r4   s    r/   ÚradiuszTrustRegion.radiusˆ   ó   € ð �|‰|Ðr1   c                 ó¤   — || _         | j                  | j                  t        j                     | j
                  z  k  r| j
                  | _         yy)z‘
        Set the trust-region radius.

        Parameters
        ----------
        radius : float
            New trust-region radius.
        N)r*   r<   r   r   ÚDECREASE_RADIUS_THRESHOLDr)   )r+   r<   s     r/   r<   zTrustRegion.radius”   sG   € ð ˆŒà�K‰KØ�‰œy×BÑBÑCØ�o‰oñòð  Ÿ?™?ˆD�Lð	r1   c                 ó   — | j                   S )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)   zTrustRegion.resolution¦   s   € ð ×ÑÐr1   c                 ó   — || _         y)z¿
        Set the resolution of the trust-region framework.

        Parameters
        ----------
        resolution : float
            New resolution of the trust-region framework.
        NrA   )r+   r)   s     r/   r)   zTrustRegion.resolution´   s   € ð &ˆÕr1   c                 ó   — | j                   S )zr
        Penalty parameter.

        Returns
        -------
        float
            Penalty parameter.
        )r   r4   s    r/   r   zTrustRegion.penaltyÀ   s   € ð �}‰}Ðr1   c                 ó   — | j                   S )zÁ
        Models of the objective function and constraints.

        Returns
        -------
        `cobyqa.models.Models`
            Models of the objective function and constraints.
        )r   r4   s    r/   ÚmodelszTrustRegion.modelsÌ   r=   r1   c                 ó   — | j                   S )z˜
        Index of the best interpolation point.

        Returns
        -------
        int
            Index of the best interpolation point.
        )r   r4   s    r/   Ú
best_indexzTrustRegion.best_indexØ   s   € ð ×ÑÐr1   c                 ó`   — | j                   j                  j                  | j                  «      S )zÛ
        Best interpolation point.

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

        Returns
        -------
        `numpy.ndarray`
            Best interpolation point.
        )rE   ÚinterpolationÚpointrG   r4   s    r/   r&   zTrustRegion.x_bestä   s#   € ð �{‰{×(Ñ(×.Ñ.¨t¯©Ó?Ð?r1   c                 óH   — | j                   j                  | j                     S )z¦
        Value of the objective function at `x_best`.

        Returns
        -------
        float
            Value of the objective function at `x_best`.
        )rE   Úfun_valrG   r4   s    r/   Úfun_bestzTrustRegion.fun_bestò   s   € ð �{‰{×"Ñ" 4§?¡?Ñ3Ð3r1   c                 óP   — | j                   j                  | j                  dd…f   S )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`.
        N)rE   Úcub_valrG   r4   s    r/   Úcub_bestzTrustRegion.cub_bestþ   ó"   € ð �{‰{×"Ñ" 4§?¡?²AÐ#5Ñ6Ð6r1   c                 óP   — | j                   j                  | j                  dd…f   S )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`.
        N)rE   Úceq_valrG   r4   s    r/   Úceq_bestzTrustRegion.ceq_best
  rQ   r1   c                 ó$  — | j                   j                  |«      | j                  | j                  j                  j
                  |z  | j                  j                  j                  z
  z  z   | j                  | j                  j                  j                  |z  | j                  j                  j                  z
  z  z   | j                  | j                   j                  |«      z  z   | j                  | j                   j                  |«      z  z   S )a/  
        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`.
        )rE   Úfunr   r   ÚlinearÚa_ubÚb_ubr    Úa_eqÚb_eqr"   Úcubr$   Úceq©r+   Úxs     r/   Ú	lag_modelzTrustRegion.lag_model  sÛ   € ð �K‰K�O‰O˜AÓØ× Ñ Ø�x‰x�‰×#Ñ# aÑ'¨$¯(©(¯/©/×*>Ñ*>Ñ>ñ@ñ@ð × Ñ Ø�x‰x�‰×#Ñ# aÑ'¨$¯(©(¯/©/×*>Ñ*>Ñ>ñ@ñ@ð
 ×#Ñ# d§k¡k§o¡o°aÓ&8Ñ8ñ9ð ×#Ñ# d§k¡k§o¡o°aÓ&8Ñ8ñ9ð	
r1   c                 ó”  — | j                   j                  |«      | j                  | j                  j                  j
                  z  z   | j                  | j                  j                  j                  z  z   | j                  | j                   j                  |«      z  z   | j                  | j                   j                  |«      z  z   S )ah  
        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`.
        )rE   Úfun_gradr   r   rW   rX   r    rZ   r"   Úcub_gradr$   Úceq_gradr^   s     r/   Úlag_model_gradzTrustRegion.lag_model_grad.  s¥   € ð �K‰K× Ñ  Ó#Ø× Ñ  4§8¡8§?¡?×#7Ñ#7Ñ7ñ8à× Ñ  4§8¡8§?¡?×#7Ñ#7Ñ7ñ8ð ×#Ñ# d§k¡k×&:Ñ&:¸1Ó&=Ñ=ñ>ð ×#Ñ# d§k¡k×&:Ñ&:¸1Ó&=Ñ=ñ	>ð	
r1   c                 ó  — | j                   j                  «       }| j                  dkD  r*|| j                  | j                   j	                  «       z  z  }| j
                  dkD  r*|| j                  | j                   j                  «       z  z  }|S )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`.
        r   )rE   Úfun_hessr!   r"   Úcub_hessr#   r$   Úceq_hess)r+   Úhesss     r/   Úlag_model_hesszTrustRegion.lag_model_hessD  s{   € ð �{‰{×#Ñ#Ó%ˆØ×Ñ Ò"Ø�D×)Ñ)¨D¯K©K×,@Ñ,@Ó,BÑBÑBˆDØ×Ñ Ò"Ø�D×)Ñ)¨D¯K©K×,@Ñ,@Ó,BÑBÑBˆDØˆr1   c                 óÜ   — | j                   j                  |«      | j                  | j                   j                  |«      z  z   | j                  | j                   j                  |«      z  z   S )aÜ  
        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`.
        )rE   Úfun_hess_prodr"   Úcub_hess_prodr$   Úceq_hess_prod©r+   Úvs     r/   Úlag_model_hess_prodzTrustRegion.lag_model_hess_prodT  sa   € ð$ �K‰K×%Ñ% aÓ(Ø×#Ñ# d§k¡k×&?Ñ&?ÀÓ&BÑBñCà×#Ñ# d§k¡k×&?Ñ&?ÀÓ&BÑBñCð	
r1   c                 óÜ   — | j                   j                  |«      | j                  | j                   j                  |«      z  z   | j                  | j                   j                  |«      z  z   S )ar  
        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`.
        )rE   Úfun_curvr"   Úcub_curvr$   Úceq_curvrp   s     r/   Úlag_model_curvzTrustRegion.lag_model_curvk  s_   € ð  �K‰K× Ñ  Ó#Ø×#Ñ# d§k¡k×&:Ñ&:¸1Ó&=Ñ=ñ>à×#Ñ# d§k¡k×&:Ñ&:¸1Ó&=Ñ=ñ>ð	
r1   c                 ó|   — || j                   j                  | j                  «      d| j                  |«      z  z   z  S )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      à?)rE   rb   r&   rr   ©r+   Ústeps     r/   Úsqp_funzTrustRegion.sqp_fun€  s?   € ð Ø�K‰K× Ñ  §¡Ó-Ø�D×,Ñ,¨TÓ2Ñ2ñ3ñ
ð 	
r1   c                 óž   — | j                   j                  | j                  «      | j                   j                  | j                  «      |z  z   S )aÓ  
        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`.
        )rE   r\   r&   rc   ry   s     r/   Úsqp_cubzTrustRegion.sqp_cub”  ó=   € ð" �K‰K�O‰O˜DŸK™KÓ(Ø�k‰k×"Ñ" 4§;¡;Ó/°$Ñ6ñ7ð	
r1   c                 óž   — | j                   j                  | j                  «      | j                   j                  | j                  «      |z  z   S )aÍ  
        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`.
        )rE   r]   r&   rd   ry   s     r/   Úsqp_ceqzTrustRegion.sqp_ceq©  r~   r1   Nc                 ó8  — |�|�|€ | j                  || j                  «      \  }}}|}| j                  dkD  rb| j                   j                  |||¬«      }t	        j
                  |«      r/|| j                  t        j                  j                  |«      z  z  }|S )av  
        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   )rO   rS   )r   r   r   Ú	violationr   Úcount_nonzeroÚlinalgÚnorm)r+   r_   rL   rO   rS   Úm_valÚc_vals          r/   ÚmeritzTrustRegion.merit¾  s‹   € ð. ˆ?˜g˜o°°Ø(,¯©°°D·L±LÓ(AÑ%ˆG�W˜gØˆØ�=‰=˜3ÒØ—H‘H×&Ñ& q°'À7Ð&ÓKˆEÜ×Ñ Ô&Ø˜Ÿ™¬¯©¯©¸Ó)>Ñ>Ñ>�Øˆr1   c                 ó  — t        j                  | j                  j                  j                  g| j
                  j                  |«      gg«      }t        j                  | j                  j                  j                  | j                  j                  j                  |z  z
  | j
                  j                  |«       g«      }t        j                  | j                  j                  j                  g| j
                  j                  |«      gg«      }t        j                  | j                  j                  j                  | j                  j                  j                  |z  z
  | j
                  j                  |«       g«      }||||fS )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   rW   rX   rE   rc   rY   r\   rZ   rd   r[   r]   )r+   r_   ÚaubÚbubÚaeqÚbeqs         r/   Úget_constraint_linearizationsz)TrustRegion.get_constraint_linearizationsÞ  s1  € ô( �h‰hà—‘—‘×%Ñ%Ð&Ø—‘×%Ñ% aÓ(Ð)ðó
ˆô �h‰hà—‘—‘×$Ñ$ t§x¡x§¡×';Ñ';¸aÑ'?Ñ?Ø—‘—‘ Ó#Ð#ðó
ˆô �h‰hà—‘—‘×%Ñ%Ð&Ø—‘×%Ñ% aÓ(Ð)ðó
ˆô �h‰hà—‘—‘×$Ñ$ t§x¡x§¡×';Ñ';¸aÑ'?Ñ?Ø—‘—‘ Ó#Ð#ðó
ˆð �C˜˜cÐ!Ð!r1   c                 ó²  — | j                  | j                  «      \  }}}}| j                  j                  j                  | j                  z
  }| j                  j                  j
                  | j                  z
  }| j                  t        j                     | j                  z  }t        ||||||||t        j                     fi | j                  ¤Ž}	|t        j                     r�t        ||«      }
t        j                  |	|
z   |k  «      st        j                  ||	|
z
  k  «      rt!        j"                  dt$        d«       t        j&                  j)                  |	«      d|z  kD  rt!        j"                  dt$        d«       t        j*                  | j                  dz  |	|	z  z
  «      }||	z  }||	z  }t        j,                  |||	z  z
  d«      }| j.                  j1                  | j                  «      | j3                  |	«      z   }| j                  j4                  dv r7t7        || j2                  ||||t        j                     fi | j                  ¤Ž}n+t9        || j2                  |||||||d   f	i | j                  ¤Ž}|t        j                     rÀt        ||«      }
t        j                  ||
z   |k  «      st        j                  |||
z
  k  «      rt!        j"                  d	t$        d«       t        j&                  j)                  |	|z   «      dt        j*                  d«      z  | j                  z  kD  rt!        j"                  d
t$        d«       |	|fS )aK  
        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   )Úunconstrainedzbound-constrainedÚdebugz;The tangential step does not respect the bound constraints.z<The trial step does not respect the trust-region constraint.)r�   r&   r   ÚboundsÚxlÚxur   r   ÚBYRD_OMOJOKUN_FACTORr<   r   r   ÚDEBUGr   r   ÚanyÚwarningsÚwarnÚRuntimeWarningr„   r…   ÚsqrtÚmaximumrE   rb   rr   Útyper   r   )r+   r-   r‹   rŒ   r�   rŽ   r—   r˜   r<   Únormal_stepÚtolÚg_bestÚtangential_steps                r/   Úget_trust_region_stepz!TrustRegion.get_trust_region_step  s  € ð8 "×?Ñ?ÀÇÁÓLÑˆˆS�#�sØ�X‰X�_‰_×Ñ $§+¡+Ñ-ˆØ�X‰X�_‰_×Ñ $§+¡+Ñ-ˆð —‘¤×!?Ñ!?Ñ@À4Ç;Á;ÑNˆÜ*ØØØØØØØØ”G—M‘MÑ"ñ

ð �o‰oñ

ˆð ”7—=‘=Ò!Ü   RÓ(ˆCÜ—‘�{ SÑ(¨2Ñ-Ô.Ü—v‘v˜b ;°Ñ#4Ñ4Ô5Ü—‘ØLÜ"Øôô
 �y‰y�~‰~˜kÓ*¨S°6©\Ò9Ü—‘ð"ä"Øô	ô —‘˜Ÿ™ cÑ)¨K¸+Ñ,EÑEÓFˆØ
ˆkÑˆØ
ˆkÑˆÜ�j‰j˜˜s [Ñ0Ñ0°#Ó6ˆØ—‘×%Ñ% d§k¡kÓ2°T×5MÑ5MØó6
ñ 
ˆð �8‰8�=‰=ÐBÑBÜ6ØØ×(Ñ(ØØØØœŸ™Ñ&ñð —/‘/ñ‰Oô CØØ×(Ñ(ØØØØØØØ˜Ñ ñð —/‘/ñˆOð ”7—=‘=Ò!Ü   RÓ(ˆCÜ�v‰v�o¨Ñ+¨bÑ0Ô1´R·V±VØ�_ sÑ*Ñ*ô6ô —‘ð#ä"Øô	ô —	‘	—‘˜{¨_Ñ<Ó=ØœŸ™ ›Ñ$ t§{¡{Ñ2ò3ô —‘ð"ä"Øô	ð ˜OÐ+Ð+r1   c                 óÈ  ‡ ‡— |t         j                     r|‰ j                  k7  sJ d«       ‚t        j                  t        j
                  d‰ j                  j                  |«      «      }t        ‰ j                  j                  ||t         j                     «      Š‰j                  ‰ j                  ‰ j                  j                  «      }‰ j                  j                  j                  ‰ j                  z
  }‰ j                  j                  j                  ‰ j                  z
  }t!        d|ˆˆ fd„||‰ j"                  |t         j                     «      }‰ j                  j%                  ‰ j                  |z   |«      }‰ j                  j                  j&                  ‰ j                  j                  j&                  dd…‰ j                  t        j(                  f   z
  }	|	dd…‰ j                  dgf   |	dd…d‰ j                  gf<   t+        d|ˆˆ fd„|	dd…dd…f   ||‰ j"                  |t         j                     «      }
‰ j                  j%                  ‰ j                  |
z   |«      }t-        |«      t-        |«      kD  r|
}|}‰ j                  j.                  dv �r‰‰ j1                  ‰ j                  «      \  }}}}t3        ||«      }t3        |«      }|| k  }||k\  }||k\  }t5        |||||«      \  }}|dd…|d…f   |dd…|d…f   j6                  |z  z  }t        j8                  j;                  |«      }d|cxk  r‰ j                  j<                  k  �rÍn �nÉ|t>        ‰ j"                  z  kD  �r²‰ j"                  |z  |z  }
‰jA                  |
‰ j                  j                  «      dk  r|
 }
t        jB                  ||
z
  |
|z
  g«      }||
z  |z
  }||
z  |z
  }tE        d	„ ||t        j,                  |«      fD «       «      }t        jD                  t        j,                  |
|    «      d¬
«      }t        jD                  t        j,                  |
|    «      |¬
«      }t        jD                  t        j,                  || dd…f   |
z  «      |¬
«      }tG        d|z  dt        j8                  j;                  |
«      z  «      }||k  rZ‰ j                  j%                  ‰ j                  |
z   |«      }t-        |«      dt-        |«      z  k\  rt        jH                  |
||«      }|t         j                     r§t3        ||«      }t        jJ                  ||z   |k  «      st        jJ                  |||z
  k  «      rtM        jN                  dtP        d«       t        j8                  j;                  |«      d‰ j"                  z  kD  rtM        jN                  dtP        d«       |S )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   r   c                 óP   •— ‰j                  | ‰j                  j                  «      S ©N©ÚcurvrE   rI   ©rq   Úlagr+   s    €€r/   ú<lambda>z/TrustRegion.get_geometry_step.<locals>.<lambda>³  ó   ø€ �c—h‘h˜q $§+¡+×";Ñ";Ó<€ r1   Nr   c                 óP   •— ‰j                  | ‰j                  j                  «      S r©   rª   r¬   s    €€r/   r®   z/TrustRegion.get_geometry_step.<locals>.<lambda>Æ  r¯   r1   )zlinearly constrainedznonlinearly constrainedc              3   óJ   K  — | ]  }t        j                  |d ¬«      –— Œ y­w)r   ©ÚinitialN)r   Úmax)Ú.0Úarrays     r/   ú	<genexpr>z0TrustRegion.get_geometry_step.<locals>.<genexpr>ò  s&   è ø€ ò  àô —F‘F˜5¨#×.Ð.ñ ùs   ‚!#r²   ç      $@g{®Gáz„?gš™™™™™¹?z9The geometry step does not respect the bound constraints.r‘   r’   z?The geometry step does not respect the trust-region constraint.))r   rš   rG   r   ÚsqueezeÚeyerE   Únptr   rI   Úgradr&   r   r–   r—   r˜   r	   r<   Ú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˜   rz   Ú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Úcbdr\   r]   Ú	maxcv_valr£   r­   s   `                             @r/   Úget_geometry_stepzTrustRegion.get_geometry_step€  sý  ù€ ð> ”7—=‘=Ò!à˜Ÿ™Ò(ðJàIóJØ(ô —J‘JœrŸv™v a¨¯©¯©¸%Ó@ÓAˆ	ÜØ�K‰K×%Ñ%ØØ”G—M‘MÑ"ó
ˆð
 —‘˜Ÿ™ d§k¡k×&?Ñ&?Ó@ˆð �X‰X�_‰_×Ñ $§+¡+Ñ-ˆØ�X‰X�_‰_×Ñ $§+¡+Ñ-ˆÜØØÜ<ØØØ�K‰KØ”G—M‘MÑ"ó
ˆð —‘×(Ñ(¨¯©°tÑ);¸UÓCˆð �K‰K×%Ñ%×)Ñ)Ø�k‰k×'Ñ'×+Ñ+ªA¨t¯©ÄÇ
Á
Ð,JÑKñLð 	ð (+ª1¨t¯©ÀÐ.BÐ+BÑ'CˆŠA��4—?‘?Ð#Ð#Ñ$Ü"ØØÜ<Ø’�1‘2�‰JØØØ�K‰KØ”G—M‘MÑ"ó	
ˆð —K‘K×,Ñ,¨T¯[©[¸8Ñ-CÀUÓKˆ	Üˆy‹>œC ›JÒ&ØˆDØˆEð �8‰8�=‰=ð 
ò 
ð
 ×2Ñ2°4·;±;Ó?ñ ˆC��c˜3ä# B¨Ó+ˆFÜ# CÓ(ˆFØ˜V˜G‘mˆGØ˜F‘lˆGØ˜V‘mˆGô 3ØØØØØó‰HˆE�1ð š1˜e™f˜9™¨ª1¨e©f¨9©¯©¸%Ñ)?Ñ@ˆJÜ Ÿi™iŸn™n¨ZÓ8ˆOØ�5Ô%˜4Ÿ8™8Ÿ:™:×%¨/¼DÀ4Ç;Á;Ñ<NÓ*NØ ŸK™K¨/Ñ9¸ZÑG�Ø—8‘8˜H d§k¡k×&?Ñ&?Ó@À3ÒFØ (˜y�Hô —h‘h  X¡¨x¸"©}Ð=Ó>�Ø˜H‘n sÑ*�Ø˜H‘n sÑ*�Üñ  à"% s¬B¯F©F°3«KÐ!8ô ó �	ô —f‘fœRŸV™V H¨g¨XÑ$6Ó7ÀÔE�Ü—f‘fœRŸV™V H¨g¨XÑ$6Ó7ÀÔE�Ü—f‘fœRŸV™V C¨¨²!¨Ñ$4°xÑ$?Ó@È#ÔN�Ü˜$ ™* d¬R¯Y©Y¯^©^¸HÓ-EÑ&EÓF�Ø Ò#Ø $§¡× 8Ñ 8ØŸ™ hÑ.°ó!�Iô ˜9“~¨¬s°5«zÑ)9Ò9Ü!Ÿw™w x°°RÓ8˜à”7—=‘=Ò!Ü   RÓ(ˆCÜ�v‰v�d˜S‘j 2‘oÔ&¬"¯&©&°°d¸S±j±Ô*AÜ—‘ð#ä"Øô	ô �y‰y�~‰~˜dÓ# c¨D¯K©KÑ&7Ò7Ü—‘ð/ä"Øô	ð ˆr1   c                 óô  — | j                  | j                  «      \  }}}}| j                  j                  j                  | j                  z
  }| j                  j                  j
                  | j                  z
  }t        j                  j                  |«      }	t        |||||||	|t        j                     fi | j                  ¤Ž}
|t        j                     r�t        ||«      }t        j                  |
|z   |k  «      st        j                  ||
|z
  k  «      rt        j                   dt"        d«       t        j                  j                  |
«      d|	z  kD  rt        j                   dt"        d«       |
S )aQ  
        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‘   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+   rz   r-   r‹   rŒ   r�   rŽ   r—   r˜   r<   Úsoc_stepr£   s               r/   Ú get_second_order_correction_stepz,TrustRegion.get_second_order_correction_step  s7  € ð" "×?Ñ?ÀÇÁÓLÑˆˆS�#�sØ�X‰X�_‰_×Ñ $§+¡+Ñ-ˆØ�X‰X�_‰_×Ñ $§+¡+Ñ-ˆÜ—‘—‘ Ó%ˆÜ'ØØØØØØØØ”G—M‘MÑ"ñ

ð �o‰oñ

ˆð ”7—=‘=Ò!Ü   RÓ(ˆCÜ�v‰v�h ‘n rÑ)Ô*¬b¯f©f°R¸(ÀS¹.Ñ5HÔ.IÜ—‘ð5ä"Øô	ô �y‰y�~‰~˜hÓ'¨#°©,Ò6Ü—‘ð;ä"Øô	ð ˆr1   c                 ó’  — | j                  | j                  | j                  | j                  | j                  «      }| j                  | j                  |z   |||«      }| j                  | j                  d| j
                  j                  | j                  «      | j
                  j                  | j                  «      «      }| j                  | j                  |z   | j                  |«      | j                  |«      | j                  |«      «      }t        ||z
  «      t        t        ||z
  «      z  kD  r||z
  t        ||z
  «      z  S y)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&   rM   rP   rT   rE   r\   r]   r{   r}   r€   rÀ   rÂ   )	r+   rz   rL   rO   rS   Ú	merit_oldÚ	merit_newÚmerit_model_oldÚmerit_model_news	            r/   Úget_reduction_ratiozTrustRegion.get_reduction_ratioI  s  € ð( —J‘JØ�K‰KØ�M‰MØ�M‰MØ�M‰Mó	
ˆ	ð —J‘J˜tŸ{™{¨TÑ1°7¸GÀWÓMˆ	ØŸ*™*Ø�K‰KØØ�K‰K�O‰O˜DŸK™KÓ(Ø�K‰K�O‰O˜DŸK™KÓ(ó	
ˆð Ÿ*™*Ø�K‰K˜$ÑØ�L‰L˜ÓØ�L‰L˜ÓØ�L‰L˜Óó	
ˆô ˆ Ñ0Ó1´D¼3Ø˜	Ñ!ó<
ñ 5
ò 
ð  	Ñ)¬SØ /Ñ1ó.ñ ð ð r1   c                 óØ  — | j                  | j                  «      \  }}}}t        t        j                  j                  t        j                  t        j                  d| «      |g«      «      t        j                  j                  t        j                  t        j                  d||z  |z
  «      ||z  |z
  g«      «      z
  d«      }| j                  |«      }t        j                  j                  t        j                  | j                  | j                  | j                  | j                  g«      «      }t        |«      t        t        |«      z  kD  rt        |||z  «      }| j                  }	| j                   | j"                  t$        j&                     |z  k  r?t        | j"                  t$        j(                     |z  d«      | _        | j+                  «        |	| j                  k(  S )z¢
        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Â   rG   r   r   r   ÚPENALTY_INCREASE_THRESHOLDÚPENALTY_INCREASE_FACTORr   )
r+   rz   r‹   rŒ   r�   rŽ   Ú	viol_diffÚsqp_valÚ	thresholdÚbest_index_saves
             r/   Úincrease_penaltyzTrustRegion.increase_penaltyy  s¢  € ð "×?Ñ?ÀÇÁÓLÑˆˆS�#�sÜÜ�I‰I�N‰NÜ—‘äŸ
™
 3¨¨Ó-Øðóóô �i‰i�n‰nÜ—‘äŸ
™
 3¨¨d©
°SÑ(8Ó9Ø˜d™
 SÑ(ðóóñð  ó#
ˆ	ð& —,‘,˜tÓ$ˆä—I‘I—N‘NÜ�H‰Hà×&Ñ&Ø×&Ñ&Ø×)Ñ)Ø×)Ñ)ð	óó	
ˆ	ô ˆy‹>œD¤3 w£<Ñ/Ò/Ü˜I w°Ñ':Ó;ˆIØŸ/™/ˆà�M‰MØ�‰œy×CÑCÑDØñòô  Ø—‘¤	× AÑ AÑBÀYÑNØóˆDŒMð ×ÑÔ!Ø $§/¡/Ñ1Ð1r1   c                 óv   — t        | j                  | j                  «       «      | _        | j                  «        y)z1
        Decrease the penalty parameter.
        N)rÃ   r   Ú_get_low_penaltyr   r4   s    r/   Údecrease_penaltyzTrustRegion.decrease_penalty±  s+   € ô ˜DŸM™M¨4×+@Ñ+@Ó+BÓCˆŒØ×ÑÕr1   c           
      ó¶  — | j                   }| j                  | j                  | j                  j                  |   | j                  j
                  |dd…f   | j                  j                  |dd…f   «      }| j                  j                  | j                  | j                  j
                  |dd…f   | j                  j                  |dd…f   «      }dt        z  t        | j                  j                  | j                  j                  «      z  t        t        |«      d«      z  }t        | j                  j                  «      D �]  }|| j                   k7  sŒ| j                  j                  j!                  |«      }| j                  || j                  j                  |   | j                  j
                  |dd…f   | j                  j                  |dd…f   «      }| j                  j                  || j                  j
                  |dd…f   | j                  j                  |dd…f   «      }||k  s|||z   k  sŒû||k  s�Œ|}|}|}�Œ
 || _        y)z2
        Set the index of the best point.
        Nr¸   râ   )rG   rˆ   r&   rE   rL   rO   rS   r   ÚmaxcvÚEPSr´   r3   r»   rÀ   ÚrangerI   rJ   r   )	r+   rG   Úm_bestÚr_bestr£   ÚkÚx_valr†   Úr_vals	            r/   r   zTrustRegion.set_best_index¸  sö  € ð —_‘_ˆ
Ø—‘Ø�K‰KØ�K‰K×Ñ 
Ñ+Ø�K‰K×Ñ 
ªA Ñ.Ø�K‰K×Ñ 
ªA Ñ.ó	
ˆð —‘—‘Ø�K‰KØ�K‰K×Ñ 
ªA Ñ.Ø�K‰K×Ñ 
ªA Ñ.ó
ˆð Üñä�$—+‘+—-‘- §¡§¡Ó1ñ2ô ”#�f“+˜sÓ#ñ$ð 	ô �t—{‘{—‘Ó'ó 	#ˆAØ�D—O‘OÓ#ØŸ™×1Ñ1×7Ñ7¸Ó:�ØŸ
™
ØØ—K‘K×'Ñ'¨Ñ*Ø—K‘K×'Ñ'¨ª1¨Ñ-Ø—K‘K×'Ñ'¨ª1¨Ñ-ó	�ð Ÿ™Ÿ™ØØ—K‘K×'Ñ'¨ª1¨Ñ-Ø—K‘K×'Ñ'¨ª1¨Ñ-ó�ð
 ˜6’> e¨f°s©lÓ&:¸uÀv¼~Ø!"�JØ"�FØ"’Fð#	#ð$ &ˆÕr1   c                 ó–  — t        j                  | j                  j                  j                  | j                  j                  j                  dd…| j
                  t         j                  f   z
  dz  d¬«      }|€d}|}n…| j                  j                  |«      }t        j                  d|t        | j                  t        j                     | j                  z  | j                  «      dz  z  «      dz  }d|| j
                  <   t        j                  |t        j                   |«      z  «      }|t        j"                  ||   «      fS )aç  
        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.
        Nr“   r   ©Úaxisrâ   g      @rÛ   )r   ÚsumrE   rI   r¾   rG   r¿   r½   r    r´   r   r   ÚLOW_RADIUS_FACTORr<   r)   ÚargmaxrÀ   rŸ   )r+   Úx_newÚdist_sqrÈ   ÚweightsÚk_maxs         r/   Úget_index_to_removezTrustRegion.get_index_to_removeâ  s&  € ô2 —&‘&à—‘×)Ñ)×-Ñ-Ø—+‘+×+Ñ+×/Ñ/²°4·?±?ÄBÇJÁJÐ0NÑOñPð ñ	ð
 ô
ˆð ˆ=ØˆEØ‰Gà—K‘K×,Ñ,¨UÓ3ˆEä—
‘
ØØÜØŸ™¬	×(CÑ(CÑDØŸ+™+ñ&àŸ™óð
 ññó	ð ñ
ð ð (,ˆG�D—O‘OÑ$Ü—	‘	˜'¤B§F¡F¨5£MÑ1Ó2ˆØ”b—g‘g˜g e™nÓ-Ð-Ð-r1   c                 óª  — t         j                  j                  |«      }|| j                  t        j
                     k  r1| xj                  | j                  t        j                     z  c_        y|| j                  t        j                     k  r:t        | j                  t        j                     | j                  z  |«      | _        yt        | j                  t        j                     | j                  z  t        | j                  t        j                     | j                  z  | j                  t        j                     |z  «      «      | _        y)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_RATIOr<   ÚDECREASE_RADIUS_FACTORÚ
HIGH_RATIOr´   rÃ   ÚINCREASE_RADIUS_FACTORÚINCREASE_RADIUS_THRESHOLD)r+   rz   ÚratioÚs_norms       r/   Úupdate_radiuszTrustRegion.update_radius  sú   € ô —‘—‘ Ó%ˆØ�D—O‘O¤I×$7Ñ$7Ñ8Ò8Ø�KŠK˜4Ÿ?™?¬9×+KÑ+KÑLÑLŽKØ�d—o‘o¤i×&:Ñ&:Ñ;Ò;ÜØ—‘¤	× @Ñ @ÑAØ—+‘+ñàóˆD�Kô Ø—‘¤	× @Ñ @ÑAØ—+‘+ñäØ—O‘O¤I×$DÑ$DÑEØ—k‘kñ"à—O‘O¤I×$GÑ$GÑHØñóó	ˆD�Kr1   c                 ó†  — | j                   t        j                     |t        j                     z  | j
                  k  r1| xj
                  | j                   t        j                     z  c_        n�| j                   t        j                     |t        j                     z  | j
                  k  r9t        j                  | j
                  |t        j                     z  «      | _        n|t        j                     | _        t        | j                   t        j                     | j                  z  | j
                  «      | _        y)z¨
        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_resolutionzTrustRegion.enhance_resolution9  sõ   € ð �O‰OœI×@Ñ@ÑAØ”g—n‘nÑ%ñ&à�o‰oòð �OŠO˜tŸ™Ü×4Ñ4ñ ñ ŽOð �O‰OœI×CÑCÑDØ”g—n‘nÑ%ñ&à�o‰oòô !Ÿg™g d§o¡oØ(/´·±Ñ(?ñ'@ó AˆD�Oð &¤g§n¡nÑ5ˆDŒOô Ø�O‰OœI×<Ñ<Ñ=ÀÇÁÑLØ�O‰Oó
ˆ�r1   c                 óv   — | j                   j                  t        j                  | j                  «      |«       y)z”
        Shift the base point to `x_best`.

        Parameters
        ----------
        options : dict
            Options of the solver.
        N)rE   Úshift_x_baser   Úcopyr&   r  s     r/   r  zTrustRegion.shift_x_baseZ  s%   € ð 	�‰× Ñ ¤§¡¨¯©Ó!5°wÕ?r1   c           	      óx  — | j                   j                  j                  |z  | j                   j                  j                  k\  }| j                  dk\  }| j                   j
                  j                  |k\  }| j                   j
                  j                  |k  }t        j                  |«      }t        j                  |«      }t        j                  |«      }t        j                  |«      }	||z   | j                  z   | j                  z   dkD  �r*t        j                  | j                   j                  «      }
t        j                  |
|dd…f    |
|dd…f   | j                   j                  j                  |dd…f   | j                  j!                  ||«      | j                   j                  j"                  | j                  j%                  |«      f   }| j                  j'                  |«      }t        j(                  |j*                  d   t        j,                   «      }d|d||	z   |z   |z    t/        |j0                  | |t        j,                  fd¬«      }|j2                  ||	z   ||	z   |z    | j4                  |<   d| j4                  | <   |j2                  ||	z   |z   ||	z   |z   |z    | j6                  |<   d| j6                  | <   |j2                  ||	z   |z   |z   ||	z   |z   |z   | j                  z    | j8                  dd |j2                  ||	z   |z   |z   | j                  z   d | j:                  dd yy)aI  
        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   rW   rX   rY   rP   r–   r—   r˜   r   rƒ   r   r#   rº   r3   Úr_rE   rc   rZ   rd   rb   ÚfullÚshapeÚinfr   rÁ   r_   r   r"   r    r$   )r+   r_   Úincl_linear_ubÚincl_nonlinear_ubÚincl_xlÚincl_xur   r!   Úm_xlÚm_xuÚidentityÚc_jacr¤   Úxl_lmÚress                  r/   r%   zTrustRegion.set_multiplierse  s,  € ð Ÿ™Ÿ™×-Ñ-°Ñ1°T·X±X·_±_×5IÑ5IÑIˆØ ŸM™M¨SÑ0ÐØ—(‘(—/‘/×$Ñ$¨Ñ)ˆØ—(‘(—/‘/×$Ñ$¨Ñ)ˆÜ×&Ñ& ~Ó6ˆÜ×)Ñ)Ð*;Ó<ˆÜ×Ñ Ó(ˆÜ×Ñ Ó(ˆð ˜.Ñ(¨4×+;Ñ+;Ñ;Ø×%Ñ%ñ&Ø()ó*ô —v‘v˜dŸh™hŸj™jÓ)ˆHÜ—E‘EØ˜'¢1˜*Ñ%Ð%Ø˜¢!˜Ñ$Ø—‘—‘×$Ñ$ ^²QÐ%6Ñ7Ø—‘×$Ñ$ QÐ(9Ó:Ø—‘—‘×$Ñ$Ø—‘×$Ñ$ QÓ'ð)ñˆEð —[‘[×)Ñ)¨!Ó,ˆFÜ—G‘G˜EŸK™K¨™N¬R¯V©V¨GÓ4ˆEØBEˆEÐ>�D˜4‘K +Ñ-°Ñ>Ð?ÜØ—‘Ø�ØœrŸv™v�Øô	ˆCð 25·±Ø�t‘˜D 4™K¨+Ñ5ð2ˆD×Ñ˜~Ñ.ð 36ˆD×Ñ ˜Ñ/Ø7:·u±uØØñàñà"Øñàñð !ñ!ð8ˆD×!Ñ!Ð"3Ñ4ð 9<ˆD×!Ñ!Ð#4Ð"4Ñ5Ø$'§E¡EØØñàñð !ñ!ð "&Øñ"àñ"ð !ñ"!ð ×"Ñ"ñ	"#ð		%ˆD×Ñ™qÐ!ð (+§u¡uØ�t‘˜kÑ)¨NÑ:¸T×=MÑ=MÑMÐNð(ˆD×!Ñ!¡!Ñ$ða*r1   c                 ó>  — t         j                  | j                  j                  j                  t         j
                  d d …f   | j                  j                  j                  j                  z   | j                  j                  j                  j                  z  | j                  j                  j                  t         j
                  d d …f   z
  | j                  j                  f   }| j                  j                  j                  t         j
                  d d …f   | j                  j                  j                  j                  z   | j                  j                  j                  j                  z  | j                  j                  j                  t         j
                  d d …f   z
  }t        j                  || | j                  j                   | j                  j                    g«      }t        j                  ||g«      }t        j"                  |d¬«      }t        j$                  |d¬«      }|| j&                  t(        j*                     |z  k  }t        j,                  |«      r±t        j"                  | j                  j.                  «      }t        j$                  | j                  j.                  «      }t        j0                  d||   «      }	t        j2                  ||   |	z
  «      }
|
t4        ||z
  z  kD  r
||z
  |
z  }|S t         j6                  }|S d}|S )Nr   r÷   r   )r   Úc_rE   rI   Úx_baser¿   r¾   rÁ   r   rW   rX   rY   rO   rZ   r[   rŠ   rS   ÚnanminÚnanmaxr   r   ÚTHRESHOLD_RATIO_CONSTRAINTSr›   rL   Ú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ë   zTrustRegion._get_low_penalty°  si  € Ü—5‘5à—‘×)Ñ)×0Ñ0´·±ºQ°Ñ?Ø—+‘+×+Ñ+×/Ñ/×1Ñ1ñ2ð �h‰h�o‰o×"Ñ"×$Ñ$ñ	%ð
 �h‰h�o‰o×"Ñ"¤2§:¡:ªq =Ñ1ñ2ð �K‰K×Ñð!ñ
ˆð �K‰K×%Ñ%×,Ñ,¬R¯Z©Zº¨]Ñ;Ø�k‰k×'Ñ'×+Ñ+×-Ñ-ñ.à�H‰H�O‰O× Ñ ×"Ñ"ñ#ð &*§X¡X§_¡_×%9Ñ%9¼"¿*¹*Âa¸-Ñ%HñIˆô —8‘8àØ�	Ø—‘×#Ñ#Ø—‘×$Ñ$Ð$ð	ó
ˆô —‘˜( HÐ-Ó.ˆÜ—	‘	˜% aÔ(ˆÜ—	‘	˜% aÔ(ˆàØ�o‰oœi×CÑCÑDÀuÑLñMð 	ô �6‰6�'Œ?Ü—I‘I˜dŸk™k×1Ñ1Ó2ˆEÜ—I‘I˜dŸk™k×1Ñ1Ó2ˆEÜŸ
™
 3¨¨g©Ó7ˆIÜ—V‘V˜E '™N¨YÑ6Ó7ˆFØœ ¨¡Ñ.Ò.Ø  5™=¨FÑ2�ð
 ˆô Ÿ&™&�ð ˆð ˆGØˆr1   )NNNr©   ),Ú__name__Ú
__module__Ú__qualname__Ú__doc__r0   Úpropertyr3   r   r   r!   r#   r<   Úsetterr)   r   rE   rG   r&   rM   rP   rT   r`   re   rk   rr   rw   r{   r}   r€   rˆ   r�   r¦   rÖ   rÙ   rà   ré   rì   r   r   r	  r  r  r%   rë   © r1   r/   r   r      sÜ  „ ñò.'ð` ñ	ó ð	ð ñ	$ó ð	$ð ñ	$ó ð	$ð ñ	'ó ð	'ð ñ	'ó ð	'ð ñ	ó ð	ð ‡]�]ñ+ó ð+ð" ñ ó ð ð ×Ññ	&ó ð	&ð ñ	ó ð	ð ñ	ó ð	ð ñ	 ó ð	 ð ñ@ó ð@ð ñ	4ó ð	4ð ñ	7ó ð	7ð ñ	7ó ð	7ò
ò0
ò,ò 
ò.
ò*
ò(
ò*
ó*ò@,"ò\r,òhUòn0òd.ò`62òpò(&óT5.ònò@
òB	@òIóV(r1   r   )rœ   Únumpyr   Úscipy.optimizer   rE   r   r   Úsettingsr   r   Ú
subsolversr	   r
   r   r   r   Úsubsolvers.optimr   Úutilsr   ÚfinfoÚfloatÚtinyrÂ   Úepsrï   r   r;  r1   r/   ú<module>rF     s^   ðÛ ã Ý %ç %ß (÷õ õ :Ý !ð €r‡x�x�ƒ×Ñ€Ø€b‡h�hˆuƒo×Ñ€÷Aò Ar1   