Ë
    âQ(h�  ã                   óà   — d dl mZ d dlmZ d dlZd dlZd dlmZm	Z	m
Z
m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  G d
„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zy)é    )Úsuppress)Ú	signatureN)ÚBoundsÚLinearConstraintÚNonlinearConstraintÚOptimizeResult)ÚPreparedConstrainté   )ÚPRINT_OPTIONSÚBARRIER)ÚCallbackSuccessÚget_arrays_tol)Úexact_1d_arrayc                   ó<   — e Zd ZdZd„ Zd„ Zed„ «       Zed„ «       Zy)ÚObjectiveFunctionz)
    Real-valued objective function.
    c                 ó¦   — |r3|�t        |«      sJ ‚t        |t        «      sJ ‚t        |t        «      sJ ‚|| _        || _        || _        d| _        y)a  
        Initialize the objective function.

        Parameters
        ----------
        fun : {callable, None}
            Function to evaluate, or None.

                ``fun(x, *args) -> float``

            where ``x`` is an array with shape (n,) and `args` is a tuple.
        verbose : bool
            Whether to print the function evaluations.
        debug : bool
            Whether to make debugging tests during the execution.
        *args : tuple
            Additional arguments to be passed to the function.
        Nr   )ÚcallableÚ
isinstanceÚboolÚ_funÚ_verboseÚ_argsÚ_n_eval)ÚselfÚfunÚverboseÚdebugÚargss        úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/_lib/cobyqa/problem.pyÚ__init__zObjectiveFunction.__init__   sT   € ñ& Ø�;¤(¨3¤-Ð/Ð/Ü˜g¤tÔ,Ð,Ð,Ü˜e¤TÔ*Ð*Ð*àˆŒ	ØˆŒØˆŒ
Øˆ�ó    c                 ó¬  — t        j                  |t        ¬«      }| j                  €d}|S t        t        j                   | j                  |g| j
                  ¢­Ž «      «      }| xj                  dz  c_        | j                  rAt        j                  di t        ¤Ž5  t        | j                  › d|› d|› �«       ddd«       |S |S # 1 sw Y   |S xY w)a  
        Evaluate the objective function.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point at which the objective function is evaluated.

        Returns
        -------
        float
            Function value at `x`.
        ©ÚdtypeNç        r
   ú(ú) = © )ÚnpÚarrayÚfloatr   Úsqueezer   r   r   Úprintoptionsr   ÚprintÚname)r   ÚxÚfs      r   Ú__call__zObjectiveFunction.__call__6   s²   € ô �H‰H�QœeÔ$ˆØ�9‰9ÐØˆAð ˆô ”b—j‘j  §¡¨1Ð!:¨t¯z©zÒ!:Ó;Ó<ˆAØ�LŠL˜AÑ�LØ�}Š}Ü—_‘_Ñ5¤}Ñ5ñ 5Ü˜TŸY™Y˜K q¨¨¨4°¨sÐ3Ô4÷5àˆˆqˆ÷5àˆús   ÂC	Ã	Cc                 ó   — | j                   S ©úŠ
        Number of function evaluations.

        Returns
        -------
        int
            Number of function evaluations.
        )r   ©r   s    r   Ún_evalzObjectiveFunction.n_evalO   ó   € ð �|‰|Ðr!   c                 óx   — d}| j                   �	 | j                   j                  }|S |S # t        $ r d}Y |S w xY w)úŠ
        Name of the objective function.

        Returns
        -------
        str
            Name of the objective function.
        Ú r   )r   Ú__name__ÚAttributeError)r   r/   s     r   r/   zObjectiveFunction.name[   sM   € ð ˆØ�9‰9Ð ðØ—y‘y×)Ñ)�ð ˆˆtˆøô "ò Ø‘Øˆðús   �* ª9¸9N)	r<   Ú
__module__Ú__qualname__Ú__doc__r    r2   Úpropertyr7   r/   r(   r!   r   r   r      s9   „ ñòò:ð2 ñ	ó ð	ð ñó ñr!   r   c                   óH   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zd„ Z	d„ Z
y)	ÚBoundConstraintsz.
    Bound constraints ``xl <= x <= xu``.
    c                 óü  — t        j                  |j                  t        «      | _        t        j                  |j
                  t        «      | _        t         j                   | j                  t        j                  | j                  «      <   t         j                  | j                  t        j                  | j                  «      <   t        j                  | j                  | j                  k  «      xrc t        j                  | j                  t         j                  k  «      xr1 t        j                  | j                  t         j                   kD  «      | _        t        j                  | j                  t         j                   kD  «      t        j                  | j                  t         j                  k  «      z   | _        t        |t        j                   |j                  j"                  «      «      | _        y)z 
        Initialize the bound constraints.

        Parameters
        ----------
        bounds : scipy.optimize.Bounds
            Bound constraints.
        N)r)   r*   Úlbr+   Ú_xlÚubÚ_xuÚinfÚxlÚisnanÚxuÚallÚis_feasibleÚcount_nonzeroÚmr	   ÚonesÚsizeÚpcs)r   Úboundss     r   r    zBoundConstraints.__init__s   s9  € ô —8‘8˜FŸI™I¤uÓ-ˆŒÜ—8‘8˜FŸI™I¤uÓ-ˆŒô ')§f¡f Wˆ�‰”—‘˜Ÿ™Ó!Ñ"Ü%'§V¡Vˆ�‰”—‘˜Ÿ™Ó!Ñ"ô �F‰F�4—7‘7˜dŸg™gÑ%Ó&ò *Ü—‘�t—w‘w¤§¡Ñ'Ó(ò*ä—‘�t—w‘w¤"§&¡& Ñ(Ó)ð 	Ôô
 ×!Ñ! $§'¡'¬R¯V©V¨GÑ"3Ó4´r×7GÑ7GØ�G‰G”b—f‘fÑó8
