Ë
    âQ(hàÅ  ã                   óÈ   — d dl Z d dlZd dlmZ ddlmZ ddlmZm	Z	m
Z
  ej                  e«      j                  Z G d„ d«      ZdddddœZd	„ Z G d
„ d«      Z G d„ d«      Zy)é    N)Úeighé   )ÚOptions)ÚMaxEvalErrorÚTargetSuccessÚFeasibleSuccessc                   ó¤   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zej                  d„ «       Zed„ «       Z
e
j                  d„ «       Z
d	„ Zy
)ÚInterpolationz×
    Interpolation set.

    This class stores a base point around which the models are expanded and the
    interpolation points. The coordinates of the interpolation points are
    relative to the base point.
    c                 ó"  — |t         j                     | _        dt        j                  |j
                  j                  |j
                  j                  z
  «      z  }|t         j                     |kD  r`||t         j                  j                  <   t        j                  |t         j                     |g«      |t         j                  j                  <   t        j                  |j                  «      | _        | j                  |j
                  j                  d|t         j                     z  z   k  }|j
                  j                  |   | j                  |<   |j
                  j                  d|t         j                     z  z   | j                  k  | j                  |j
                  j                  |t         j                     z   k  z  }t        j                  |j
                  j                  |   |t         j                     z   |j
                  j                  |   «      | j                  |<   | j                  |j
                  j                  d|t         j                     z  z
  k\  }|j
                  j                  |   | j                  |<   | j                  |j
                  j                  d|t         j                     z  z
  k  |j
                  j                  |t         j                     z
  | j                  k  z  }t        j                   |j
                  j                  |   |t         j                     z
  |j
                  j                  |   «      | j                  |<   t        j"                  |j$                  |t         j&                     f«      | _        t+        d|t         j&                     «      D �]Ô  }||j$                  k  rU||dz
     r'|t         j                      | j,                  |dz
  |f<   ŒB|t         j                     | j,                  |dz
  |f<   Œh|d|j$                  z  k  rÌ|||j$                  z
  dz
     r6d|t         j                     z  | j,                  ||j$                  z
  dz
  |f<   ŒÅ|||j$                  z
  dz
     r7d|t         j                     z  | j,                  ||j$                  z
  dz
  |f<   �Œ|t         j                      | j,                  ||j$                  z
  dz
  |f<   �ŒF||j$                  z
  dz
  |j$                  z  }	|d|	z   |j$                  z  z
  dz
  }
|
|	z   |j$                  z  }| j,                  |
|
dz   f   | j,                  |
|f<   | j,                  ||dz   f   | j,                  ||f<   �Œ× y)zÜ
        Initialize the interpolation set.

        Parameters
        ----------
        pb : `cobyqa.problem.Problem`
            Problem to be solved.
        options : dict
            Options of the solver.
        ç      à?r   é   ç       @g       ÀN)r   ÚDEBUGÚ_debugÚnpÚminÚboundsÚxuÚxlÚRHOBEGÚvalueÚRHOENDÚcopyÚx0Ú_x_baseÚx_baseÚminimumÚmaximumÚzerosÚnÚNPTÚ_xptÚrangeÚxpt)ÚselfÚpbÚoptionsÚ
max_radiusÚvery_close_xl_idxÚclose_xl_idxÚvery_close_xu_idxÚclose_xu_idxÚkÚspreadÚk1Úk2s               úV/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/_lib/cobyqa/models.pyÚ__init__zInterpolation.__init__   sO  € ð œgŸm™mÑ,ˆŒØœ2Ÿ6™6 "§)¡)§,¡,°·±·±Ñ"=Ó>Ñ>ˆ
Ø”7—>‘>Ñ" ZÒ/Ø,6ˆG”G—N‘N×(Ñ(Ñ)Ü,.¯F©FàœGŸN™NÑ+Øðó-ˆG”G—N‘N×(Ñ(Ñ)ô —w‘w˜rŸu™u“~ˆŒà�K‰K˜2Ÿ9™9Ÿ<™<¨#°¼¿¹Ñ0GÑ*GÑGÑGð 	ð *,¯©¯©Ð6GÑ)Hˆ�‰Ð%Ñ&à�I‰I�L‰L˜3 ¬¯©Ñ!8Ñ8Ñ8¸4¿;¹;ÑFØ�[‰[˜BŸI™IŸL™L¨7´7·>±>Ñ+BÑBÑBñDˆô %'§J¡JØ�I‰I�L‰L˜Ñ&¨´·±Ñ)@Ñ@Ø�I‰I�L‰L˜Ñ&ó%
ˆ�‰�LÑ!ð
 �K‰K˜2Ÿ9™9Ÿ<™<¨#°¼¿¹Ñ0GÑ*GÑGÑGð 	ð *,¯©¯©Ð6GÑ)Hˆ�‰Ð%Ñ&à�K‰K˜"Ÿ)™)Ÿ,™,¨¨w´w·~±~Ñ/FÑ)FÑFÑFØ�Y‰Y�\‰\˜G¤G§N¡NÑ3Ñ3°t·{±{ÑBñDˆô %'§J¡JØ�I‰I�L‰L˜Ñ&¨´·±Ñ)@Ñ@Ø�I‰I�L‰L˜Ñ&ó%
ˆ�‰�LÑ!ô —H‘H˜bŸd™d G¬G¯K©KÑ$8Ð9Ó:ˆŒ	Ü�q˜'¤'§+¡+Ñ.Ó/ó 	7ˆAØ�B—D‘DŠyØ$ Q¨¡UÒ+Ø*1´'·.±.Ñ*AÐ)A�D—H‘H˜Q ™U A˜XÒ&à)0´·±Ñ)@�D—H‘H˜Q ™U A˜XÒ&Ø�a˜"Ÿ$™$‘h’Ø$ Q¨¯©¡X°¡\Ò2Ø03°g¼g¿n¹nÑ6MÑ0M�D—H‘H˜Q §¡™X¨™\¨1˜_Ò-Ø& q¨2¯4©4¡x°!¡|Ò4Ø04°w¼w¿~¹~Ñ7NÑ0N�D—H‘H˜Q §¡™X¨™\¨1˜_Ó-à18¼¿¹Ñ1HÐ0H�D—H‘H˜Q §¡™X¨™\¨1˜_Ó-à˜bŸd™d™( Q™,¨2¯4©4Ñ/�Ø˜!˜f™*¨¯©Ñ,Ñ,¨qÑ0�Ø˜6‘k R§T¡TÑ)�Ø"&§(¡(¨2¨r°A©v¨:Ñ"6�—‘˜˜Q˜‘Ø"&§(¡(¨2¨r°A©v¨:Ñ"6�—‘˜˜Q˜“ñ%	7ó    c                 ó4   — | j                   j                  d   S )út
        Number of variables.

        Returns
        -------
        int
            Number of variables.
        r   ©r$   Úshape©r%   s    r1   r    zInterpolation.n\   ó   € ð �x‰x�~‰~˜aÑ Ð r3   c                 ó4   — | j                   j                  d   S )úŠ
        Number of interpolation points.

        Returns
        -------
        int
            Number of interpolation points.
        r   r6   r8   s    r1   ÚnptzInterpolation.npth   r9   r3   c                 ó   — | j                   S )z’
        Interpolation points.

        Returns
        -------
        `numpy.ndarray`, shape (n, npt)
            Interpolation points.
        )r"   r8   s    r1   r$   zInterpolation.xptt   s   € ð �y‰yÐr3   c                 ó‚   — | j                   r,|j                  | j                  | j                  fk(  sJ d«       ‚|| _        y)zª
        Set the interpolation points.

        Parameters
        ----------
        xpt : `numpy.ndarray`, shape (n, npt)
            New interpolation points.
        z The shape of `xpt` is not valid.N)r   r7   r    r<   r"   )r%   r$   s     r1   r$   zInterpolation.xpt€   sG   € ð �;Š;Ø—9‘9Ø—‘Ø—‘ð!ò ð 2ð 2ó2ð ð ˆ�	r3   c                 ó   — | j                   S )zÄ
        Base point around which the models are expanded.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Base point around which the models are expanded.
        )r   r8   s    r1   r   zInterpolation.x_base‘   s   € ð �|‰|Ðr3   c                 ól   — | j                   r!|j                  | j                  fk(  sJ d«       ‚|| _        y)zß
        Set the base point around which the models are expanded.

        Parameters
        ----------
        x_base : `numpy.ndarray`, shape (n,)
            New base point around which the models are expanded.
        z#The shape of `x_base` is not valid.N)r   r7   r    r   )r%   r   s     r1   r   zInterpolation.x_base�   s>   € ð �;Š;Ø—<‘<Ø—‘ð$ò ð 5à4ó5ð ð ˆ�r3   c                 ó¢   — | j                   r$d|cxk  r| j                  k  sJ d«       ‚ J d«       ‚| j                  | j                  dd…|f   z   S )a<  
        Get the `k`-th interpolation point.

        The return point is relative to the origin.

        Parameters
        ----------
        k : int
            Index of the interpolation point.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            `k`-th interpolation point.
        r   zThe index `k` is not valid.N)r   r<   r   r$   )r%   r-   s     r1   ÚpointzInterpolation.point­   sO   € ð  �;Š;Ø˜Ô$˜DŸH™HÒ$ÐCÐ&CÓCÑ$ÐCÐ&CÓCÐ$Ø�{‰{˜TŸX™X¢a¨ d™^Ñ+Ð+r3   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   Úpropertyr    r<   r$   Úsetterr   rB   © r3   r1   r
   r
      s“   „ ñòD7ðL ñ	!ó ð	!ð ñ	!ó ð	!ð ñ	ó ð	ð 	‡Z�Zñó ðð  ñ	ó ð	ð ‡]�]ñó ðó,r3   r
   )r$   ÚaÚright_scalingr   c                 ó¸  — t         d   �At        j                  | j                  t         d   «      rt         d   t         d   t         d   fS t        j                  t        j
                  j                  | j                  d¬«      t        ¬«      }| j                  |z  }|j                  \  }}t        j                  ||z   d	z   ||z   d	z   f«      }d
|j                  |z  dz  z  |d|…d|…f<   d|d|…|f<   |j                  |d|…|d	z   d…f<   d||d|…f<   |||d	z   d…d|…f<   t        j                  ||z   d	z   «      }d|dz  z  |d| |dz  ||<   |||d	z   d t        |d¬«      \  }}t        j                  | j                  «      t         d<   t        j                  |«      t         d<   t        j                  |«      t         d<   ||ft         d<   ||||ffS )a‰  
    Build the left-hand side matrix of the interpolation system. The
    matrix below stores W * diag(right_scaling),
    where W is the theoretical matrix of the interpolation system. The
    right scaling matrices is chosen to keep the elements in
    the matrix well-balanced.

    Parameters
    ----------
    interpolation : `cobyqa.models.Interpolation`
        Interpolation set.
    r$   NrJ   rK   r   r   )Úaxis©Úinitialr   r   r   ç      ð?F)Úcheck_finite)Ú_cacher   Úarray_equalr$   ÚmaxÚlinalgÚnormÚEPSr7   r   ÚTÚemptyr   r   )	ÚinterpolationÚscaleÚ	xpt_scaler    r<   rJ   rK   Ú
eig_valuesÚeig_vectorss	            r1   Úbuild_systemr_   Å   sá  € ô" ˆe�}Ð ¤R§^¡^Ø×Ñœ6 %™=ô&ô �c‰{œF ?Ñ3´V¸F±^ÐCÐCä�F‰F”2—9‘9—>‘> -×"3Ñ"3¸!�>Ó<ÄcÔJ€EØ×!Ñ! EÑ)€Ià�_‰_�F€A€sÜ
�‰�#˜‘'˜A‘+˜s Q™w¨™{Ð+Ó,€AØ˜9Ÿ;™;¨Ñ2°sÑ:Ñ:€A€d€s€dˆDˆSˆD€j�MØ€A€d€s€dˆC€i�LØ!Ÿ™€A€d€s€dˆC�!‰G‰H€nÑØ€A€cˆ4ˆCˆ4€i�LØ!€A€cˆA�g�h���€nÑô —H‘H˜S 1™W q™[Ó)€MØ  s¡
Ñ*€M�$�3ÐØ ™€M�#ÑØ#€M�#˜‘'�(Ðä" 1°5Ô9Ñ€J�ä—G‘G˜M×-Ñ-Ó.„Fˆ5�MÜ—'‘'˜!“*„Fˆ3�KÜ Ÿg™g mÓ4„Fˆ?ÑØ  +Ð.„Fˆ6�Nàˆm˜j¨+Ð6Ð6Ð6r3   c                   ó€   — e Zd ZdZd„ Zd„ Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zed„ «       Zed„ «       Zy)Ú	Quadratica:  
    Quadratic model.

    This class stores the Hessian matrix of the quadratic model using the
    implicit/explicit representation designed by Powell for NEWUOA [1]_.

    References
    ----------
    .. [1] M. J. D. Powell. The NEWUOA software for unconstrained optimization
       without derivatives. In G. Di Pillo and M. Roma, editors, *Large-Scale
       Nonlinear Optimization*, volume 83 of Nonconvex Optim. Appl., pages
       255--297. Springer, Boston, MA, USA, 2006. `doi:10.1007/0-387-30065-1_16
       <https://doi.org/10.1007/0-387-30065-1_16>`_.
    c                 óˆ  — || _         | j                   r!|j                  |j                  fk(  sJ d«       ‚|j                  |j                  dz   k  rt	        d|j                  dz   › d�«      ‚| j                  ||«      \  | _        | _        | _        }t        j                  | j                  | j                  f«      | _        y)aú  
        Initialize the quadratic model.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.
        values : `numpy.ndarray`, shape (npt,)
            Values of the interpolated function at the interpolation points.
        debug : bool
            Whether to make debugging tests during the execution.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        ú#The shape of `values` is not valid.r   z4The number of interpolation points must be at least ú.N)r   r7   r<   r    Ú
