§
    fŠtjô—  ã                   óä   — 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¦  «        j        Z G d	„ d
¦  «        ZdS )é    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+dS )-ÚTrustRegionz!
    Trust-region framework.
    c                 ó  — d| _         || _        t          | j        || j        ¦  «        | _        || _        d| _        |                      ¦   «          t          j	        | j
        ¦  «        | _        t          j	        | j        ¦  «        | _        t          j	        | j        ¦  «        | _        t          j	        | j        ¦  «        | _        |                      | j        ¦  «         |t(          j                 | _        | j        | _        dS )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/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/_lib/cobyqa/framework.pyÚ__init__zTrustRegion.__init__   sØ   € ð4 ˆŒð ˆŒÝ˜dœh¨°´Ñ>Ô>ˆŒØ#ˆŒð ˆÔØ×ÒÑÔÐõ  œX dÔ&6Ñ7Ô7ˆÔÝœX dÔ&6Ñ7Ô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Œ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Ô#Ð#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Ô&Ð&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        | _         dS dS )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”   sJ   € ð ˆŒàŒKØŒ�yÔBÔCØŒoñòð ð  œ?ˆDŒLˆLˆ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                 ó   — || _         dS )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                 ó0   — | 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                 ó8   — | 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°A°AÐ#5Ô6Ð6r1   c                 ó8   — | 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        |z  | j        j        j        z
  z  z   | j        | j        j        j        |z  | j        j        j	        z
  z  z   | j
        | j                              |¦  «        z  z   | 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�OŠO˜AÑÔØÔ ØŒxŒÔ# aÑ'¨$¬(¬/Ô*>Ñ>ñ@ñ@ð Ô ØŒxŒÔ# aÑ'¨$¬(¬/Ô*>Ñ>ñ@ñ@ð
 Ô# d¤k§o¢o°aÑ&8Ô&8Ñ8ñ9ð Ô# d¤k§o¢o°aÑ&8Ô&8Ñ8ñ9ð	