ñ 
ˆŒô & f¬b¯g©g°f·i±i·n±nÓ.EÓFˆ�r!   c                 ó   — | j                   S )z|
        Lower bound.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Lower bound.
        )rF   r6   s    r   rJ   zBoundConstraints.xl�   ó   € ð �x‰xˆr!   c                 ó   — | j                   S )z|
        Upper bound.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Upper bound.
        )rH   r6   s    r   rL   zBoundConstraints.xu™   rV   r!   c                 óZ   — t        j                  |t        ¬«      }| j                  |«      S )á0  
        Evaluate the maximum constraint violation.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point at which the maximum constraint violation is evaluated.

        Returns
        -------
        float
            Maximum constraint violation at `x`.
        r#   )r)   Úasarrayr+   Ú	violation©r   r0   s     r   ÚmaxcvzBoundConstraints.maxcv¥   s#   € ô �J‰J�q¤Ô&ˆØ�~‰~˜aÓ Ð r!   c                 ó|   — | j                   rt        j                  dg«      S | j                  j	                  |«      S )Nr   )rN   r)   r*   rS   r[   r\   s     r   r[   zBoundConstraints.violation¶   s0   € à×ÒÜ—8‘8˜Q˜C“=Ð à—8‘8×%Ñ% aÓ(Ð(r!   c                 ót   — | j                   r+t        j                  || j                  | j                  «      S |S )a  
        Project a point onto the feasible set.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point to be projected.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Projection of `x` onto the feasible set.
        )rN   r)   ÚcliprJ   rL   r\   s     r   ÚprojectzBoundConstraints.project½   s,   € ð 04×/?Ò/?Œr�w‰w�q˜$Ÿ'™' 4§7¡7Ó+ÐFÀQÐFr!   N)r<   r>   r?   r@   r    rA   rJ   rL   r]   r[   ra   r(   r!   r   rC   rC   n   sE   „ ñòGð4 ñ	ó ð	ð ñ	ó ð	ò!ò")óGr!   rC   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d	„ Zd
„ Zy)ÚLinearConstraintszK
    Linear constraints ``a_ub @ x <= b_ub`` and ``a_eq @ x == b_eq``.
    c           	      ó  — |r=t        |t        «      sJ ‚|D ]  }t        |t        «      rŒJ ‚ t        |t        «      sJ ‚t	        j
                  d|f«      | _        t	        j
                  d«      | _        t	        j
                  d|f«      | _        t	        j
                  d«      | _	        |D �]|  }t	        j                  |j                  |j                  z
  «      t        |j                  |j                  «      k  }t	        j                  |«      ryt	        j                  | j                   |j"                  |   f«      | _        t	        j$                  | j&                  d|j                  |   |j                  |   z   z  f«      | _	        t	        j(                  |«      rŒõt	        j                  | j*                  |j"                  |    |j"                  |     f«      | _        t	        j$                  | j,                  |j                  |    |j                  |     f«      | _        �Œ d| j*                  t	        j.                  | j*                  «      <   d| j                   t	        j.                  | j                   «      <   t	        j.                  | j,                  «      t	        j0                  | j,                  «      z  }t	        j.                  | j&                  «      }| j*                  | dd…f   | _        | j,                  |    | _        | j                   | dd…f   | _        | j&                  |    | _	        |D �cg c]8  }|j"                  j2                  sŒt5        |t	        j6                  |«      «      ‘Œ: c}| _        yc c}w )a2  
        Initialize the linear constraints.

        Parameters
        ----------
        constraints : list of LinearConstraint
            Linear constraints.
        n : int
            Number of variables.
        debug : bool
            Whether to make debugging tests during the execution.
        r   ç      à?r%   N)r   Úlistr   r   r)   ÚemptyÚ_a_ubÚ_b_ubÚ_a_eqÚ_b_eqÚabsrG   rE   r   ÚanyÚvstackÚa_eqÚAÚconcatenateÚb_eqrM   Úa_ubÚb_ubrK   ÚisinfrR   r	   rQ   rS   )	r   ÚconstraintsÚnr   Ú
constraintÚis_equalityÚundef_ubÚundef_eqÚcs	            r   r    zLinearConstraints.__init__Ó   s¿  € ñ Ü˜k¬4Ô0Ð0Ð0Ø)ò @�
Ü! *Ô.>Õ?Ð?Ð?ð@ä˜e¤TÔ*Ð*Ð*ä—X‘X˜q !˜fÓ%ˆŒ
Ü—X‘X˜a“[ˆŒ
Ü—X‘X˜q !˜fÓ%ˆŒ
Ü—X‘X˜a“[ˆŒ
Ø%ó 	ˆJÜŸ&™&Ø—‘ 
§¡Ñ-óä 
§¡¨z¯}©}Ó=ñ>ˆKô �v‰v�kÔ"ÜŸY™Y¨¯	©	°:·<±<ÀÑ3LÐ'MÓN�”
ÜŸ^™^àŸ	™	Øà&ŸM™M¨+Ñ6Ø(Ÿm™m¨KÑ8ñ9ñðó	�”
ô —6‘6˜+Õ&ÜŸY™YàŸ	™	Ø"Ÿ™ k \Ñ2Ø#Ÿ™ { lÑ3Ð3ðó�”
ô  Ÿ^™^àŸ	™	Ø"Ÿ™ { lÑ3Ø#Ÿ™¨ |Ñ4Ð4ðó�–
ð1	ðB *-ˆ�	‰	”"—(‘(˜4Ÿ9™9Ó%Ñ&Ø),ˆ�	‰	”"—(‘(˜4Ÿ9™9Ó%Ñ&Ü—8‘8˜DŸI™IÓ&¬¯©°$·)±)Ó)<Ñ<ˆÜ—8‘8˜DŸI™IÓ&ˆØ—Y‘Y ˜yª!˜|Ñ,ˆŒ
Ø—Y‘Y ˜yÑ)ˆŒ
Ø—Y‘Y ˜yª!˜|Ñ,ˆŒ
Ø—Y‘Y ˜yÑ)ˆŒ
à7Bö
Ø23ÀaÇcÁcÇhÃhÔ˜q¤"§'¡'¨!£*Õ-ò
ˆ�ùò 
s   ÍN
Í !N
c                 ó   — | j                   S )zÜ
        Left-hand side matrix of the linear inequality constraints.

        Returns
        -------
        `numpy.ndarray`, shape (m, n)
            Left-hand side matrix of the linear inequality constraints.
        )rh   r6   s    r   rs   zLinearConstraints.a_ub  ó   € ð �z‰zÐr!   c                 ó   — | j                   S )zÞ
        Right-hand side vector of the linear inequality constraints.

        Returns
        -------
        `numpy.ndarray`, shape (m, n)
            Right-hand side vector of the linear inequality constraints.
        )ri   r6   s    r   rt   zLinearConstraints.b_ub#  r~   r!   c                 ó   — | j                   S )zØ
        Left-hand side matrix of the linear equality constraints.

        Returns
        -------
        `numpy.ndarray`, shape (m, n)
            Left-hand side matrix of the linear equality constraints.
        )rj   r6   s    r   ro   zLinearConstraints.a_eq/  r~   r!   c                 ó   — | j                   S )zÚ
        Right-hand side vector of the linear equality constraints.

        Returns
        -------
        `numpy.ndarray`, shape (m, n)
            Right-hand side vector of the linear equality constraints.
        )rk   r6   s    r   rr   zLinearConstraints.b_eq;  r~   r!   c                 ó.   — | j                   j                  S ©zœ
        Number of linear inequality constraints.

        Returns
        -------
        int
            Number of linear inequality constraints.
        )rt   rR   r6   s    r   Úm_ubzLinearConstraints.m_ubG  ó   € ð �y‰y�~‰~Ðr!   c                 ó.   — | j                   j                  S ©z˜
        Number of linear equality constraints.

        Returns
        -------
        int
            Number of linear equality constraints.
        )rr   rR   r6   s    r   Úm_eqzLinearConstraints.m_eqS  r…   r!   c                 óN   — t        j                  | j                  |«      d¬«      S )rY   r%   ©Úinitial©r)   Úmaxr[   r\   s     r   r]   zLinearConstraints.maxcv_  s   € ô �v‰v�d—n‘n QÓ'°Ô5Ð5r!   c                 óØ   — t        | j                  «      r<t        j                  | j                  D �cg c]  }|j	                  |«      ‘Œ c}«      S t        j
                  g «      S c c}w ©N)ÚlenrS   r)   rq   r[   r*   )r   r0   Úpcs      r   r[   zLinearConstraints.violationo  sG   € Üˆt�x‰xŒ=Ü—>‘>¸T¿X¹XÖ"F°r 2§<¡<°¥?Ò"FÓGÐGÜ�x‰x˜‹|Ðùò #Gs   ³A'N)r<   r>   r?   r@   r    rA   rs   rt   ro   rr   r„   rˆ   r]   r[   r(   r!   r   rc   rc   Î   s�   „ ñòB
ðH ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ò6ó r!   rc   c                   ó\   — e Zd ZdZd„ Zd„ Zed„ «       Zed„ «       Zed„ «       Z	d
d„Z
d
d	„Zy)ÚNonlinearConstraintszI
    Nonlinear constraints ``c_ub(x) <= 0`` and ``c_eq(x) == b_eq``.
    c                 ó  — |rOt        |t        «      sJ ‚|D ]  }t        |t        «      rŒJ ‚ t        |t        «      sJ ‚t        |t        «      sJ ‚|| _        g | _        || _        d| _        d| _        dx| _	        | _
        y)aA  
        Initialize the nonlinear constraints.

        Parameters
        ----------
        constraints : list
            Nonlinear constraints.
        verbose : bool
            Whether to print the function evaluations.
        debug : bool
            Whether to make debugging tests during the execution.
        N)r   rf   r   r   Ú_constraintsrS   r   Ú_map_ubÚ_map_eqÚ_m_ubÚ_m_eq)r   rv   r   r   rx   s        r   r    zNonlinearConstraints.__init__z  s�   € ñ Ü˜k¬4Ô0Ð0Ð0Ø)ò C�
Ü! *Ô.AÕBÐBÐBðCä˜g¤tÔ,Ð,Ð,Ü˜e¤TÔ*Ð*Ð*à'ˆÔØˆŒØˆŒð ˆŒØˆŒØ"&Ð&ˆŒ
�T•Zr!   c           
      ó 	  — t        | j                  «      s8dx| _        | _        t	        j
                  g «      t	        j
                  g «      fS t	        j
                  |t        ¬«      }t        | j                  «      �sªg | _        g | _	        d| _        d| _        | j                  D �]~  }t        |j                  «      s2t        j                  |«      }d„ |_        d„ |_        t        ||«      }nt        ||«      }d|j                  _        | j                  j#                  |«       t	        j$                  |j                  j&                  «      }|j(                  d   |j(                  d   }}t+        ||«      }t	        j,                  ||z
  «      |k  }	| j                  j#                  ||	   «       | j                  j#                  ||	    «       | xj                  t	        j.                  |	«      z  c_        | xj                  t	        j.                  |	 «      z  c_        �Œ� g }
g }t1        | j                  «      D �]œ  \  }}|j                  j                  |«      }| j2                  rpt	        j4                  di t6        ¤Ž5  t9        t:        «      5  | j                  |   j                  j<                  }t?        |› d|› d|› �«       d	d	d	«       d	d	d	«       | j                  |   }| j                  |   }||   }t        |«      rƒ|j(                  d   |   }|j(                  d   |   }|t        j@                   kD  }||   ||   z
  }|
j#                  |«       |t        j@                  k  }||   ||   z
  }|
j#                  |«       ||   }t        |«      r-d
|j(                  d   |   |j(                  d   |   z   z  }||z  }|j#                  |«       �ŒŸ | j                  rt	        jB                  |«      }nt	        j
                  g «      }| j                  rt	        jB                  |
«      }
nt	        j
                  g «      }
|
jD                  | _        |jD                  | _        |
|fS # 1 sw Y   �Œ¨xY w# 1 sw Y   �Œ­xY w)a¿  
        Calculates the residual (slack) for the constraints.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point at which the constraints are evaluated.

        Returns
        -------
        `numpy.ndarray`, shape (m_nonlinear_ub,)
            Nonlinear inequality constraint slack values.
        `numpy.ndarray`, shape (m_nonlinear_eq,)
            Nonlinear equality constraint slack values.
        r   r#   c                 ó   — | S r�   r(   )Úx0s    r   ú<lambda>z/NonlinearConstraints.__call__.<locals>.<lambda>¹  s   €  r€ r!   c                  ó   — y)Nr%   r(   )rœ   Úvs     r   r�   z/NonlinearConstraints.__call__.<locals>.<lambda>º  s   � r!   Tr
   r&   r'   Nre   r(   )#r�   r•   r™   r˜   r)   r*   r+   rS   r–   r—   r   ÚjacÚcopyÚhessr	   r   Ú	f_updatedÚappendÚarangerP   rT   r   rl   rO   Ú	enumerater   r-   r   r   r=   r<   r.   rI   rq   rR   )r   r0   rx   r|   r‘   ÚidxrE   rG   Úarr_tolry   Úc_ubÚc_eqÚiÚvalÚfun_nameÚeq_idxÚub_idxÚub_valrJ   rL   Ú	finite_xlÚ_vÚ	finite_xuÚeq_valÚmidpoints                            r   r2   zNonlinearConstraints.__call__—  s¼  € ô  �4×$Ñ$Ô%Ø&'Ð'ˆDŒJ˜œÜ—8‘8˜B“<¤§¡¨"£Ð-Ð-ä�H‰H�QœeÔ$ˆä�4—8‘8�}ØˆDŒLØˆDŒLØˆDŒJØˆDŒJà"×/Ñ/ó =�
Ü 
§¡Ô/ô Ÿ	™	 *Ó-�AÙ)�A”EÙ.�A”FÜ+¨A¨qÓ1‘Bä+¨J¸Ó:�Bð $(�—‘Ô à—‘—‘ Ô#Ü—i‘i §¡§¡Ó)�ð Ÿ™ 1™ r§y¡y°¡|�B�Ü(¨¨RÓ0�Ü Ÿf™f R¨"¡W›o°Ñ8�Ø—‘×#Ñ# C¨Ñ$4Ô5Ø—‘×#Ñ# C¨¨Ñ$5Ô6ð —
’
œb×.Ñ.¨{Ó;Ñ;•
Ø—
’
œb×.Ñ.°¨|Ó<Ñ<—
ð7=ð: ˆØˆÜ˜tŸx™xÓ(ó  	 ‰EˆAˆrØ—&‘&—*‘*˜Q“-ˆCØ�}Š}Ü—_‘_Ñ5¤}Ñ5ñ :Ü!¤.Ó1ñ :Ø#'×#4Ñ#4°QÑ#7×#;Ñ#;×#DÑ#D˜Ü  
¨!¨A¨3¨d°3°%Ð8Ô9÷:÷:ð —\‘\ !‘_ˆFØ—\‘\ !‘_ˆFà˜‘[ˆFÜ�6Œ{Ø—Y‘Y˜q‘\ &Ñ)�Ø—Y‘Y˜q‘\ &Ñ)�ð ¤"§&¡& ™L�	Ø˜	‘] V¨IÑ%6Ñ6�Ø—‘˜B”ð ¤§¡™K�	Ø˜IÑ&¨¨I©Ñ6�Ø—‘˜B”ð ˜‘[ˆFÜ�6Œ{Ø "§)¡)¨A¡,¨vÑ"6¸¿¹À1¹ÀfÑ9MÑ"MÑN�Ø˜(Ñ"�Ø�K‰K˜ÖðA 	 ðD �:Š:Ü—>‘> $Ó'‰Dä—8‘8˜B“<ˆDà�:Š:Ü—>‘> $Ó'‰Dä—8‘8˜B“<ˆDà—Y‘YˆŒ
Ø—Y‘YˆŒ
à�TˆzÐ÷W:ñ :ú÷:ñ :ús$   Ê	RÊ7Q6ËRÑ6R Ñ;RÒR	c                 óH   — | j                   €t        d«      ‚| j                   S )a  
        Number of nonlinear inequality constraints.

        Returns
        -------
        int
            Number of nonlinear inequality constraints.

        Raises
        ------
        ValueError
            If the number of nonlinear inequality constraints is unknown.
        z:The number of nonlinear inequality constraints is unknown.)r˜   Ú
ValueErrorr6   s    r   r„   zNonlinearConstraints.m_ub  s*   € ð �:‰:ÐÜØLóð ð —:‘:Ðr!   c                 óH   — | j                   €t        d«      ‚| j                   S )a  
        Number of nonlinear equality constraints.

        Returns
        -------
        int
            Number of nonlinear equality constraints.

        Raises
        ------
        ValueError
            If the number of nonlinear equality constraints is unknown.
        z8The number of nonlinear equality constraints is unknown.)r™   r·   r6   s    r   rˆ   zNonlinearConstraints.m_eq  s*   € ð �:‰:ÐÜØJóð ð —:‘:Ðr!   c                 ót   — t        | j                  «      r#| j                  d   j                  j                  S y)r5   r   )r�   rS   r   Únfevr6   s    r   r7   zNonlinearConstraints.n_eval/  s*   € ô ˆt�x‰xŒ=Ø—8‘8˜A‘;—?‘?×'Ñ'Ð'àr!   Nc                 óT   — t        j                  | j                  |||¬«      d¬«      S ©aÔ  
        Evaluate the maximum constraint violation.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point at which the maximum constraint violation is evaluated.
        cub_val : array_like, shape (m_nonlinear_ub,), optional
            Values of the nonlinear inequality constraints. If not provided,
            the nonlinear inequality constraints are evaluated at `x`.
        ceq_val : array_like, shape (m_nonlinear_eq,), optional
            Values of the nonlinear equality constraints. If not provided,
            the nonlinear equality constraints are evaluated at `x`.

        Returns
        -------
        float
            Maximum constraint violation at `x`.
        )Úcub_valÚceq_valr%   rŠ   rŒ   )r   r0   r½   r¾   s       r   r]   zNonlinearConstraints.maxcv>  s)   € ô( �v‰vØ�N‰N˜1 g°wˆNÓ?Èô
ð 	
r!   c                 ó„   — t        j                  | j                  D �cg c]  }|j                  |«      ‘Œ c}«      S c c}w r�   )r)   rq   rS   r[   )r   r0   r½   r¾   r‘   s        r   r[   zNonlinearConstraints.violationV  s+   € Ü�~‰~¸¿¹ÖB°2˜rŸ|™|¨A�ÒBÓCÐCùÒBs   ž=©NN)r<   r>   r?   r@   r    r2   rA   r„   rˆ   r7   r]   r[   r(   r!   r   r“   r“   u  sZ   „ ñò'ò:jðX ñó ðð* ñó ðð* ñó ðó
ô0Dr!   r“   c                   ó:  — e Zd ZdZd„ Zd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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d„Zdd„Zd„ Zy)ÚProblemz
    Optimization problem.
    c           
      óò  — |rÄt        |t        «      sJ ‚t        |t        «      sJ ‚t        |t        «      sJ ‚t        |t        «      sJ ‚t        |t
        «      sJ ‚t        |t        «      sJ ‚t        |	t        «      sJ ‚t        |
t        «      sJ ‚|	r|
dkD  sJ ‚t        |t        «      sJ ‚|dkD  sJ ‚t        |t        «      sJ ‚|| _        || _	        || _
        |�t        |«      st        d«      ‚|| _        t        |d«      }|j                  }|j                   j                  |k7  rt#        d|› d�«      ‚|j$                  j&                  d   |k7  rt#        d|› d	�«      ‚t)        |j                   |j*                  «      }|j                   |j*                  k  t-        j.                  |j                   |j*                  z
  «      |k  z  | _        d
|j                   | j0                     |j*                  | j0                     z   z  | _        t-        j4                  | j2                  |j                   | j0                     |j*                  | j0                     «      | _        || _        t        t9        |j                   | j0                      |j*                  | j0                      «      «      | _        | j:                  j=                  || j0                      «      | _        |j@                  |jB                  dd…| j0                  f   | j2                  z  z
  }t        tE        |j$                  dd…| j0                   f   t,        jF                   |jH                  |j$                  dd…| j0                  f   | j2                  z  z
  «      tE        |jB                  dd…| j0                   f   ||«      g| jJ                  |«      | _	        |xr’ | j:                  jL                  xrz t-        jN                  t-        jP                  | j:                  j                   «      «      xr< t-        jN                  t-        jP                  | j:                  j*                  «      «      }|�rd
| j:                  j*                  | j:                  j                   z
  z  | _)        d