ValueErrorÚ
_get_modelÚ_constÚ_gradÚ_i_hessr   r   Ú_e_hess)r%   rZ   ÚvaluesÚdebugÚ_s        r1   r2   zQuadratic.__init__  sÁ   € ð$ ˆŒØ�;Š;Ø—<‘<Ø×!Ñ!ð$ò ð 5à4ó5ð ð ×Ñ˜}Ÿ™°Ñ2Ò2ÜØFØ —?‘? QÑ&Ð' qð*óð ð 48·?±?ØØó4
Ñ0ˆŒ�T”Z ¤¨qô —x‘x §¡¨¯©Ð 0Ó1ˆ�r3   c                 ó2  — | j                   r!|j                  | j                  fk(  sJ d«       ‚||j                  z
  }| j                  | j
                  |z  z   d| j                  |j                  j                  |z  dz  z  || j                  z  |z  z   z  z   S )a�  
        Evaluate the quadratic model at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which the quadratic model is evaluated.
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.

        Returns
        -------
        float
            Value of the quadratic model at `x`.
        úThe shape of `x` is not valid.r   r   )
r   r7   r    r   rg   rh   ri   r$   rX   rj   ©r%   ÚxrZ   Úx_diffs       r1   Ú__call__zQuadratic.__call__(  s›   € ð  �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�]×)Ñ)Ñ)ˆà�K‰KØ�j‰j˜6Ñ!ñ"àà—‘ × 1Ñ 1× 3Ñ 3°fÑ <ÀÑDÑDØ˜4Ÿ<™<Ñ'¨&Ñ0ñ1ññð	
r3   c                 ó.   — | j                   j                  S )r5   )rh   Úsizer8   s    r1   r    zQuadratic.nE  s   € ð �z‰z�‰Ðr3   c                 ó.   — | j                   j                  S )zÐ
        Number of interpolation points used to define the quadratic model.

        Returns
        -------
        int
            Number of interpolation points used to define the quadratic model.
        )ri   ru   r8   s    r1   r<   zQuadratic.nptQ  s   € ð �|‰|× Ñ Ð r3   c                 ó¸   — | j                   r!|j                  | j                  fk(  sJ d«       ‚||j                  z
  }| j                  | j                  ||«      z   S )aº  
        Evaluate the gradient of the quadratic model at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which the gradient of the quadratic model is evaluated.
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Gradient of the quadratic model at `x`.
        ro   )r   r7   r    r   rh   Ú	hess_prodrp   s       r1   ÚgradzQuadratic.grad]  sS   € ð  �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�]×)Ñ)Ñ)ˆØ�z‰z˜DŸN™N¨6°=ÓAÑAÐAr3   c                 ó¦   — | j                   |j                  | j                  dd…t        j                  f   |j                  j
                  z  z  z   S )a;  
        Evaluate the Hessian matrix of the quadratic model.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.

        Returns
        -------
        `numpy.ndarray`, shape (n, n)
            Hessian matrix of the quadratic model.
        N)rj   r$   ri   r   ÚnewaxisrX   )r%   rZ   s     r1   ÚhesszQuadratic.hessr  sG   € ð �|‰|˜m×/Ñ/Ø�L‰LšœBŸJ™J˜Ñ'¨-×*;Ñ*;×*=Ñ*=Ñ=ñ