r1   c                 ó*  — | j                              |¦  «        | j        | j        j        j        z  z   | j        | j        j        j        z  z   | j        | j          	                    |¦  «        z  z   | 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× Ò  Ñ#Ô#ØÔ  4¤8¤?Ô#7Ñ7ñ8àÔ  4¤8¤?Ô#7Ñ7ñ8ð Ô# d¤k×&:Ò&:¸1Ñ&=Ô&=Ñ=ñ>ð Ô# d¤k×&:Ò&:¸1Ñ&=Ô&=Ñ=ñ	>ð	
r1   c                 óô   — | j                              ¦   «         }| j        dk    r$|| j        | j                              ¦   «         z  z  }| j        dk    r$|| 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  sx   € ð Œ{×#Ò#Ñ%Ô%ˆØÔ Ò"Ð"Ø�DÔ)¨D¬K×,@Ò,@Ñ,BÔ,BÑBÑBˆDØÔ Ò"Ð"Ø�DÔ)¨D¬K×,@Ò,@Ñ,BÔ,BÑBÑBˆDØˆr1   c                 óÂ   — | j                              |¦  «        | j        | j                              |¦  «        z  z   | 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  s^   € ð$ ŒK×%Ò% aÑ(Ô(ØÔ# d¤k×&?Ò&?ÀÑ&BÔ&BÑBñCàÔ# d¤k×&?Ò&?ÀÑ&BÔ&BÑBñCð	
r1   c                 óÂ   — | j                              |¦  «        | j        | j                              |¦  «        z  z   | 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× Ò  Ñ#Ô#ØÔ# d¤k×&:Ò&:¸1Ñ&=Ô&=Ñ=ñ>àÔ# d¤k×&:Ò&:¸1Ñ&=Ô&=Ñ=ñ>ð	
r1   c                 óx   — || j                              | j        ¦  «        d|                      |¦  «        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€  sA   € ð ØŒK× Ò  ¤Ñ-Ô-Ø�D×,Ò,¨TÑ2Ô2Ñ2ñ3ñ
ð 	
r1   c                 ó†   — | 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�OŠO˜DœKÑ(Ô(ØŒk×"Ò" 4¤;Ñ/Ô/°$Ñ6ñ7ð	
r1   c                 ó†   — | 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                 ó   — |�|�|€|                       || j        ¦  «        \  }}}|}| j        dk    r[| j                              |||¬¦  «        }t	          j        |¦  «        r*|| j        t          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`.
        Nr   )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Ñ(AÔ(AÑ%ˆG�W˜gØˆØŒ=˜3ÒÐØ”H×&Ò& q°'À7Ð&ÑKÔKˆEÝÔ Ñ&Ô&ð ?Ø˜œ­¬¯ª¸Ñ)>Ô)>Ñ>Ñ>�Øˆr1   c                 óV  — t          j        | j        j        j        g| j                             |¦  «        gg¦  «        }t          j        | j        j        j        | j        j        j        |z  z
  | j                             |¦  «         g¦  «        }t          j        | j        j        j	        g| j         
                    |¦  «        gg¦  «        }t          j        | j        j        j        | j        j        j	        |z  z
  | 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Þ  s  € õ( Œhà””Ô%Ð&Ø”×%Ò% aÑ(Ô(Ð)ðñ
ô 
ˆõ Œhà””Ô$ t¤x¤Ô';¸aÑ'?Ñ?Ø”—’ Ñ#Ô#Ð#ðñ
ô 
ˆõ Œhà””Ô%Ð&Ø”×%Ò% aÑ(Ô(Ð)ðñ
ô 
ˆõ Œhà””Ô$ t¤x¤Ô';¸aÑ'?Ñ?Ø”—’ Ñ#Ô#Ð#ðñ
ô 
ˆð �C˜˜cÐ!Ð!r1   c                 óþ  — |                       | 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                             |	¦  «        d|z  k    rt!          j        dt$          d¦  «         t          j        | j	        dz  |	|	z  z
  ¦  «        }||	z  }||	z  }t          j        |||	z  z
  d¦  «        }| j                             | j        ¦  «        |                      |	¦  «        z   }| j        j        dv r-t7          || j        ||||t          j                 fi | j        ¤Ž}n%t9          || j        |||||||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                             |	|z   ¦  «        dt          j        d¦  «        z  | j	        z  k    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  sN  € ð8 "×?Ò?ÀÄÑLÔLÑˆˆS�#�sØŒXŒ_Ô $¤+Ñ-ˆØŒXŒ_Ô $¤+Ñ-ˆð ”¥Ô!?Ô@À4Ä;ÑNˆÝ*ØØØØØØØØ•G”MÔ"ð

ð 

ð Œoð

ð 

ˆð •7”=Ô!ð 	Ý   RÑ(Ô(ˆCÝ”�{ SÑ(¨2Ò-Ñ.Ô.ð Ý”v˜b ;°Ñ#4Ò4Ñ5Ô5ðå”ØLÝ"Øñô ð õ
 Œy�~Š~˜kÑ*Ô*¨S°6©\Ò9Ð9Ý”ð"å"Øñ	ô ð õ ”˜œ cÑ)¨K¸+Ñ,EÑEÑFÔFˆØ
ˆkÑˆØ
ˆkÑˆÝŒj˜˜s [Ñ0Ñ0°#Ñ6Ô6ˆØ”×%Ò% d¤kÑ2Ô2°T×5MÒ5MØñ6
ô 6
ñ 
ˆð Œ8Œ=ÐBÐBÐBÝ6ØØÔ(ØØØØ�œÔ&ðð ð ”/ðð ˆOˆOõ CØØÔ(ØØØØØØØ˜Ô ðð ð ”/ðð ˆOð •7”=Ô!ð 	Ý   RÑ(Ô(ˆCÝŒv�o¨Ñ+¨bÒ0Ñ1Ô1ð µR´VØ�_ sÑ*Ò*ñ6ô 6ð õ ”ð#å"Øñ	ô ð õ ”	—’˜{¨_Ñ<Ñ=Ô=Ø�œ ™œÑ$ t¤{Ñ2ò3ð 3õ ”ð"å"Øñ	ô ð ð ˜OÐ+Ð+r1   c                 óÖ
  ‡ ‡— |t           j                 r|‰ j        k    s
J d¦   «         ‚t          j        t          j        d‰ j        j        |¦  «        ¦  «        }t          ‰ j        j	        ||t           j                 ¦  «        Š‰ 
                    ‰ j        ‰ j        j	        ¦  «        }‰ j        j        j        ‰ j        z
  }‰ j        j        j        ‰ j        z
  }t!          d|ˆˆ fd„||‰ j        |t           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        |
z   |¦  «        }t-          |¦  «        t-          |¦  «        k    r|
}|}‰ j        j        dv �r’‰                      ‰ j        ¦  «        \  }}}}t3          ||¦  «        }t3          |¦  «        }|| k    }||k    }||k    }t5          |||||¦  «        \  }}|dd…|d…f         |dd…|d…f         j        |z  z  }t          j                             |¦  «        }d|cxk     r‰ j        j        k     �rÏn �nË|t>          ‰ j        z  k    �r·‰ j        |z  |z  }
‰                      |
‰ j        j	        ¦  «        dk     r|
 }
t          j!        ||
z
  |
|z
  g¦  «        }||
z  |z
  }||
z  |z
  }tE          d	„ ||t          j        |¦  «        fD ¦   «         ¦  «        }t          j"        t          j        |
|          ¦  «        d¬
¦  «        }t          j"        t          j        |
|          ¦  «        |¬
¦  «        }t          j"        t          j        || dd…f         |
z  ¦  «        |¬
¦  «        }tG          d|z  dt          j                             |
¦  «        z  ¦  «        }||k    r\‰ j                             ‰ j        |
z   |¦  «        }t-          |¦  «        dt-          |¦  «        z  k    rt          j$        |
||¦  «        }|t           j                 r§t3          ||¦  «        }t          j%        ||z   |k     ¦  «        st          j%        |||z
  k     ¦  «        rtM          j'        dtP          d¦  «         t          j                             |¦  «        d‰ j        z  k    rtM          j'        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                 óD   •— ‰                      | ‰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                 óD   •— ‰                      | ‰j        j        ¦  «        S r©   rª   r¬   s    €€r/   r®   z/TrustRegion.get_geometry_step.<locals>.<lambda>Æ  r¯   r1   )zlinearly constrainedznonlinearly constrainedc              3   óB   K  — | ]}t          j        |d ¬¦  «        V — ŒdS )r   ©ÚinitialN)r   Úmax)Ú.0Úarrays     r/   ú	<genexpr>z0TrustRegion.get_geometry_step.<locals>.<genexpr>ò  sE   è è € ð  ð  àõ ”F˜5¨#Ð.Ñ.Ô.ð ð  ð  ð  ð  ð  r1   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�rœv a¨¬¬¸%Ñ@Ô@ÑAÔAˆ	ÝØŒKÔ%ØØ•G”MÔ"ñ
ô 
ˆð
 —’˜œ d¤kÔ&?Ñ@Ô@ˆð ŒXŒ_Ô $¤+Ñ-ˆØŒXŒ_Ô $¤+Ñ-ˆÝØØØ<Ð<Ð<Ð<Ð<ØØØŒKØ•G”MÔ"ñ
ô 
ˆð ”×(Ò(¨¬°tÑ);¸UÑCÔCˆð ŒKÔ%Ô)ØŒkÔ'Ô+¨A¨A¨A¨t¬ÅÄ
Ð,JÔKñLð 	ð (+¨1¨1¨1¨t¬ÀÐ.BÐ+BÔ'CˆˆAˆAˆA��4”?Ð#Ð#Ñ$Ý"ØØØ<Ð<Ð<Ð<Ð<Ø����1�2�2�ŒJØØØŒKØ•G”MÔ"ñ	
ô 	
ˆð ”K×,Ò,¨T¬[¸8Ñ-CÀUÑKÔKˆ	Ýˆy‰>Œ>�C ™JœJÒ&Ð&ØˆDØˆEð Œ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˜1˜1˜e˜f˜f˜9œ¨¨1¨1¨1¨e¨f¨f¨9¬¬¸%Ñ)?Ñ@ˆJÝ œiŸnšn¨ZÑ8Ô8ˆOØ�5Ð%Ð%Ò%Ð%˜4œ8œ:Ò%Ñ%Ð%Ð%Ñ%¨/½DÀ4Ä;Ñ<NÒ*NÑ*NØ œK¨/Ñ9¸ZÑG�Ø—8’8˜H d¤kÔ&?Ñ@Ô@À3ÒFÐFØ (˜y�Hõ ”h  X¡¨x¸"©}Ð=Ñ>Ô>�Ø˜H‘n sÑ*�Ø˜H‘n sÑ*�Ýð  ð  à"% s­B¬F°3©K¬KÐ!8ð ñ  ô  ñ ô �	õ ”f�RœV H¨g¨XÔ$6Ñ7Ô7ÀÐEÑEÔE�Ý”f�RœV H¨g¨XÔ$6Ñ7Ô7ÀÐEÑEÔE�Ý”f�RœV C¨¨°!°!°!¨Ô$4°xÑ$?Ñ@Ô@È#ÐNÑNÔN�Ý˜$ ™* d­R¬Y¯^ª^¸HÑ-EÔ-EÑ&EÑFÔF�Ø Ò#Ð#Ø $¤× 8Ò 8Øœ hÑ.°ñ!ô !�Iõ ˜9‘~”~¨­s°5©z¬zÑ)9Ò9Ð9Ý!œw x°°RÑ8Ô8˜à•7”=Ô!ð 	Ý   RÑ(Ô(ˆCÝŒv�d˜S‘j 2’oÑ&Ô&ð ­"¬&°°d¸S±j²Ñ*AÔ*Að Ý”ð#å"Øñ	ô ð õ Œy�~Š~˜dÑ#Ô# c¨D¬KÑ&7Ò7Ð7Ý”ð/å"Øñ	ô ð ð ˆr1   c                 ó   — |                       | j        ¦  «        \  }}}}| j        j        j        | j        z
  }| j        j        j        | j        z
  }t          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                             |
¦  «        d|	z  k    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  sS  € ð" "×?Ò?ÀÄÑLÔLÑˆˆS�#�sØŒXŒ_Ô $¤+Ñ-ˆØŒXŒ_Ô $¤+Ñ-ˆÝ”—’ Ñ%Ô%ˆÝ'ØØØØØØØØ•G”MÔ"ð

ð 

ð Œoð

ð 

ˆð •7”=Ô!ð 	Ý   RÑ(Ô(ˆCÝŒv�h ‘n rÒ)Ñ*Ô*ð ­b¬f°R¸(ÀS¹.Ò5HÑ.IÔ.Ið Ý”ð5å"Øñ	ô ð õ Œy�~Š~˜hÑ'Ô'¨#°©,Ò6Ð6Ý”ð;å"Øñ	ô ð ð ˆr1   c                 óŠ  — |                       | j        | j        | j        | j        ¦  «        }|                       | j        |z   |||¦  «        }|                       | j        d| j                             | j        ¦  «        | j                             | j        ¦  «        ¦  «        }|                       | j        |z   |                      |¦  «        |  	                    |¦  «        |  
                    |¦  «        ¦  «        }t          ||z
  ¦  «        t          t          ||z
  ¦  «        z  k    r||z
  t          ||z
  ¦  «        z  S dS )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ØŒMØŒMØŒMñ	
ô 
ˆ	ð —J’J˜tœ{¨TÑ1°7¸GÀWÑMÔMˆ	ØŸ*š*ØŒKØØŒK�OŠO˜DœKÑ(Ô(ØŒK�OŠO˜DœKÑ(Ô(ñ	
ô 
ˆð Ÿ*š*ØŒK˜$ÑØ�LŠL˜ÑÔØ�LŠL˜ÑÔØ�LŠL˜ÑÔñ	
ô 
ˆõ ˆ Ñ0Ñ1Ô1µD½3Ø˜	Ñ!ñ<
ô <
ñ 5
ò 
ð 
ð  	Ñ)­SØ /Ñ1ñ.ô .ñ ð ð �4r1   c                 ó®  — |                       | j        ¦  «        \  }}}}t          t          j                             t          j        t          j        d| ¦  «        |g¦  «        ¦  «        t          j                             t          j        t          j        d||z  |z
  ¦  «        ||z  |z
  g¦  «        ¦  «        z
  d¦  «        }|                      |¦  «        }t          j                             t          j        | j	        | j
        | j        | j        g¦  «        ¦  «        }t          |¦  «        t          t          |¦  «        z  k    rt          |||z  ¦  «        }| j        }	| j        | j        t$          j                 |z  k    rAt          | j        t$          j                 |z  d¦  «        | _        |                      ¦   «          |	| 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ÔLÑˆˆS�#�sÝÝŒI�NŠNÝ”åœ
 3¨¨Ñ-Ô-Øðñô ñô õ Œi�nŠnÝ”åœ
 3¨¨d©
°SÑ(8Ñ9Ô9Ø˜d™
 SÑ(ðñô ñô ñð  ñ#
ô 
ˆ	ð& —,’,˜tÑ$Ô$ˆå”I—N’NÝŒHàÔ&ØÔ&ØÔ)ØÔ)ð	ñô ñ	
ô 	
ˆ	õ ˆy‰>Œ>�D¥3 w¡<¤<Ñ/Ò/Ð/Ý˜I w°Ñ':Ñ;Ô;ˆIØœ/ˆàŒMØŒ�yÔCÔDØñòð õ  Ø”¥	Ô AÔBÀYÑNØñô ˆDŒMð ×ÒÑ!Ô!Ð!Ø $¤/Ò1Ð1r1   c                 ó†   — t          | j        |                      ¦   «         ¦  «        | _        |                      ¦   «          dS )z1
        Decrease the penalty parameter.
        N)rÃ   r   Ú_get_low_penaltyr   r4   s    r/   Údecrease_penaltyzTrustRegion.decrease_penalty±  s;   € õ ˜DœM¨4×+@Ò+@Ñ+BÔ+BÑCÔCˆŒØ×ÒÑÔÐÐÐr1   c           
      óâ  — | 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         ¦  «        }dt          z  t          | j        j        | j        j        ¦  «        z  t          t          |¦  «        d¦  «        z  }t          | j        j        ¦  «        D ]Û}|| j         k    rÎ| j        j                             |¦  «        }|                      || j        j        |         | j        j        |dd…f         | j        j        |dd…f         ¦  «        }| j                             || j        j        |dd…f         | j        j        |dd…f         ¦  «        }||k     s|||z   k     r||k     r|}|}|}ŒÜ|| _        dS )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Ô 
¨A¨A¨A Ô.ØŒKÔ 
¨A¨A¨A Ô.ñ	
ô 
ˆð ”—’ØŒKØŒKÔ 
¨A¨A¨A Ô.ØŒKÔ 
¨A¨A¨A Ô.ñ
ô 
ˆð Ýñå�$”+”- ¤¤Ñ1Ô1ñ2õ •#�f‘+”+˜sÑ#Ô#ñ$ð 	õ �t”{”Ñ'Ô'ð 	#ð 	#ˆAØ�D”OÒ#Ð#ØœÔ1×7Ò7¸Ñ:Ô:�ØŸ
š
ØØ”KÔ'¨Ô*Ø”KÔ'¨¨1¨1¨1¨Ô-Ø”KÔ'¨¨1¨1¨1¨Ô-ñ	ô �ð œŸšØØ”KÔ'¨¨1¨1¨1¨Ô-Ø”KÔ'¨¨1¨1¨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}|}nr| 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Ð0NÔOñPð ñ	ð
 ð
ñ 
ô 
ˆð ˆ=ØˆEØˆGˆGà”K×,Ò,¨UÑ3Ô3ˆEå”
ØØÝØœ­	Ô(CÔDØœ+ñ&àœñô ð
 ñññ	ô 	ð ñ
ð ð (,ˆG�D”OÑ$Ý”	˜'¥B¤F¨5¡M¤MÑ1Ñ2Ô2ˆØ•b”g˜g eœnÑ-Ô-Ð-Ð-r1   c                 óP  — t           j                             |¦  «        }|| j        t          j                 k    r'| xj        | j        t          j                 z  c_        dS || j        t          j                 k    r4t          | j        t          j                 | j        z  |¦  «        | _        dS t          | j        t          j                 | j        z  t          | j        t          j                 | j        z  | j        t          j                 |z  ¦  «        ¦  «        | _        dS )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¥IÔ$7Ô8Ò8Ð8ØˆKŒK˜4œ?­9Ô+KÔLÑLˆKŒKˆKˆKØ�d”o¥iÔ&:Ô;Ò;Ð;ÝØ”¥	Ô @ÔAØ”+ñàñô ˆDŒKˆKˆKõ Ø”¥	Ô @ÔAØ”+ñåØ”O¥IÔ$DÔEØ”kñ"à”O¥IÔ$GÔHØññô ñ	ô 	ˆDŒKˆKˆKr1   c                 ó  — | j         t          j                 |t          j                 z  | j        k     r&| xj        | j         t          j                 z  c_        n|| j         t          j                 |t          j                 z  | j        k     r2t          j	        | j        |t          j                 z  ¦  «        | _        n|t          j                 | _        t          | j         t          j                 | j        z  | j        ¦  «        | _        dS )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�IÔ@ÔAØ•g”nÔ%ñ&àŒoòð ð ˆOŒO˜tœÝÔ4ô ñ ˆOŒOˆOð ŒO�IÔCÔDØ•g”nÔ%ñ&àŒoòð õ !œg d¤oØ(/µ´Ô(?ñ'@ñ Aô AˆDŒOˆOð &¥g¤nÔ5ˆDŒOõ ØŒO�IÔ<Ô=ÀÄÑLØŒOñ
ô 
ˆŒˆˆr1   c                 ój   — | j                              t          j        | j        ¦  «        |¦  «         dS )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Ô!5°wÑ?Ô?Ð?Ð?Ð?r1   c           	      óD  — | 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k    �rÙt          j        | j         j        ¦  «        }
t          j        |
|dd…f          |
|dd…f         | j         j        j        |dd…f         | j                             ||¦  «        | j         j        j        | j                             |¦  «        f         }| j                             |¦  «        }t          j        |j        d         t          j         ¦  «        }d|d||	z   |z   |z   …<   t/          |j        | |t          j        fd¬¦  «        }|j        ||	z   ||	z   |z   …         | j        |<   d| j        | <   |j        ||	z   |z   ||	z   |z   |z   …         | j        |<   d| j        | <   |j        ||	z   |z   |z   ||	z   |z   |z   | j
        z   …         | j        dd…<   |j        ||	z   |z   |z   | j
        z   d…         | j        dd…<   dS dS )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´_Ô5IÒIˆØ œM¨SÒ0ÐØ”(”/Ô$¨Ò)ˆØ”(”/Ô$¨Ò)ˆÝÔ& ~Ñ6Ô6ˆÝÔ)Ð*;Ñ<Ô<ˆÝÔ Ñ(Ô(ˆÝÔ Ñ(Ô(ˆð ˜.Ñ(¨4Ô+;Ñ;ØÔ%ñ&Ø()ò*ñ *õ ”v˜dœhœjÑ)Ô)ˆHÝ”EØ˜' 1 1 1˜*Ô%Ð%Ø˜ ! ! !˜Ô$Ø””Ô$ ^°Q°Q°QÐ%6Ô7Ø”×$Ò$ QÐ(9Ñ:Ô:Ø””Ô$Ø”×$Ò$ QÑ'Ô'ð)ôˆEð ”[×)Ò)¨!Ñ,Ô,ˆFÝ”G˜EœK¨œN­R¬V¨GÑ4Ô4ˆEØBEˆEÐ>�D˜4‘K +Ñ-°Ñ>Ð>Ñ?ÝØ”Ø�Ø�rœv�Øð	ñ ô ˆCð 25´Ø�t‘˜D 4™K¨+Ñ5Ð5ô2ˆDÔ˜~Ñ.ð 36ˆDÔ ˜Ñ/Ø7:´uØØñàñà"Øñàñð !ñ!ð!ô8ˆDÔ!Ð"3Ñ4ð 9<ˆDÔ!Ð#4Ð"4Ñ5Ø$'¤EØØñàñð !ñ!ð "&Øñ"àñ"ð !ñ"!ð Ô"ñ	"#ð#ô	%ˆDÔ˜q˜q˜qÑ!ð (+¤uØ�t‘˜kÑ)¨NÑ:¸TÔ=MÑMÐNÐ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          j        d||         ¦  «        }	t          j        ||         |	z
  ¦  «        }
|
t4          ||z
  z  k    r	||z
  |
z  }nt           j        }n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°  s  € Ý”5à”Ô)Ô0µ´¸Q¸Q¸Q°Ô?Ø”+Ô+Ô/Ô1ñ2ð ŒhŒoÔ"Ô$ñ	%ð
 ŒhŒoÔ"¥2¤:¨q¨q¨q =Ô1ñ2ð ŒKÔð!ô
ˆð ŒKÔ%Ô,­R¬Z¸¸¸¨]Ô;ØŒkÔ'Ô+Ô-ñ.àŒHŒOÔ Ô"ñ#ð &*¤X¤_Ô%9½"¼*ÀaÀaÀa¸-Ô%HñIˆõ ”8àØ�	Ø”Ô#Ø”Ô$Ð$ð	ñ
ô 
ˆõ ”˜( HÐ-Ñ.Ô.ˆÝ”	˜% aÐ(Ñ(Ô(ˆÝ”	˜% aÐ(Ñ(Ô(ˆàØŒo�iÔCÔDÀuÑLòMð 	õ Œ6�'‰?Œ?ð 
	Ý”I˜dœkÔ1Ñ2Ô2ˆEÝ”I˜dœkÔ1Ñ2Ô2ˆEÝœ
 3¨¨g¬Ñ7Ô7ˆIÝ”V˜E 'œN¨YÑ6Ñ7Ô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      sb  € € € € € ðð ð.'ð .'ð .'ð` ð	ð 	ñ „Xð	ð ð	$ð 	$ñ „Xð	$ð ð	$ð 	$ñ „Xð	$ð ð	'ð 	'ñ „Xð	'ð ð	'ð 	'ñ „Xð	'ð ð	ð 	ñ „Xð	ð „]ð+ð +ñ „]ð+ð" ð ð  ñ „Xð ð Ôð	&ð 	&ñ Ôð	&ð ð	ð 	ñ „Xð	ð ð	ð 	ñ „Xð	ð ð	 ð 	 ñ „Xð	 ð ð@ð @ñ „Xð@ð ð	4ð 	4ñ „Xð	4ð ð	7ð 	7ñ „Xð	7ð ð	7ð 	7ñ „Xð	7ð
ð 
ð 
ð0
ð 
ð 
ð,ð ð ð 
ð 
ð 
ð.
ð 
ð 
ð*
ð 
ð 
ð(
ð 
ð 
ð*
ð 
ð 
ð*ð ð ð ð@,"ð ,"ð ,"ð\r,ð r,ð r,ðhUð Uð Uðn0ð 0ð 0ðd.ð .ð .ð`62ð 62ð 62ðpð ð ð(&ð (&ð (&ðT5.ð 5.ð 5.ð 5.ðnð ð ð@
ð 
ð 
ðB	@ð 	@ð 	@ðIð Ið 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*  ðØ €€€à Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (ðð ð ð ð ð ð ð ð ð ð ð ð ð ð :Ð 9Ð 9Ð 9Ð 9Ð 9Ø !Ð !Ð !Ð !Ð !Ð !ð €r„x��„Ô€Ø€b„hˆu�o„oÔ€ðAð Að Að Að Añ Aô Að Að Að Ar1   