| j:                  j*                  | j:                  j                   z   z  | _*        t        t9        t-        jV                  | jJ                  «       t-        jV                  | jJ                  «      «      «      | _        | j                  j@                  | j                  jB                  | jT                  z  z
  }t        tE        | j                  j$                  t-        jX                  | jR                  «      z  t,        jF                   | j                  jH                  | j                  j$                  | jT                  z  z
  «      tE        | j                  jB                  t-        jX                  | jR                  «      z  ||«      g| jJ                  |«      | _	        | j>                  | jT                  z
  | jR                  z  | _        nHt-        jV                  | jJ                  «      | _)        t-        jZ                  | jJ                  «      | _*        || _.        || _/        g | _0        g | _1        g | _2        |	| _3        |
| _4        g | _5        g | _6        g | _7        y)aY  
        Initialize the nonlinear problem.

        The problem is preprocessed to remove all the variables that are fixed
        by the bound constraints.

        Parameters
        ----------
        obj : ObjectiveFunction
            Objective function.
        x0 : array_like, shape (n,)
            Initial guess.
        bounds : BoundConstraints
            Bound constraints.
        linear : LinearConstraints
            Linear constraints.
        nonlinear : NonlinearConstraints
            Nonlinear constraints.
        callback : {callable, None}
            Callback function.
        feasibility_tol : float
            Tolerance on the constraint violation.
        scale : bool
            Whether to scale the problem according to the bounds.
        store_history : bool
            Whether to store the function evaluations.
        history_size : int
            Maximum number of function evaluations to store.
        filter_size : int
            Maximum number of points in the filter.
        debug : bool
            Whether to make debugging tests during the execution.
        r   Nz)The callback must be a callable function.z#The initial guess must be a vector.zThe bounds must have z
 elements.r
   z@The left-hand side matrices of the linear constraints must have z	 columns.re   )8r   r   rC   rc   r“   r+   r   ÚintÚ_objÚ_linearÚ