ñ 
ð 	
r3   c                 óâ   — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  |z  |j                  | j
                  |j                  j                  |z  z  z  z   S )a.  
        Evaluate the right product of the Hessian matrix of the quadratic model
        with a given vector.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Vector with which the Hessian matrix of the quadratic model is
            multiplied from the right.
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Right product of the Hessian matrix of the quadratic model with
            `v`.
        úThe shape of `v` is not valid.)r   r7   r    rj   r$   ri   rX   ©r%   ÚvrZ   s      r1   rx   zQuadratic.hess_prod„  si   € ð& �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�|‰|˜aÑ -×"3Ñ"3Ø�L‰L˜M×-Ñ-×/Ñ/°!Ñ3Ñ4ñ#
ñ 
ð 	
r3   c                 óÔ   — | j                   r!|j                  | j                  fk(  sJ d«       ‚|| j                  z  |z  | j                  |j
                  j                  |z  dz  z  z   S )aÄ  
        Evaluate the curvature of the quadratic model along a given direction.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Direction along which the curvature of the quadratic model is
            evaluated.
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.

        Returns
        -------
        float
            Curvature of the quadratic model along `v`.
        r~   r   )r   r7   r    rj   ri   r$   rX   r   s      r1   ÚcurvzQuadratic.curv�  sf   € ð" �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'à�—‘Ñ˜qÑ Ø�l‰l˜m×/Ñ/×1Ñ1°AÑ5¸#Ñ=Ñ=ñ>ð	
r3   c                 ó&  — | j                   rfd|cxk  r| j                  k  sJ d«       ‚ J d«       ‚|j                  | j                  fk(  sJ d«       ‚|j                  | j                  fk(  sJ d«       ‚| xj                  | j
                  |   t        j                  ||«      z  z  c_        d| j
                  |<   | j                  ||«      \  }}}}| xj                  |z  c_	        | xj                  |z  c_
        | xj
                  |z  c_        |S )a�  
        Update the quadratic model.

        This method applies the derivative-free symmetric Broyden update to the
        quadratic model. The `knew`-th interpolation point must be updated
        before calling this method.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Updated interpolation set.
        k_new : int
            Index of the updated interpolation point.
        dir_old : `numpy.ndarray`, shape (n,)
            Value of ``interpolation.xpt[:, k_new]`` before the update.
        values_diff : `numpy.ndarray`, shape (npt,)
            Differences between the values of the interpolated nonlinear
            function and the previous quadratic model at the updated
            interpolation points.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        r   úThe index `k_new` is not valid.z$The shape of `dir_old` is not valid.z(The shape of `values_diff` is not valid.ç        )r   r<   r7   r    rj   ri   r   Úouterrf   rg   rh   )	r%   rZ   Úk_newÚdir_oldÚvalues_diffÚconstry   Úi_hessÚill_conditioneds	            r1   ÚupdatezQuadratic.updateµ  s  € ð4 �;Š;Ø˜Ô( §¡Ò(ÐKÐ*KÓKÑ(ÐKÐ*KÓKÐ(Ø—=‘=Ø—‘ð%ò ð 6à5ó6ð ð ×$Ñ$Ø—‘ð)ò ð :à9ó:ð ð 	�Š˜Ÿ™ UÑ+¬b¯h©h°wÀÓ.HÑHÑH�Ø!ˆ�‰�UÑð 04¯©ØØó0
Ñ,ˆˆt�V˜_ð 	�Š�uÑ�Ø�
Š
�dÑ�
Ø�Š˜Ñ�ØÐr3   c                 óš  — | j                   r!|j                  | j                  fk(  sJ d«       ‚ | ||«      | _        | j	                  ||«      | _        ||j                  z
  }t        j                  ||j                  d|dd…t        j                  f   z  z
  | j                  z  «      }| xj                  ||j                  z   z  c_        y)aB  
        Shift the point around which the quadratic model is defined.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Previous interpolation set.
        new_x_base : `numpy.ndarray`, shape (n,)
            Point that will replace ``interpolation.x_base``.
        ú'The shape of `new_x_base` is not valid.r   N)r   r7   r    rg   ry   rh   r   r   r†   r$   r{   ri   rj   rX   )r%   rZ   Ú
new_x_baseÚshiftr�   s        r1   Úshift_x_basezQuadratic.shift_x_baseé  s¼   € ð �;Š;Ø×#Ñ#Ø—‘ð(ò ð 9à8ó9ð ñ ˜: }Ó5ˆŒØ—Y‘Y˜z¨=Ó9ˆŒ
Ø˜]×1Ñ1Ñ1ˆÜ—‘ØØ×Ñ  uªQ´·
±
¨]Ñ';Ñ!;Ñ;¸t¿|¹|ÑKó
ˆð 	�Š˜ §¡Ñ)Ñ)Žr3   c                 óÞ  — | j                   j                  \  }}|j                  dk(  r|j                  d   ||z   dz   k(  sJ d«       ‚t        | «      \  }}}||dd…t        j
                  f   z  }t	        j                  t	        j                  |«      «      r(t	        j                  t	        j                  |«      «      st        j                  j                  d«      ‚|\  }}	t	        j                  |«      t        kD  }
|	dd…|
f   }	d||
   z  }t	        j                  |
d«       }|	|	j                  |z  |dd…t        j
                  f   z  z  }||dd…t        j
                  f   z  |fS )a•  
        Solve the interpolation systems.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.
        rhs : `numpy.ndarray`, shape (npt + n + 1, m)
            Right-hand side vectors of the ``m`` interpolation systems.

        Returns
        -------
        `numpy.ndarray`, shape (npt + n + 1, m)
            Solutions of the interpolation systems.
        `numpy.ndarray`, shape (m, )
            Whether the interpolation systems are ill-conditioned.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation systems are ill-defined.
        r   r   r   z The shape of `rhs` is not valid.Nz(The interpolation system is ill-defined.rP   )r$   r7   Úndimr_   r   r{   ÚallÚisfiniterU   ÚLinAlgErrorÚabsrW   rX   )rZ   Úrhsr    r<   rJ   rK   ÚeigÚ
rhs_scaledr]   r^   Úlarge_eig_valuesÚinv_eig_valuesrŒ   Úleft_scaled_solutionss                 r1   Úsolve_systemszQuadratic.solve_systems  sZ  € ð0 ×"Ñ"×(Ñ(‰ˆˆ3à�H‰H˜ŠM˜cŸi™i¨™l¨c°A©g¸©kÒ9ð	.à-ó	.Ø9ô !-¨]Ó ;Ñˆˆ=˜#ð ˜=ª¬B¯J©J¨Ñ7Ñ7ˆ
Ü—‘”r—{‘{ 1“~Ô&¬2¯6©6´"·+±+¸jÓ2IÔ+JÜ—)‘)×'Ñ'Ø:óð ð
 #&Ñˆ
�KäŸ6™6 *Ó-´Ñ3ÐØ!¢!Ð%5Ð"5Ñ6ˆØ˜zÐ*:Ñ;Ñ;ˆÜŸ6™6Ð"2°AÓ6Ð6ˆØ +Ø�]‰]˜ZÑ'¨>º!¼R¿Z¹Z¸-Ñ+HÑHñ!
Ðð " M²!´R·Z±Z°-Ñ$@Ñ@Øð
ð 	
r3   c           
      óL  — |j                   | j                  fk(  sJ d«       ‚| j                  j                   \  }}t        j	                  | t        j                  |t        j                  |dz   «      gg«      j                  «      \  }}||df   ||dz   d…df   |d|…df   |fS )aÓ  
        Solve the interpolation system.

        Parameters
        ----------
        interpolation : `cobyqa.models.Interpolation`
            Interpolation set.
        values : `numpy.ndarray`, shape (npt,)
            Values of the interpolated function at the interpolation points.

        Returns
        -------
        float
            Constant term of the quadratic model.
        `numpy.ndarray`, shape (n,)
            Gradient of the quadratic model at ``interpolation.x_base``.
        `numpy.ndarray`, shape (npt,)
            Implicit Hessian matrix of the quadratic model.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        rc   r   r   N)	r7   r<   r$   ra   rŸ   r   Úblockr   rX   )rZ   rk   r    r<   rq   rŒ   s         r1   rf   zQuadratic._get_modelB  sÃ   € ð4 �|‰|Ø×Ñð 
ò 
ð 	1à0ó	1ð 
ð ×"Ñ"×(Ñ(‰ˆˆ3Ü&×4Ñ4ØÜ�H‰Hð ÜŸ™  Q¡›ððó÷ ‰aó

Ñˆˆ?ð ��a�‰y˜!˜C !™G™H a˜K™.¨!¨D¨S¨D°!¨G©*°oÐEÐEr3   N)rC   rD   rE   rF   r2   rs   rG   r    r<   ry   r|   rx   r‚   r�   r’   ÚstaticmethodrŸ   rf   rI   r3   r1   ra   ra   ö   s…   „ ñò 2òD
ð: ñ	ó ð	ð ñ	!ó ð	!òBò*
ò$
ò2
ò02òh*ð0 ñ>
ó ð>
ð@ ñ(Fó ñ(Fr3   ra   c                   ó:  — 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d	„ «       Zed
„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd#d„Zd„ Zd„ Zd#d„Z d„ Z!d#d „Z"d#d!„Z#d"„ Z$y)$ÚModelsz6
    Models for a nonlinear optimization problem.
    c           	      ó¦  — |t         j                     | _        t        ||«      | _        | j
                  j                  d«      } |||«      \  }}}t        j                  |t         j                     t        j                  «      | _        t        j                  |t         j                     |j                  ft        j                  «      | _        t        j                  |t         j                     |j                  ft        j                  «      | _        t        |t         j                     «      D �]²  }||t         j                      k\  rt"        ‚|dk(  r6|| j$                  |<   || j&                  |dd…f<   || j(                  |dd…f<   nW| j
                  j                  |«      } |||«      \  | j$                  |<   | j&                  |dd…f<   | j(                  |dd…f<   |j*                  rh|j-                  | j
                  j                  |«      | j&                  |dd…f   | j(                  |dd…f   «      |t         j.                     k  rt0        ‚| j                  |   |t         j2                     k  s�ŒK|j-                  | j
                  j                  |«      | j&                  |dd…f   | j(                  |dd…f   «      |t         j.                     k  s�Œ¯t4        ‚ t7        | j
                  | j                  |t         j                     «      | _        t        j:                  | j<                  t6        ¬«      | _        t        j:                  | j@                  t6        ¬«      | _!        t        | j<                  «      D ]H  }	t7        | j
                  | j&                  dd…|	f   |t         j                     «      | j>                  |	<   ŒJ t        | j@                  «      D ]H  }	t7        | j
                  | j(                  dd…|	f   |t         j                     «      | jB                  |	<   ŒJ | j                  r| jE                  «        yy)aE  
        Initialize the models.

        Parameters
        ----------
        pb : `cobyqa.problem.Problem`
            Problem to be solved.
        options : dict
            Options of the solver.
        penalty : float
            Penalty parameter used to select the point in the filter to forward
            to the callback function.

        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 interpolation system is ill-defined.
        r   N)Údtype)#r   r   r   r
   Ú_interpolationrZ   rB   r   Úfullr!   ÚnanÚ_fun_valru   Ú_cub_valÚ_ceq_valr#   ÚMAX_EVALr   Úfun_valÚcub_valÚceq_valÚis_feasibilityÚmaxcvÚFEASIBILITY_TOLr   ÚTARGETr   ra   Ú_funrY   Úm_nonlinear_ubÚ_cubÚm_nonlinear_eqÚ_ceqÚ_check_interpolation_conditions)
r%   r&   r'   ÚpenaltyÚx_evalÚfun_initÚcub_initÚceq_initr-   Úis
             r1   r2   zModels.__init__s  sx  € ð6 œgŸm™mÑ,ˆŒÜ+¨B°Ó8ˆÔð ×#Ñ#×)Ñ)¨!Ó,ˆÙ')¨&°'Ó':Ñ$ˆ�(˜HÜŸ™ ¬¯©Ñ 4´b·f±fÓ=ˆŒÜŸ™ ¬¯©Ñ!5°x·}±}Ð EÄrÇvÁvÓNˆŒÜŸ™ ¬¯©Ñ!5°x·}±}Ð EÄrÇvÁvÓNˆŒÜ�wœwŸ{™{Ñ+Ó,ó &	$ˆAØ�GœG×,Ñ,Ñ-Ò-Ü"Ð"Ø�AŠvØ"*�—‘˜Q‘Ø%-�—‘˜Q¢˜TÑ"Ø%-�—‘˜Q¢˜TÒ"à×+Ñ+×1Ñ1°!Ó4�ÙJLØØóKÑG�—‘˜Q‘ §¡¨a²¨dÑ!3°T·\±\À!ÂQÀ$Ñ5Gð ×!Ò!Ø—H‘HØ×&Ñ&×,Ñ,¨QÓ/Ø—L‘L ¢A Ñ&Ø—L‘L ¢A Ñ&óð
 œ7×2Ñ2Ñ3ò4ô &Ð%ð
 —‘˜aÑ  G¬G¯N©NÑ$;Ô;Ø—H‘HØ×&Ñ&×,Ñ,¨QÓ/Ø—L‘L ¢A Ñ&Ø—L‘L ¢A Ñ&óð
 œ7×2Ñ2Ñ3ô4ô $Ð#ðM&	$ôR Ø×ÑØ�M‰MØ”G—M‘MÑ"ó