_nonlinearr   Ú	TypeErrorÚ	_callbackr   rR   rJ   r·   rs   Úshaper   rL   r)   rl   Ú
_fixed_idxÚ
_fixed_valr`   Ú_orig_boundsr   Ú_boundsra   Ú_x0rr   ro   r   rI   rt   rw   rN   rM   ÚisfiniteÚ_scaling_factorÚ_scaling_shiftrQ   ÚdiagÚzerosÚ_feasibility_tolÚ_filter_sizeÚ_fun_filterÚ_maxcv_filterÚ	_x_filterÚ_store_historyÚ_history_sizeÚ_fun_historyÚ_maxcv_historyÚ
_x_history)r   Úobjrœ   rT   ÚlinearÚ	nonlinearÚcallbackÚfeasibility_tolÚscaleÚstore_historyÚhistory_sizeÚfilter_sizer   rw   Útolrr   s                   r   r    zProblem.__init___  sš  € ñ` Ü˜cÔ#4Ô5Ð5Ð5Ü˜fÔ&6Ô7Ð7Ð7Ü˜fÔ&7Ô8Ð8Ð8Ü˜iÔ)=Ô>Ð>Ð>Ü˜o¬uÔ5Ð5Ð5Ü˜e¤TÔ*Ð*Ð*Ü˜m¬TÔ2Ð2Ð2Ü˜l¬CÔ0Ð0Ð0ÙØ# aÒ'Ð'Ð'Ü˜k¬3Ô/Ð/Ð/Ø ’?Ð"�?Ü˜e¤TÔ*Ð*Ð*àˆŒ	ØˆŒØ#ˆŒØÐÜ˜HÔ%ÜÐ KÓLÐLØ!ˆŒô ˜BÐ EÓFˆØ�G‰GˆØ�9‰9�>‰>˜QÒÜÐ4°Q°C°zÐBÓCÐCØ�;‰;×Ñ˜QÑ 1Ò$ÜðØ�s˜)ð%óð ô ˜VŸY™Y¨¯	©	Ó2ˆØ!Ÿ9™9¨¯	©	Ñ1Ü�F‰F�6—9‘9˜vŸy™yÑ(Ó)¨CÑ/ñ
ˆŒð Ø�I‰I�d—o‘oÑ&¨¯©°4·?±?Ñ)CÑCñ
ˆŒô Ÿ'™'Ø�O‰OØ�I‰I�d—o‘oÑ&Ø�I‰I�d—o‘oÑ&ó
ˆŒð #ˆÔÜ'Ü�6—9‘9˜dŸo™oÐ-Ñ.°·	±	¸4¿?¹?Ð:JÑ0KÓLó
ˆŒð
 —<‘<×'Ñ'¨¨D¯O©OÐ+;Ñ(<Ó=ˆŒð �{‰{˜VŸ[™[ª¨D¯O©OÐ);Ñ<¸t¿¹ÑNÑNˆÜ(ä Ø—K‘K¢ D§O¡OÐ#3Ð 3Ñ4Ü—V‘V�GØ—K‘KØ—k‘k¢! T§_¡_Ð"4Ñ5¸¿¹ÑGñHóô ! §¡ªQ°·±Ð0@Ð-@Ñ!AÀ4ÈÓNðð �F‰FØó
ˆŒð  ò 5Ø—‘×(Ñ(ò5ä—‘”r—{‘{ 4§<¡<§?¡?Ó3Ó4ò5ô —‘”r—{‘{ 4§<¡<§?¡?Ó3Ó4ð	 	ò Ø#&¨$¯,©,¯/©/¸D¿L¹L¿O¹OÑ*KÑ#LˆDÔ Ø"%¨¯©¯©¸4¿<¹<¿?¹?Ñ)JÑ"KˆDÔÜ+ÜœŸ™ §¡›Ð'¬¯©°·±«Ó9óˆDŒLð —<‘<×$Ñ$ t§|¡|×'8Ñ'8¸4×;NÑ;NÑ'NÑNˆDÜ,ä$ØŸ™×)Ñ)¬B¯G©G°D×4HÑ4HÓ,IÑIÜŸ™˜ØŸ™×)Ñ)ØŸ,™,×+Ñ+¨d×.AÑ.AÑAñBóô %ØŸ™×)Ñ)¬B¯G©G°D×4HÑ4HÓ,IÑIØØóðð —‘ØóˆDŒLð" Ÿ™ 4×#6Ñ#6Ñ6¸$×:NÑ:NÑNˆD�Hä#%§7¡7¨4¯6©6£?ˆDÔ Ü"$§(¡(¨4¯6©6Ó"2ˆDÔð !0ˆÔØ'ˆÔØˆÔØˆÔØˆŒð ,ˆÔØ)ˆÔØˆÔØ ˆÔØˆ�r!   c                 óÎ  ‡‡— t        j                  |t        ¬«      }| j                  |«      }| j	                  |«      Š| j                  |«      \  }}| j                  |||«      Š| j                  rÄ| j                  j                  ‰«       | j                  j                  ‰«       | j                  j                  |«       t        | j                  «      | j                  kD  rQ| j                  j                  d«       | j                  j                  d«       | j                  j                  d«       t        j                  ‰«      r.t        j                  ‰«      rt        | j                   «      dk(  }nÃt        j                  ‰«      r3t#        ˆfd„t%        | j                   | j&                  «      D «       «      }n{t        j                  ‰«      r3t#        ˆfd„t%        | j                   | j&                  «      D «       «      }n3t#        ˆˆfd„t%        | j                   | j&                  «      D «       «      }|�r | j                   j                  ‰«       | j&                  j                  ‰«       | j(                  j                  |«       t+        t        | j                   «      dz
  dd«      D �]5  }t        j                  ‰«      r#t        j                  | j                   |   «      }n¦t        j                  ‰«      r#t        j                  | j&                  |   «      }nnt        j                  | j                   |   «      xsJ t        j                  | j&                  |   «      xs& ‰| j                   |   k  xr ‰| j&                  |   k  }|sŒå| j                   j                  |«       | j&                  j                  |«       | j(                  j                  |«       �Œ8 t        | j                   «      | j,                  kD  rQ| j                   j                  d«       | j&                  j                  d«       | j(                  j                  d«       | j.                  �†t1        | j.                  «      }		 | j3                  |«      \  }
}}| j                  |
«      }
t5        |	j6                  «      d	hk(  r t9        |
|¬
«      }| j/                  |¬«       n| j/                  |
«       t        j                  ‰«      rt>        Št>        |t        j                  |«      <   t>        |t        j                  |«      <   tA        tC        ‰t>        «      t>         «      Št        jD                  t        jF                  |t>        «      t>         «      }t        jD                  t        jF                  |t>        «      t>         «      }‰||fS # t:        $ r}t<        |‚d}~ww xY w)a  
        Evaluate the objective and nonlinear constraint functions.

        Parameters
        ----------
        x : array_like, shape (n,)
            Point at which the functions are evaluated.
        penalty : float, optional
            Penalty parameter used to select the point in the filter to forward
            to the callback function.

        Returns
        -------
        float
            Objective function value.
        `numpy.ndarray`, shape (m_nonlinear_ub,)
            Nonlinear inequality constraint function values.
        `numpy.ndarray`, shape (m_nonlinear_eq,)
            Nonlinear equality constraint function values.

        Raises
        ------
        `cobyqa.utils.CallbackSuccess`
            If the callback function raises a ``StopIteration``.
        r#   r   c              3   óŠ   •K  — | ]:  \  }}t        j                  |«      xr ‰|k  xs t        j                  |«      –— Œ< y ­wr�   ©r)   rK   )Ú.0Ú
fun_filterÚmaxcv_filterÚ	maxcv_vals      €r   ú	<genexpr>z#Problem.__call__.<locals>.<genexpr>7  sK   øè ø€ ò  ñ -�J ô —‘˜Ó$ò -Ø Ñ,ò*ä—8‘8˜LÓ)ó*ñ ùó   ƒA Ac              3   óŠ   •K  — | ]:  \  }}t        j                  |«      xr ‰|k  xs t        j                  |«      –— Œ< y ­wr�   rë   )rì   rí   rî   Úfun_vals      €r   rð   z#Problem.__call__.<locals>.<genexpr>A  sK   øè ø€ ò  ñ -�J ô —‘˜Ó&ò )Ø˜jÑ(ò(ä—8‘8˜JÓ'ó(ñ ùrñ   c              3   ó<   •K  — | ]  \  }}‰|k  xs ‰|k  –— Œ y ­wr�   r(   )rì   rí   rî   ró   rï   s      €€r   rð   z#Problem.__call__.<locals>.<genexpr>K  s/   øè ø€ ò  á,�J ð ˜*Ñ$Ò@¨	°LÑ(@Ó@ñ ùs   ƒé   éÿÿÿÿNÚintermediate_result)r0   r   )r÷   )$r)   rZ   r+   Úbuild_xrÅ   rÇ   r]   rÚ   rÜ   r¤   rÝ   rÞ   r�   rÛ   ÚpoprK   r×   rM   ÚziprØ   rÙ   ÚrangerÖ   rÉ   r   Ú	best_evalÚsetÚ
parametersr   ÚStopIterationr   r   r�   ÚminÚmaximumÚminimum)r   r0   ÚpenaltyÚx_fullr½   r¾   Úinclude_pointÚkÚremove_pointÚsigÚx_bestÚfun_bestÚ_r÷   Úexcró   rï   s                  @@r   r2   zProblem.__call__
  s¨  ù€ ô6 �J‰J�q¤Ô&ˆØ—‘˜a“ˆØ—)‘)˜FÓ#ˆØŸ?™?¨6Ó2Ñˆ�Ø—J‘J˜q '¨7Ó3ˆ	Ø×ÒØ×Ñ×$Ñ$ WÔ-Ø×Ñ×&Ñ& yÔ1Ø�O‰O×"Ñ" 1Ô%Ü�4×$Ñ$Ó%¨×(:Ñ(:Ò:Ø×!Ñ!×%Ñ% aÔ(Ø×#Ñ#×'Ñ'¨Ô*Ø—‘×#Ñ# AÔ&ô �8‰8�GÔ¤§¡¨)Ô!4Ü × 0Ñ 0Ó1°QÑ6‰MÜ�X‰X�gÔÜó  ô 14Ø×$Ñ$Ø×&Ñ&ó1ô	 ó ‰Mô �X‰X�iÔ Üó  ô 14Ø×$Ñ$Ø×&Ñ&ó1ô	 ó ‰Mô  ô  ä03Ø×$Ñ$Ø×&Ñ&ó1ô ó ˆMò Ø×Ñ×#Ñ# GÔ,Ø×Ñ×%Ñ% iÔ0Ø�N‰N×!Ñ! !Ô$ô
 œ3˜t×/Ñ/Ó0°1Ñ4°b¸"Ó=ó *�Ü—8‘8˜GÔ$Ü#%§8¡8¨D×,<Ñ,<¸QÑ,?Ó#@‘LÜ—X‘X˜iÔ(Ü#%§8¡8¨D×,>Ñ,>¸qÑ,AÓ#B‘Lô Ÿ™ ×!1Ñ!1°!Ñ!4Ó5ò ?ÜŸ8™8 D×$6Ñ$6°qÑ$9Ó:ò?à" d×&6Ñ&6°qÑ&9Ñ9ò ?Ø%¨×);Ñ);¸AÑ)>Ñ>ð	 !ò  Ø×$Ñ$×(Ñ(¨Ô+Ø×&Ñ&×*Ñ*¨1Ô-Ø—N‘N×&Ñ& qÖ)ð*ô$ �4×#Ñ#Ó$ t×'8Ñ'8Ò8Ø× Ñ ×$Ñ$ QÔ'Ø×"Ñ"×&Ñ& qÔ)Ø—‘×"Ñ" 1Ô%ð �>‰>Ð%Ü˜DŸN™NÓ+ˆCð/Ø&*§n¡n°WÓ&=Ñ#�˜ !ØŸ™ fÓ-�Ü�s—~‘~Ó&Ð+@Ð*AÒAÜ*8Ø Ø$ô+Ð'ð
 —N‘NÐ7J�NÕKà—N‘N 6Ô*ô
 �8‰8�GÔÜˆGÜ%,ˆ”—‘˜Ó!Ñ"Ü%,ˆ”—‘˜Ó!Ñ"Ü”c˜'¤7Ó+¬g¨XÓ6ˆÜ—*‘*œRŸZ™Z¨´Ó9¼G¸8ÓDˆÜ—*‘*œRŸZ™Z¨´Ó9¼G¸8ÓDˆØ˜ Ð(Ð(øô !ò /Ü%¨3Ð.ûð/ús   ÒA0W ×	W$×W×W$c                 ó.   — | j                   j                  S )zt
        Number of variables.

        Returns
        -------
        int
            Number of variables.
        )rœ   rR   r6   s    r   rw   z	Problem.nŽ  s   € ð �w‰w�|‰|Ðr!   c                 ó.   — | j                   j                  S )zÒ
        Number of variables in the original problem (with fixed variables).

        Returns
        -------
        int
            Number of variables in the original problem (with fixed variables).
        )rË   rR   r6   s    r   Ún_origzProblem.n_origš  s   € ð �‰×#Ñ#Ð#r!   c                 ó   — | j                   S )z€
        Initial guess.

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Initial guess.
        )rÏ   r6   s    r   rœ   z