ˆŒ	ô
 —H‘H˜T×0Ñ0¼	ÔBˆŒ	Ü—H‘H˜T×0Ñ0¼	ÔBˆŒ	Ü�t×*Ñ*Ó+ò 	ˆAÜ$Ø×"Ñ"Ø—‘šQ ˜TÑ"ØœŸ™Ñ&óˆD�I‰I�aŠLð	ô �t×*Ñ*Ó+ò 	ˆAÜ$Ø×"Ñ"Ø—‘šQ ˜TÑ"ØœŸ™Ñ&óˆD�I‰I�aŠLð	ð �;Š;Ø×0Ñ0Õ2ð r3   c                 ó.   — | j                   j                  S )z~
        Dimension of the problem.

        Returns
        -------
        int
            Dimension of the problem.
        )rZ   r    r8   s    r1   r    zModels.nÖ  s   € ð ×!Ñ!×#Ñ#Ð#r3   c                 ó.   — | j                   j                  S )r;   )rZ   r<   r8   s    r1   r<   z
Models.nptâ  s   € ð ×!Ñ!×%Ñ%Ð%r3   c                 ó4   — | j                   j                  d   S )z¢
        Number of nonlinear inequality constraints.

        Returns
        -------
        int
            Number of nonlinear inequality constraints.
        r   )r¯   r7   r8   s    r1   r¶   zModels.m_nonlinear_ubî  ó   € ð �|‰|×!Ñ! !Ñ$Ð$r3   c                 ó4   — | j                   j                  d   S )zž
        Number of nonlinear equality constraints.

        Returns
        -------
        int
            Number of nonlinear equality constraints.
        r   )r°   r7   r8   s    r1   r¸   zModels.m_nonlinear_eqú  rÄ   r3   c                 ó   — | j                   S )zŠ
        Interpolation set.

        Returns
        -------
        `cobyqa.models.Interpolation`
            Interpolation set.
        )r§   r8   s    r1   rZ   zModels.interpolation  s   € ð ×"Ñ"Ð"r3   c                 ó   — | j                   S )zà
        Values of the objective function at the interpolation points.

        Returns
        -------
        `numpy.ndarray`, shape (npt,)
            Values of the objective function at the interpolation points.
        )rª   r8   s    r1   r®   zModels.fun_val  s   € ð �}‰}Ðr3   c                 ó   — | j                   S )a1  
        Values of the nonlinear inequality constraint functions at the
        interpolation points.

        Returns
        -------
        `numpy.ndarray`, shape (npt, m_nonlinear_ub)
            Values of the nonlinear inequality constraint functions at the
            interpolation points.
        )r«   r8   s    r1   r¯   zModels.cub_val  ó   € ð �}‰}Ðr3   c                 ó   — | j                   S )a-  
        Values of the nonlinear equality constraint functions at the
        interpolation points.

        Returns
        -------
        `numpy.ndarray`, shape (npt, m_nonlinear_eq)
            Values of the nonlinear equality constraint functions at the
            interpolation points.
        )r¬   r8   s    r1   r°   zModels.ceq_val,  rÉ   r3   c                 ó”   — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  || j                  «      S )a�  
        Evaluate the quadratic model of the objective function at a given
        point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the quadratic model of the objective
            function.

        Returns
        -------
        float
            Value of the quadratic model of the objective function at `x`.
        ro   )r   r7   r    rµ   rZ   ©r%   rq   s     r1   Úfunz
Models.fun:  s@   € ð  �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�y‰y˜˜D×.Ñ.Ó/Ð/r3   c                 ó¨   — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  j	                  || j
                  «      S )aÆ  
        Evaluate the gradient of the quadratic model of the objective function
        at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the gradient of the quadratic model of
            the objective function.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Gradient of the quadratic model of the objective function at `x`.
        ro   )r   r7   r    rµ   ry   rZ   rÌ   s     r1   Úfun_gradzModels.fun_gradN  sD   € ð  �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�y‰y�~‰~˜a ×!3Ñ!3Ó4Ð4r3   c                 óL   — | j                   j                  | j                  «      S )zû
        Evaluate the Hessian matrix of the quadratic model of the objective
        function.

        Returns
        -------
        `numpy.ndarray`, shape (n, n)
            Hessian matrix of the quadratic model of the objective function.
        )rµ   r|   rZ   r8   s    r1   Úfun_hesszModels.fun_hessb  s   € ð �y‰y�~‰~˜d×0Ñ0Ó1Ð1r3   c                 ó¨   — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  j	                  || j
                  «      S )a'  
        Evaluate the right product of the Hessian matrix of the quadratic model
        of the objective function with a given vector.

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

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Right product of the Hessian matrix of the quadratic model of the
            objective function with `v`.
        r~   )r   r7   r    rµ   rx   rZ   ©r%   r€   s     r1   Úfun_hess_prodzModels.fun_hess_prodn  sF   € ð" �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�y‰y×"Ñ" 1 d×&8Ñ&8Ó9Ð9r3   c                 ó¨   — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  j	                  || j
                  «      S )aÑ  
        Evaluate the curvature of the quadratic model of the objective function
        along a given direction.

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

        Returns
        -------
        float
            Curvature of the quadratic model of the objective function along
            `v`.
        r~   )r   r7   r    rµ   r‚   rZ   rÓ   s     r1   Úfun_curvzModels.fun_curvƒ  sD   € ð" �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�y‰y�~‰~˜a ×!3Ñ!3Ó4Ð4r3   c                 óê   — | j                   r!|j                  | j                  fk(  sJ d«       ‚t        | j                  | j
                  | j                   «      }|j                  || j                  «      S )ap  
        Evaluate the gradient of the alternative quadratic model of the
        objective function at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the gradient of the alternative
            quadratic model of the objective function.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Gradient of the alternative quadratic model of the objective
            function at `x`.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        ro   )r   r7   r    ra   rZ   r®   ry   )r%   rq   Úmodels      r1   Úfun_alt_gradzModels.fun_alt_grad˜  s\   € ð, �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ü˜$×,Ñ,¨d¯l©l¸D¿K¹KÓHˆØ�z‰z˜!˜T×/Ñ/Ó0Ð0r3   Nc           	      ó2  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  } ||| j                  «      ‘Œ c}«      S c c}w )a;  
        Evaluate the quadratic models of the nonlinear inequality functions at
        a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the quadratic models of the nonlinear
            inequality functions.
        mask : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Values of the quadratic model of the nonlinear inequality
            functions.
        ro   ú!The shape of `mask` is not valid.)r   r7   r    r¶   r   ÚarrayÚ_get_cubrZ   ©r%   rq   ÚmaskrØ   s       r1   Úcubz
Models.cub³  s“   € ð& �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �x‰xØ7;·}±}ÀTÓ7JÖK¨e‰U�1�d×(Ñ(Õ)ÒKó
ð 	
ùÚKó   Á3Bc           	      ó^  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}d| j                  f«      S c c}w )a`  
        Evaluate the gradients of the quadratic models of the nonlinear
        inequality functions at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the gradients of the quadratic models of
            the nonlinear inequality functions.
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Gradients of the quadratic model of the nonlinear inequality
            functions.
        ro   rÛ   éÿÿÿÿ)	r   r7   r    r¶   r   ÚreshaperÝ   ry   rZ   rÞ   s       r1   Úcub_gradzModels.cub_gradÏ  ó¬   € ð& �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �z‰zàŸ-™-¨Ó-ö/Øð �Z‰Z˜˜4×-Ñ-Õ.ò /à�—‘ˆLó
ð 	
ùò/ó   Á3#B*c                 ó0  — | j                   r#|�!|j                  | j                  fk(  sJ d«       ‚t        j                  | j                  |«      D �cg c]  }|j                  | j                  «      ‘Œ c}d| j                  | j                  f«      S c c}w )a¶  
        Evaluate the Hessian matrices of the quadratic models of the nonlinear
        inequality functions.

        Parameters
        ----------
        mask : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Hessian matrices of the quadratic models of the nonlinear
            inequality functions.
        rÛ   rã   )	r   r7   r¶   r   rä   rÝ   r|   rZ   r    ©r%   rß   rØ   s      r1   Úcub_hesszModels.cub_hessí  ó‰   € ð  �;Š;Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �z‰zØ9=¿¹ÀtÓ9LÖM°ˆU�Z‰Z˜×*Ñ*Õ+ÒMØ�—‘˜Ÿ™Ð ó
ð 	
ùÚMó   Á"Bc           	      ó^  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}d| j                  f«      S c c}w )aÂ  
        Evaluate the right product of the Hessian matrices of the quadratic
        models of the nonlinear inequality functions with a given vector.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Vector with which the Hessian matrices of the quadratic models of
            the nonlinear inequality functions are multiplied from the right.
        mask : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Right products of the Hessian matrices of the quadratic models of
            the nonlinear inequality functions with `v`.
        r~   rÛ   rã   )	r   r7   r    r¶   r   rä   rÝ   rx   rZ   ©r%   r€   rß   rØ   s       r1   Úcub_hess_prodzModels.cub_hess_prod  ó°   € ð& �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �z‰zð "Ÿ]™]¨4Ó0öàð —‘  4×#5Ñ#5Õ6òð �—‘ˆLó
ð 	
ùòrç   c           	      óD  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}«      S c c}w )az  
        Evaluate the curvature of the quadratic models of the nonlinear
        inequality functions along a given direction.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Direction along which the curvature of the quadratic models of the
            nonlinear inequality functions is evaluated.
        mask : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Curvature of the quadratic models of the nonlinear inequality
            functions along `v`.
        r~   rÛ   )	r   r7   r    r¶   r   rÜ   rÝ   r‚   rZ   rî   s       r1   Úcub_curvzModels.cub_curv&  ó¡   € ð& �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �x‰xàŸ-™-¨Ó-ö/Øð �Z‰Z˜˜4×-Ñ-Õ.ò /ó
ð 	
ùò/ó   Á3#Bc           	      ó2  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  } ||| j                  «      ‘Œ c}«      S c c}w )a)  
        Evaluate the quadratic models of the nonlinear equality functions at a
        given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the quadratic models of the nonlinear
            equality functions.
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Values of the quadratic model of the nonlinear equality functions.
        ro   rÛ   )r   r7   r    r¸   r   rÜ   Ú_get_ceqrZ   rÞ   s       r1   Úceqz
Models.ceqC  s“   € ð$ �;Š;Ø—7‘7˜tŸv™v˜iÒ'ÐIÐ)IÓIÐ'Ø�< 4§:¡:Ø×#Ñ#ð2ò $ð 3à2ó3ð ô �x‰xØ7;·}±}ÀTÓ7JÖK¨e‰U�1�d×(Ñ(Õ)ÒKó
ð 	
ùÚKrá   c           	      ó^  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}d| j                  f«      S c c}w )aZ  
        Evaluate the gradients of the quadratic models of the nonlinear
        equality functions at a given point.

        Parameters
        ----------
        x : `numpy.ndarray`, shape (n,)
            Point at which to evaluate the gradients of the quadratic models of
            the nonlinear equality functions.
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Gradients of the quadratic model of the nonlinear equality
            functions.
        ro   rÛ   rã   )	r   r7   r    r¸   r   rä   rö   ry   rZ   rÞ   s       r1   Úceq_gradzModels.ceq_grad^  ræ   rç   c                 ó0  — | j                   r#|�!|j                  | j                  fk(  sJ d«       ‚t        j                  | j                  |«      D �cg c]  }|j                  | j                  «      ‘Œ c}d| j                  | j                  f«      S c c}w )a²  
        Evaluate the Hessian matrices of the quadratic models of the nonlinear
        equality functions.

        Parameters
        ----------
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Hessian matrices of the quadratic models of the nonlinear equality
            functions.
        rÛ   rã   )	r   r7   r¸   r   rä   rö   r|   rZ   r    ré   s      r1   Úceq_hesszModels.ceq_hess|  rë   rì   c           	      ó^  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}d| j                  f«      S c c}w )a¼  
        Evaluate the right product of the Hessian matrices of the quadratic
        models of the nonlinear equality functions with a given vector.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Vector with which the Hessian matrices of the quadratic models of
            the nonlinear equality functions are multiplied from the right.
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Right products of the Hessian matrices of the quadratic models of
            the nonlinear equality functions with `v`.
        r~   rÛ   rã   )	r   r7   r    r¸   r   rä   rö   rx   rZ   rî   s       r1   Úceq_hess_prodzModels.ceq_hess_prod•  rð   rç   c           	      óD  — | j                   rD|j                  | j                  fk(  sJ d«       ‚|�!|j                  | j                  fk(  sJ d«       ‚t	        j
                  | j                  |«      D �cg c]  }|j                  || j                  «      ‘Œ  c}«      S c c}w )at  
        Evaluate the curvature of the quadratic models of the nonlinear
        equality functions along a given direction.

        Parameters
        ----------
        v : `numpy.ndarray`, shape (n,)
            Direction along which the curvature of the quadratic models of the
            nonlinear equality functions is evaluated.
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to consider.

        Returns
        -------
        `numpy.ndarray`
            Curvature of the quadratic models of the nonlinear equality
            functions along `v`.
        r~   rÛ   )	r   r7   r    r¸   r   rÜ   rö   r‚   rZ   rî   s       r1   Úceq_curvzModels.ceq_curvµ  ró   rô   c                 ó  — t        | j                  | j                  | j                  «      | _        t        | j                  «      D ]A  }t        | j                  | j                  dd…|f   | j                  «      | j                  |<   ŒC t        | j                  «      D ]A  }t        | j                  | j                  dd…|f   | j                  «      | j                  |<   ŒC | j                  r| j                  «        yy)a9  
        Set the quadratic models of the objective function, nonlinear
        inequality constraints, and nonlinear equality constraints to the
        alternative quadratic models.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        N)ra   rZ   r®   r   rµ   r#   r¶   r¯   r·   r¸   r°   r¹   rº   )r%   rÀ   s     r1   Úreset_modelszModels.reset_modelsÒ  sÖ   € ô ˜d×0Ñ0°$·,±,ÀÇÁÓLˆŒ	Ü�t×*Ñ*Ó+ò 	ˆAÜ$Ø×"Ñ"Ø—‘šQ ˜TÑ"Ø—‘óˆD�I‰I�aŠLð	ô �t×*Ñ*Ó+ò 	ˆAÜ$Ø×"Ñ"Ø—‘šQ ˜TÑ"Ø—‘óˆD�I‰I�aŠLð	ð �;Š;Ø×0Ñ0Õ2ð r3   c           	      óÐ  — | j                   ržd|cxk  r| j                  k  sJ d«       ‚ J d«       ‚|j                  | j                  fk(  sJ d«       ‚t	        |t
        «      sJ d«       ‚|j                  | j                  fk(  sJ d«       ‚|j                  | j                  fk(  sJ d«       ‚t        j                  | j                  «      }t        j                  | j                  j                  «      }t        j                  | j                  j                  «      }|| j                  |«      z
  ||<   || j                  |«      z
  ||dd…f<   || j                  |«      z
  ||dd…f<   || j                  |<   || j                  |dd…f<   || j                  |dd…f<   t        j                   | j"                  j$                  dd…|f   «      }	|| j"                  j&                  z
  | j"                  j$                  dd…|f<   | j(                  j+                  | j"                  ||	|«      }
t-        | j                  «      D ]8  }|
xs2 | j.                  |   j+                  | j"                  ||	|dd…|f   «      }
Œ: t-        | j                  «      D ]8  }|
xs2 | j0                  |   j+                  | j"                  ||	|dd…|f   «      }
Œ: | j                   r| j3                  «        |
S )aÿ  
        Update the interpolation set.

        This method updates the interpolation set by replacing the `knew`-th
        interpolation point with `xnew`. It also updates the function values
        and the quadratic models.

        Parameters
        ----------
        k_new : int
            Index of the updated interpolation point.
        x_new : `numpy.ndarray`, shape (n,)
            New interpolation point. Its value is interpreted as relative to
            the origin, not the base point.
        fun_val : float
            Value of the objective function at `x_new`.
            Objective function value at `x_new`.
        cub_val : `numpy.ndarray`, shape (m_nonlinear_ub,)
            Values of the nonlinear inequality constraints at `x_new`.
        ceq_val : `numpy.ndarray`, shape (m_nonlinear_eq,)
            Values of the nonlinear equality constraints at `x_new`.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.
        r   r„   ú"The shape of `x_new` is not valid.z The function value is not valid.z$The shape of `cub_val` is not valid.z$The shape of `ceq_val` is not valid.N)r   r<   r7   r    Ú
isinstanceÚfloatr¶   r¸   r   r   r¯   r°   rÍ   rà   r÷   r®   r   rZ   r$   r   rµ   r�   r#   r·   r¹   rº   )r%   r‡   Úx_newr®   r¯   r°   Úfun_diffÚcub_diffÚceq_diffrˆ   rŒ   rÀ   s               r1   Úupdate_interpolationzModels.update_interpolationí  sË  € ð8 �;Š;Ø˜Ô( §¡Ò(ÐKÐ*KÓKÑ(ÐKÐ*KÓKÐ(Ø—;‘; 4§6¡6 )Ò+ð 5Ø4ó5Ð+ä˜g¤uÔ-ð 3Ø2ó3Ð-à—=‘=Ø×#Ñ#ð%ò ð 6à5ó6ð ð —=‘=Ø×#Ñ#ð%ò ð 6à5ó6ð ô
 —8‘8˜DŸH™HÓ%ˆÜ—8‘8˜DŸL™L×.Ñ.Ó/ˆÜ—8‘8˜DŸL™L×.Ñ.Ó/ˆØ! D§H¡H¨U£OÑ3ˆ�‰Ø$ t§x¡x°£Ñ6ˆ�š�ÑØ$ t§x¡x°£Ñ6ˆ�š�Ñð &ˆ�‰�UÑØ!(ˆ�‰�UšA�XÑØ!(ˆ�‰�UšA�XÑô —'‘'˜$×,Ñ,×0Ñ0²°E°Ñ:Ó;ˆØ+0°4×3EÑ3E×3LÑ3LÑ+Lˆ×Ñ×Ñšq %˜xÑ(ð Ÿ)™)×*Ñ*Ø×ÑØØØó	
ˆô �t×*Ñ*Ó+ò 	ˆAØ-ò °·±¸1±×1DÑ1DØ×"Ñ"ØØØš˜A˜‘ó	2‰Oð	ô �t×*Ñ*Ó+ò 	ˆAØ-ò °·±¸1±×1DÑ1DØ×"Ñ"ØØØš˜A˜‘ó	2‰Oð	ð �;Š;Ø×0Ñ0Ô2ØÐr3   c                 óf  — | j                   rG|j                  | j                  fk(  sJ d«       ‚|�$d|cxk  r| j                  k  sJ d«       ‚ J d«       ‚|| j                  j
                  z
  }t        j                  | j                  | j                  z   dz   df«      }d| j                  j                  j                  |z  dz  z  |d| j                  …df<   d|| j                  df<   ||| j                  dz   d…df<   t        j                  | j                  |«      d   }d||z  dz  z  |dd…df   |dd…df   z  z
  }|€„t        j                  | j                  | j                  z   dz   | j                  «      }t        j                  t        j                  | j                  |«      d   «      }|d| j                  …df   }	nat        j                  | j                  | j                  z   dz   d| «      }t        j                  | j                  |«      d   |df   }||df   }	||z  |	dz  z   S )	aÎ  
        Compute the normalized determinants of the new interpolation systems.

        Parameters
        ----------
        x_new : `numpy.ndarray`, shape (n,)
            New interpolation point. Its value is interpreted as relative to
            the origin, not the base point.
        k_new : int, optional
            Index of the updated interpolation point. If `k_new` is not
            specified, all the possible determinants are computed.

        Returns
        -------
        {float, `numpy.ndarray`, shape (npt,)}
            Determinant(s) of the new interpolation system.

        Raises
        ------
        `numpy.linalg.LinAlgError`
            If the interpolation system is ill-defined.

        Notes
        -----
        The determinants are normalized by the determinant of the current
        interpolation system. For stability reasons, the calculations are done
        using the formula (2.12) in [1]_.

        References
        ----------
        .. [1] M. J. D. Powell. On updating the inverse of a KKT matrix.
           Technical Report DAMTP 2004/NA01, Department of Applied Mathematics
           and Theoretical Physics, University of Cambridge, Cambridge, UK,
           2004.
        r  Nr   r„   r   r   r   rP   )r   r7   r    r<   rZ   r   r   rY   r$   rX   ra   rŸ   ÚeyeÚdiag)
r%   r  r‡   r‘   Únew_colÚinv_new_colÚbetaÚ	coord_vecÚalphaÚtaus
             r1   ÚdeterminantszModels.determinants@  sI  € ðH �;Š;Ø—;‘; 4§6¡6 )Ò+ð 5Ø4ó5Ð+ð �  eÔ!6¨d¯h©hÒ!6ð1à0ó1Ø6Ð!6ð1à0ó1Ø6ð ˜×*Ñ*×1Ñ1Ñ1ˆÜ—(‘(˜DŸH™H t§v¡vÑ-°Ñ1°1Ð5Ó6ˆà�t×)Ñ)×-Ñ-×/Ñ/°%Ñ7¸CÑ?Ñ?ð 	�
�$—(‘(�
˜A�Ñà"ˆ�—‘˜!�ÑØ$)ˆ�—‘˜1‘‘˜qÐ Ñ!Ü×-Ñ-¨d×.@Ñ.@À'ÓJÈ1ÑMˆØ�e˜e‘m¨Ñ+Ñ+¨g²a¸°d©m¸kÊ!ÈQÈ$Ñ>OÑ.OÑOˆð ˆ=ÜŸ™˜tŸx™x¨$¯&©&Ñ0°1Ñ4°d·h±hÓ?ˆIÜ—G‘GÜ×'Ñ'Ø×&Ñ&Øóð ñóˆEð ˜j §¡˜j¨!˜mÑ,‰CäŸ™˜tŸx™x¨$¯&©&Ñ0°1Ñ4°a¸%¸Ó@ˆIÜ×+Ñ+Ø×"Ñ"Øóð ñ	ð
 �QˆhñˆEð ˜e Q˜hÑ'ˆCØ�t‰|˜c 3™hÑ&Ð&r3   c                 ó~  — | j                   r!|j                  | j                  fk(  sJ d«       ‚| j                  j	                  | j
                  |«       | j                  D ]  }|j	                  | j
                  |«       Œ  | j                  D ]  }|j	                  | j
                  |«       Œ  || j
                  j                  z
  }| j
                  xj                  |z  c_        | j
                  xj                  |dd…t        j                  f   z  c_	        |t        j                     r| j                  «        yy)zü
        Shift the base point without changing the interpolation set.

        Parameters
        ----------
        new_x_base : `numpy.ndarray`, shape (n,)
            New base point.
        options : dict
            Options of the solver.
        r�   N)r   r7   r    rµ   r’   rZ   r·   r¹   r   r$   r   r{   r   r   rº   )r%   r�   r'   rØ   r‘   s        r1   r’   zModels.shift_x_baseŠ  s  € ð �;Š;Ø×#Ñ#Ø—‘ð(ò ð 9à8ó9ð ð
 	�	‰	×Ñ˜t×1Ñ1°:Ô>Ø—Y‘Yò 	?ˆEØ×Ñ˜t×1Ñ1°:Õ>ð	?à—Y‘Yò 	?ˆEØ×Ñ˜t×1Ñ1°:Õ>ð	?ð ˜T×/Ñ/×6Ñ6Ñ6ˆØ×Ñ×!Ò! UÑ*Õ!Ø×Ñ×Ò %ª¬2¯:©:¨Ñ"6Ñ6ÕØ”7—=‘=Ò!Ø×0Ñ0Õ2ð "r3   c                 ó<   — |€| j                   S | j                   |   S )ao  
        Get the quadratic models of the nonlinear inequality constraints.

        Parameters
        ----------
        mask : `numpy.ndarray`, shape (m_nonlinear_ub,), optional
            Mask of the quadratic models to return.

        Returns
        -------
        `numpy.ndarray`
            Quadratic models of the nonlinear inequality constraints.
        )r·   ©r%   rß   s     r1   rÝ   zModels._get_cub¨  ó   € ð !˜Lˆt�y‰yÐ=¨d¯i©i¸©oÐ=r3   c                 ó<   — |€| j                   S | j                   |   S )ak  
        Get the quadratic models of the nonlinear equality constraints.

        Parameters
        ----------
        mask : `numpy.ndarray`, shape (m_nonlinear_eq,), optional
            Mask of the quadratic models to return.

        Returns
        -------
        `numpy.ndarray`
            Quadratic models of the nonlinear equality constraints.
        )r¹   r  s     r1   rö   zModels._get_ceq¸  r  r3   c                 ó  — d}d}d}t        | j                  «      D �]1  }t        j                  |t        j                  | j                  | j                  j                  |«      «      | j                  |   z
  «      g«      }t        j                  t        j                  | j                  | j                  j                  |«      «      | j                  |dd…f   z
  «      |¬«      }t        j                  t        j                  | j                  | j                  j                  |«      «      | j                  |dd…f   z
  «      |¬«      }�Œ4 dt        j                  t        «      z  t        | j                  | j                  «      z  }||t        j                  t        j                  | j                  «      d¬«      z  kD  rt!        j"                  dt$        d«       ||t        j                  t        j                  | j                  «      d¬«      z  kD  rt!        j"                  dt$        d«       ||t        j                  t        j                  | j                  «      d¬«      z  kD  rt!        j"                  d	t$        d«       yy)
zM
        Check the interpolation conditions of all quadratic models.
        r…   NrN   g      $@rP   zJThe interpolation conditions for the objective function are not satisfied.r   zVThe interpolation conditions for the inequality constraint function are not satisfied.zTThe interpolation conditions for the equality constraint function are not satisfied.)r#   r<   r   rT   r˜   rÍ   rZ   rB   r®   rà   r¯   r÷   r°   ÚsqrtrW   r    ÚwarningsÚwarnÚRuntimeWarning)r%   Ú	error_funÚ	error_cubÚ	error_ceqr-   Útols         r1   rº   z&Models._check_interpolation_conditionsÈ  sü  € ð ˆ	Øˆ	Øˆ	Ü�t—x‘x“ó 	ˆAÜŸ™àÜ—F‘FØŸ™ ×!3Ñ!3×!9Ñ!9¸!Ó!<Ó=ÀÇÁÈQÁÑOóðóˆIô Ÿ™Ü—‘Ø—H‘H˜T×/Ñ/×5Ñ5°aÓ8Ó9¸D¿L¹LÈÊAÈÑ<NÑNóð "ô	ˆIô Ÿ™Ü—‘Ø—H‘H˜T×/Ñ/×5Ñ5°aÓ8Ó9¸D¿L¹LÈÊAÈÑ<NÑNóð "ô	ŠIð	ð* ”R—W‘WœS“\Ñ!¤C¨¯©°·±Ó$9Ñ9ˆØ�sœRŸV™V¤B§F¡F¨4¯<©<Ó$8À#ÔFÑFÒFÜ�M‰Mð!äØô	ð �sœRŸV™V¤B§F¡F¨4¯<©<Ó$8À#ÔFÑFÒFÜ�M‰Mð.äØô	ð �sœRŸV™V¤B§F¡F¨4¯<©<Ó$8À#ÔFÑFÒFÜ�M‰Mð.äØõ	ð Gr3   )N)%rC   rD   rE   rF   r2   rG   r    r<   r¶   r¸   rZ   r®   r¯   r°   rÍ   rÏ   rÑ   rÔ   rÖ   rÙ   rà   rå   rê   rï   rò   r÷   rù   rû   rý   rÿ   r  r
  r  r’   rÝ   rö   rº   rI   r3   r1   r¤   r¤   n  s'  „ ñòa3ðF ñ	$ó ð	$ð ñ	&ó ð	&ð ñ	%ó ð	%ð ñ	%ó ð	%ð ñ	#ó ð	#ð ñ	ó ð	ð ñó ðð ñó ðò0ò(5ò(
2ò:ò*5ò*1ó6
ó8
ó<
ó2
ó@
ó:
ó6
ó<
ó2
ó@
ò:3ò6QófH'òT3ó<>ó >ó 1r3   r¤   )r  Únumpyr   Úscipy.linalgr   Úsettingsr   Úutilsr   r   r   Úfinfor  ÚepsrW   r
   rR   r_   ra   r¤   rI   r3   r1   ú<module>r)     sl   ðÛ ã Ý å ß ?Ñ ?ð €b‡h�hˆuƒo×Ñ€÷r,ñ r,ðj ˜D°4ÀÑ	F€ò.7÷buFñ uF÷pKò Kr3   