Problem.x0¦  rV   r!   c                 ó.   — | j                   j                  S r4   )rÅ   r7   r6   s    r   r7   zProblem.n_eval²  s   € ð �y‰y×ÑÐr!   c                 ó.   — | j                   j                  S )r:   )rÅ   r/   r6   s    r   r­   zProblem.fun_name¾  r…   r!   c                 ó   — | j                   S )z}
        Bound constraints.

        Returns
        -------
        BoundConstraints
            Bound constraints.
        )rÎ   r6   s    r   rT   zProblem.boundsÊ  r8   r!   c                 ó   — | j                   S )z€
        Linear constraints.

        Returns
        -------
        LinearConstraints
            Linear constraints.
        )rÆ   r6   s    r   rà   zProblem.linearÖ  r8   r!   c                 ó.   — | j                   j                  S )z„
        Number of bound constraints.

        Returns
        -------
        int
            Number of bound constraints.
        )rT   rP   r6   s    r   Úm_boundszProblem.m_boundsâ  s   € ð �{‰{�}‰}Ðr!   c                 ó.   — | j                   j                  S rƒ   )rà   r„   r6   s    r   Úm_linear_ubzProblem.m_linear_ubî  ó   € ð �{‰{×ÑÐr!   c                 ó.   — | j                   j                  S r‡   )rà   rˆ   r6   s    r   Úm_linear_eqzProblem.m_linear_eqú  r  r!   c                 ó.   — | j                   j                  S )a   
        Number of nonlinear inequality constraints.

        Returns
        -------
        int
            Number of nonlinear inequality constraints.

        Raises
        ------
        ValueError
            If the number of nonlinear inequality constraints is not known.
        )rÇ   r„   r6   s    r   Úm_nonlinear_ubzProblem.m_nonlinear_ub  ó   € ð �‰×#Ñ#Ð#r!   c                 ó.   — | j                   j                  S )a  
        Number of nonlinear equality constraints.

        Returns
        -------
        int
            Number of nonlinear equality constraints.

        Raises
        ------
        ValueError
            If the number of nonlinear equality constraints is not known.
        )rÇ   rˆ   r6   s    r   Úm_nonlinear_eqzProblem.m_nonlinear_eq  r  r!   c                 óL   — t        j                  | j                  t        ¬«      S )z½
        History of objective function evaluations.

        Returns
        -------
        `numpy.ndarray`, shape (n_eval,)
            History of objective function evaluations.
        r#   )r)   r*   rÜ   r+   r6   s    r   Úfun_historyzProblem.fun_history(  s   € ô �x‰x˜×)Ñ)´Ô7Ð7r!   c                 óL   — t        j                  | j                  t        ¬«      S )z»
        History of maximum constraint violations.

        Returns
        -------
        `numpy.ndarray`, shape (n_eval,)
            History of maximum constraint violations.
        r#   )r)   r*   rÝ   r+   r6   s    r   Úmaxcv_historyzProblem.maxcv_history4  s   € ô �x‰x˜×+Ñ+´5Ô9Ð9r!   c                 óÀ   — 	 | j                   dkD  s| j                  dkD  ry| j                  dkD  s| j                  dkD  ry| j                  dkD  ryy# t
        $ r Y yw xY w)zû
        Type of the problem.

        The problem can be either 'unconstrained', 'bound-constrained',
        'linearly constrained', or 'nonlinearly constrained'.

        Returns
        -------
        str
            Type of the problem.
        r   znonlinearly constrainedzlinearly constrainedzbound-constrainedÚunconstrained)r  r   r  r  r  r·   r6   s    r   ÚtypezProblem.type@  si   € ð	-Ø×"Ñ" QÒ&¨$×*=Ñ*=ÀÒ*AØ0Ø×!Ñ! AÒ%¨×)9Ñ)9¸AÒ)=Ø-Ø—‘ Ò"Ø*à&øÜò 	-ñ -ð	-ús   ‚A ¡A Á A Á	AÁAc                 ó    — | j                   dk(  S )z§
        Whether the problem is a feasibility problem.

        Returns
        -------
        bool
            Whether the problem is a feasibility problem.
        r;   )r­   r6   s    r   Úis_feasibilityzProblem.is_feasibility^  s   € ð �}‰} Ñ"Ð"r!   c                 óü   — t        j                  | j                  «      }| j                  || j                  <   || j
                  z  | j                  z   || j                   <   | j                  j                  |«      S )a0  
        Build the full vector of variables from the reduced vector.

        Parameters
        ----------
        x : array_like, shape (n,)
            Reduced vector of variables.

        Returns
        -------
        `numpy.ndarray`, shape (n_orig,)
            Full vector of variables.
        )	r)   rg   r  rÌ   rË   rÑ   rÒ   rÍ   ra   )r   r0   r  s      r   rø   zProblem.build_xj  si   € ô —‘˜$Ÿ+™+Ó&ˆØ"&§/¡/ˆˆt�‰ÑØ$%¨×(<Ñ(<Ñ$<Ø&*×&9Ñ&9ñ%:ˆ�—‘ÐÑ à× Ñ ×(Ñ(¨Ó0Ð0r!   Nc                 ó„   — | j                  |||¬«      }t        j                  |«      rt        j                  |d¬«      S yr¼   )r[   r)   rO   r�   )r   r0   r½   r¾   r[   s        r   r]   zProblem.maxcv~  s:   € ð( —N‘N 1¨g¸w�NÓGˆ	Ü×Ñ˜IÔ&Ü—6‘6˜)¨SÔ1Ð1àr!   c                 óü  — g }| j                   j                  s,| j                   j                  |«      }|j                  |«       t	        | j
                  j                  «      r,| j
                  j                  |«      }|j                  |«       t	        | j                  j                  «      r.| j                  j                  |||«      }|j                  |«       t	        |«      rt        j                  |«      S y r�   )
rT   rN   r[   r¤   r�   rà   rS   rÇ   r)   rq   )r   r0   r½   r¾   r[   ÚbÚlcÚnlcs           r   r[   zProblem.violation˜  s»   € Øˆ	Ø�{‰{×&Ò&Ø—‘×%Ñ% aÓ(ˆAØ×Ñ˜QÔäˆt�{‰{�‰ÔØ—‘×&Ñ& qÓ)ˆBØ×Ñ˜RÔ Üˆt�‰×"Ñ"Ô#Ø—/‘/×+Ñ+¨A¨w¸Ó@ˆCØ×Ñ˜SÔ!äˆyŒ>Ü—>‘> )Ó,Ð,ð r!   c                 óº  — t        | j                  «      dk(  r | | j                  «       t        j                  | j                  «      }t        j                  | j
                  «      }t        j                  | j                  «      }t        j                  |«      }t        j                  |«      �r|| j                  k  }t        j                  |«      r™t        j                  t        j                  ||   «      «      sn||t        j                  ||   «      k  z  }t        j                  |«      dkD  r||t        j                  ||   «      k  z  }t        j                  |«      d   }�nÂt        j                  |«      rt        j                  |«      d   }�n“t        j                   |t        j"                  «      }	||   |||   z  z   |	|<   t        j                  t        j                  |	«      «      r2|t        j                  |«      k  }
t        j                  |
«      d   }�n|	t        j                  |	«      k  }t        j                  |«      dkD  r||t        j                  ||   «      k  z  }t        j                  |«      dkD  r||t        j                  ||   «      k  z  }t        j                  |«      d   }ngt        j                  t        j                  |«      «      s1|t        j                  |«      k  }t        j                  |«      d   }nt        |«      dz
  }| j$                  j'                  ||dd…f   «      ||   ||   fS )aÎ  
        Return the best point in the filter and the corresponding objective and
        nonlinear constraint function evaluations.

        Parameters
        ----------
        penalty : float
            Penalty parameter

        Returns
        -------
        `numpy.ndarray`, shape (n,)
            Best point.
        float
            Corresponding objective function value.
        float
            Corresponding maximum constraint violation.
        r   r
   rö   N)r�   r×   rœ   r)   r*   rØ   rÙ   rÐ   rm   rÕ   rM   rK   ÚnanminrO   r   ÚflatnonzeroÚ	full_likeÚnanrT   ra   )r   r  rí   rî   Úx_filterÚ
finite_idxÚfeasible_idxÚfun_min_idxr«   Úmerit_filterÚmin_maxcv_idxÚmerit_min_idxs               r   rü   zProblem.best_eval¨  sÐ  € ô, ˆt×ÑÓ  AÒ%Ù�—‘ŒMô —X‘X˜d×.Ñ.Ó/ˆ
Ü—x‘x × 2Ñ 2Ó3ˆÜ—8‘8˜DŸN™NÓ+ˆÜ—[‘[ Ó.ˆ
Ü�6‰6�*Õà'¨4×+@Ñ+@Ñ@ˆLÜ�v‰v�lÔ#¬B¯F©FÜ—‘˜ LÑ1Ó2ô-ð +Ø¤"§)¡)¨J°|Ñ,DÓ"EÑEñ�ô ×#Ñ# KÓ0°1Ò4Ø <´2·6±6Ø$ [Ñ1ó4ñ $ñ �Kô —N‘N ;Ó/°Ñ3’Ü—‘˜Ô%ô —N‘N <Ó0°Ñ4’ô  "Ÿ|™|¨J¼¿¹Ó?�à˜zÑ*¨W°|ÀJÑ7OÑ-OÑOð ˜ZÑ(ô —6‘6œ"Ÿ(™( <Ó0Ô1ð %1´B·I±I¸lÓ4KÑ$K�MÜŸ™ }Ó5°bÑ9’Að %1´B·I±I¸lÓ4KÑ$K�MÜ×'Ñ'¨Ó6¸Ò:Ø%¨¼¿¹Ø(¨Ñ7ó:ñ *ñ ˜ô ×'Ñ'¨Ó6¸Ò:Ø%¨´r·v±vØ& }Ñ5ó8ñ *ñ ˜ô Ÿ™ }Ó5°bÑ9‘AÜ—‘œŸ™ Ó,Ô-ð
 %¬¯	©	°*Ó(=Ñ=ˆKÜ—‘˜{Ó+¨BÑ/‰Aô �J“ !Ñ#ˆAà�K‰K×Ñ ¨ªA¨¡Ó/Ø�q‰MØ˜‰Oð
ð 	
r!   )r%   rÀ   )r<   r>   r?   r@   r    r2   rA   rw   r  rœ   r7   r­   rT   rà   r  r  r  r  r   r"  r$  r'  r)  rø   r]   r[   rü   r(   r!   r   rÂ   rÂ   Z  sj  „ ñòióVB)ðH ñ	ó ð	ð ñ	$ó ð	$ð ñ	ó ð	ð ñ	 ó ð	 ð ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ð ñ	ó ð	ð ñ	 ó ð	 ð ñ	 ó ð	 ð ñ$ó ð$ð  ñ$ó ð$ð  ñ	8ó ð	8ð ñ	:ó ð	:ð ñ-ó ð-ð: ñ	#ó ð	#ò1ó(ó4-ó h
r!   rÂ   )Ú
contextlibr   Úinspectr   r¡   Únumpyr)   Úscipy.optimizer   r   r   r   Úscipy.optimize._constraintsr	   Úsettingsr   r   Úutilsr   r   r   r   rC   rc   r“   rÂ   r(   r!   r   ú<module>rC     so   ðÝ Ý Û ã ÷ó õ ;÷ -ß 2Ý !÷Wñ W÷t]Gñ ]G÷@dñ d÷NbDñ bD÷Jv

ò v

r!   