§
    fŠtj·à  ã                   óÎ   — 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mZmZmZ ddlmZmZmZmZmZ ddlmZmZmZmZmZmZ 	 	 	 	 	 dd	„Zd
„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$dS )é    N)ÚBoundsÚLinearConstraintÚNonlinearConstraintÚOptimizeResulté   )ÚTrustRegion)ÚObjectiveFunctionÚBoundConstraintsÚLinearConstraintsÚNonlinearConstraintsÚProblem)ÚMaxEvalErrorÚTargetSuccessÚCallbackSuccessÚFeasibleSuccessÚexact_1d_array)Ú
ExitStatusÚOptionsÚ	ConstantsÚDEFAULT_OPTIONSÚDEFAULT_CONSTANTSÚPRINT_OPTIONS© c                 ó˜  — |€i }nt          |¦  «        }|                     t          j        t          t          j                 ¦  «        }t          |¦  «        }|                     t          j        t          t          j                 ¦  «        }	t          |	¦  «        }	|                     t          j        t          t          j                 ¦  «        }
t          |
¦  «        }
|                     t          j	        t          t          j	                 ¦  «        }t          |¦  «        }t          j
        |v r%|t          j
                 dk    rt          d¦  «        ‚|                     t          j
        t          t          j
                 ¦  «        }t          |¦  «        }t          j        |v r%|t          j                 dk    rt          d¦  «        ‚|                     t          j        t          t          j                 ¦  «        }t          |¦  «        }|                     t          j        t          t          j                 ¦  «        }t          |¦  «        }t          |t           ¦  «        s|f}t#          | ||g|¢R Ž }t%          |d¦  «        s|g}t'          |¦  «        }t)          t+          ||¦  «        ¦  «        }t-          |¦  «        \  }}t/          |||¦  «        }t1          |||¦  «        }t3          |||||||	|
||||¦  «        }t5          ||j        ¦  «         t9          di |¤Ž}|j        j        st?          |ddt@          j!        d|¦  «        S |j        dk    rt?          |ddt@          j"        d|¦  «        S |r©tG          d	¦  «         tG          d
|t          j$                 › d�¦  «         tG          d|t          j%                 › d�¦  «         tG          d|t          j&                 › d�¦  «         tG          d|t          j'                 › d�¦  «         tG          ¦   «          	 tQ          |||¦  «        }nÜ# tR          $ r! t?          |ddt@          j*        d|¦  «        cY S tV          $ r! t?          |ddt@          j,        d|¦  «        cY S tZ          $ r! t?          |ddt@          j.        d|¦  «        cY S t^          $ r! t?          |ddt@          j0        d|¦  «        cY S tb          j2        j3        $ r! t?          |ddt@          j4        d|¦  «        cY S w xY wd}d}d}d}d}d}	 ||t          j'                 k    rt@          j0        }�ni|dz  }tb          j2         5                    |j6        |j7        j8        j9        z
  ¦  «        |tt          j;                 |j<        z  k    r| =                    |¦  «         |j<        }| >                    |¦  «        \  } }!| |!z   }"tb          j2         5                    |"¦  «        }#|#|tt          j?                 |j@        z  k    rÓ|xj<        |tt          jA                 z  c_<        ||j@        k    rd}d}n|dz  }|dz  }|#d|j@        z  k    rd}|dk    p|dk    }$|$rd}d}d}%�nM	 | B                    ¦   «         \  }}&n'# tb          j2        j3        $ r t@          j4        }Y �n w xY w|&t‡          |j<        |tt          jD                 |j@        z  ¦  «        k    }%�nÚ| E                    |"¦  «        }'|'�r¾	 t�          |||"|¦  «        \  }(})}*nk# tR          $ r t@          j*        }d}Y �n~tZ          $ r t@          j.        }d}Y �ndtV          $ r t@          j,        }d}Y �nJt^          $ r t@          jG        }Y �n2w xY w| H                    |j6        |jI        |jJ        |jK        ¦  «        }+| H                    |j6        |"z   |(|)|*¦  «        },|jL        dk    �r|,|+k    rÿtb          j2         5                    | ¦  «        |tt          jM                 dz  |j<        z  k    rÁ| N                    |"|¦  «        }-tb          j2         5                    |-¦  «        dk    rˆ|"|-z  }"	 t�          |||"|¦  «        \  }(})}*nk# tR          $ r t@          j*        }d}Y �n!tZ          $ r t@          j.        }d}Y �ntV          $ r t@          j,        }d}Y �nít^          $ r t@          jG        }Y �nÕw xY w| O                    |"|(|)|*¦  «        }.	 | B                    |j6        |"z   ¦  «        d         }n'# tb          j2        j3        $ r t@          j4        }Y �nqw xY w	 |j7         P                    ||j6        |"z   |(|)|*¦  «        }/n'# tb          j2        j3        $ r t@          j4        }Y �n"w xY w| Q                    ¦   «          | R                    |"|.¦  «         |j<        |j@        k    �r%|.|tt          jS                 k    rd}�n|dz  }|j7         T                    |j6        ¦  «        }0	 |j7         U                    |j6        ¦  «        }1n'# tb          j2        j3        $ r t@          j4        }Y �naw xY wtb          j2         5                    |0¦  «        |tt          jV                 tb          j2         5                    |1¦  «        z  k     rd}|dk    rD	 |j7         W                    ¦   «          n'# tb          j2        j3        $ r t@          j4        }Y �nÄw xY wd}| X                    |j6        |"z   ¦  «         	 | B                    ¦   «         \  }}&n'# tb          j2        j3        $ r t@          j4        }Y �new xY w|/pF|.|tt          jY                 k    o0|&t‡          |j<        |tt          jD                 |j@        z  ¦  «        k    }%||j@        k    o|.|tt          jY                 k    o|% }$nd}$d}%|$rÉ|j@        |t          j%                 k    rd}t@          jZ        }�nÂ| [                    |¦  «         | \                    ¦   «          |rs| ]                    |j6        |jJ        |jK        ¦  «        }2t½          d|j@        › �|| _                    |j6        ¦  «        |jI        |2|j`        |¦  «         tG          ¦   «          |%�r	 | a                    ||¦  «        }"n&# tb          j2        j3        $ r t@          j4        }Y nçw xY w	 t�          |||"|¦  «        \  }(})}*ng# tR          $ r t@          j*        }d}Y n±tZ          $ r t@          j.        }d}Y n˜tV          $ r t@          j,        }d}Y nt^          $ r t@          jG        }Y nhw xY w	 |j7         P                    ||j6        |"z   |(|)|*¦  «         n&# tb          j2        j3        $ r t@          j4        }Y nw xY w| Q                    ¦   «          �Œ�t?          ||jb        ||||¦  «        S )a¡?  
    Minimize a scalar function using the COBYQA method.

    The Constrained Optimization BY Quadratic Approximations (COBYQA) method is
    a derivative-free optimization method designed to solve general nonlinear
    optimization problems. A complete description of COBYQA is given in [3]_.

    Parameters
    ----------
    fun : {callable, None}
        Objective function to be minimized.

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

        where ``x`` is an array with shape (n,) and `args` is a tuple. If `fun`
        is ``None``, the objective function is assumed to be the zero function,
        resulting in a feasibility problem.
    x0 : array_like, shape (n,)
        Initial guess.
    args : tuple, optional
        Extra arguments passed to the objective function.
    bounds : {`scipy.optimize.Bounds`, array_like, shape (n, 2)}, optional
        Bound constraints of the problem. It can be one of the cases below.

        #. An instance of `scipy.optimize.Bounds`. For the time being, the
           argument ``keep_feasible`` is disregarded, and all the constraints
           are considered unrelaxable and will be enforced.
        #. An array with shape (n, 2). The bound constraints for ``x[i]`` are
           ``bounds[i][0] <= x[i] <= bounds[i][1]``. Set ``bounds[i][0]`` to
           :math:`-\infty` if there is no lower bound, and set ``bounds[i][1]``
           to :math:`\infty` if there is no upper bound.

        The COBYQA method always respect the bound constraints.
    constraints : {Constraint, list}, optional
        General constraints of the problem. It can be one of the cases below.

        #. An instance of `scipy.optimize.LinearConstraint`. The argument
           ``keep_feasible`` is disregarded.
        #. An instance of `scipy.optimize.NonlinearConstraint`. The arguments
           ``jac``, ``hess``, ``keep_feasible``, ``finite_diff_rel_step``, and
           ``finite_diff_jac_sparsity`` are disregarded.

        #. A list, each of whose elements are described in the cases above.

    callback : callable, optional
        A callback executed at each objective function evaluation. The method
        terminates if a ``StopIteration`` exception is raised by the callback
        function. Its signature can be one of the following:

            ``callback(intermediate_result)``

        where ``intermediate_result`` is a keyword parameter that contains an
        instance of `scipy.optimize.OptimizeResult`, with attributes ``x``
        and ``fun``, being the point at which the objective function is
        evaluated and the value of the objective function, respectively. The
        name of the parameter must be ``intermediate_result`` for the callback
        to be passed an instance of `scipy.optimize.OptimizeResult`.

        Alternatively, the callback function can have the signature:

            ``callback(xk)``

        where ``xk`` is the point at which the objective function is evaluated.
        Introspection is used to determine which of the signatures to invoke.
    options : dict, optional
        Options passed to the solver. Accepted keys are:

            disp : bool, optional
                Whether to print information about the optimization procedure.
                Default is ``False``.
            maxfev : int, optional
                Maximum number of function evaluations. Default is ``500 * n``.
            maxiter : int, optional
                Maximum number of iterations. Default is ``1000 * n``.
            target : float, optional
                Target on the objective function value. The optimization
                procedure is terminated when the objective function value of a
                feasible point is less than or equal to this target. Default is
                ``-numpy.inf``.
            feasibility_tol : float, optional
                Tolerance on the constraint violation. If the maximum
                constraint violation at a point is less than or equal to this
                tolerance, the point is considered feasible. Default is
                ``numpy.sqrt(numpy.finfo(float).eps)``.
            radius_init : float, optional
                Initial trust-region radius. Typically, this value should be in
                the order of one tenth of the greatest expected change to `x0`.
                Default is ``1.0``.
            radius_final : float, optional
                Final trust-region radius. It should indicate the accuracy
                required in the final values of the variables. Default is
                ``1e-6``.
            nb_points : int, optional
                Number of interpolation points used to build the quadratic
                models of the objective and constraint functions. Default is
                ``2 * n + 1``.
            scale : bool, optional
                Whether to scale the variables according to the bounds. Default
                is ``False``.
            filter_size : int, optional
                Maximum number of points in the filter. The filter is used to
                select the best point returned by the optimization procedure.
                Default is ``sys.maxsize``.
            store_history : bool, optional
                Whether to store the history of the function evaluations.
                Default is ``False``.
            history_size : int, optional
                Maximum number of function evaluations to store in the history.
                Default is ``sys.maxsize``.
            debug : bool, optional
                Whether to perform additional checks during the optimization
                procedure. This option should be used only for debugging
                purposes and is highly discouraged to general users. Default is
                ``False``.

        Other constants (from the keyword arguments) are described below. They
        are not intended to be changed by general users. They should only be
        changed by users with a deep understanding of the algorithm, who want
        to experiment with different settings.

    Returns
    -------
    `scipy.optimize.OptimizeResult`
        Result of the optimization procedure, with the following fields:

            message : str
                Description of the cause of the termination.
            success : bool
                Whether the optimization procedure terminated successfully.
            status : int
                Termination status of the optimization procedure.
            x : `numpy.ndarray`, shape (n,)
                Solution point.
            fun : float
                Objective function value at the solution point.
            maxcv : float
                Maximum constraint violation at the solution point.
            nfev : int
                Number of function evaluations.
            nit : int
                Number of iterations.

        If ``store_history`` is True, the result also has the following fields:

            fun_history : `numpy.ndarray`, shape (nfev,)
                History of the objective function values.
            maxcv_history : `numpy.ndarray`, shape (nfev,)
                History of the maximum constraint violations.

        A description of the termination statuses is given below.

        .. list-table::
            :widths: 25 75
            :header-rows: 1

            * - Exit status
              - Description
            * - 0
              - The lower bound for the trust-region radius has been reached.
            * - 1
              - The target objective function value has been reached.
            * - 2
              - All variables are fixed by the bound constraints.
            * - 3
              - The callback requested to stop the optimization procedure.
            * - 4
              - The feasibility problem received has been solved successfully.
            * - 5
              - The maximum number of function evaluations has been exceeded.
            * - 6
              - The maximum number of iterations has been exceeded.
            * - -1
              - The bound constraints are infeasible.
            * - -2
              - A linear algebra error occurred.

    Other Parameters
    ----------------
    decrease_radius_factor : float, optional
        Factor by which the trust-region radius is reduced when the reduction
        ratio is low or negative. Default is ``0.5``.
    increase_radius_factor : float, optional
        Factor by which the trust-region radius is increased when the reduction
        ratio is large. Default is ``numpy.sqrt(2.0)``.
    increase_radius_threshold : float, optional
        Threshold that controls the increase of the trust-region radius when
        the reduction ratio is large. Default is ``2.0``.
    decrease_radius_threshold : float, optional
        Threshold used to determine whether the trust-region radius should be
        reduced to the resolution. Default is ``1.4``.
    decrease_resolution_factor : float, optional
        Factor by which the resolution is reduced when the current value is far
        from its final value. Default is ``0.1``.
    large_resolution_threshold : float, optional
        Threshold used to determine whether the resolution is far from its
        final value. Default is ``250.0``.
    moderate_resolution_threshold : float, optional
        Threshold used to determine whether the resolution is close to its
        final value. Default is ``16.0``.
    low_ratio : float, optional
        Threshold used to determine whether the reduction ratio is low. Default
        is ``0.1``.
    high_ratio : float, optional
        Threshold used to determine whether the reduction ratio is high.
        Default is ``0.7``.
    very_low_ratio : float, optional
        Threshold used to determine whether the reduction ratio is very low.
        This is used to determine whether the models should be reset. Default
        is ``0.01``.
    penalty_increase_threshold : float, optional
        Threshold used to determine whether the penalty parameter should be
        increased. Default is ``1.5``.
    penalty_increase_factor : float, optional
        Factor by which the penalty parameter is increased. Default is ``2.0``.
    short_step_threshold : float, optional
        Factor used to determine whether the trial step is too short. Default
        is ``0.5``.
    low_radius_factor : float, optional
        Factor used to determine which interpolation point should be removed
        from the interpolation set at each iteration. Default is ``0.1``.
    byrd_omojokun_factor : float, optional
        Factor by which the trust-region radius is reduced for the computations
        of the normal step in the Byrd-Omojokun composite-step approach.
        Default is ``0.8``.
    threshold_ratio_constraints : float, optional
        Threshold used to determine which constraints should be taken into
        account when decreasing the penalty parameter. Default is ``2.0``.
    large_shift_factor : float, optional
        Factor used to determine whether the point around which the quadratic
        models are built should be updated. Default is ``10.0``.
    large_gradient_factor : float, optional
        Factor used to determine whether the models should be reset. Default is
        ``10.0``.
    resolution_factor : float, optional
        Factor by which the resolution is decreased. Default is ``2.0``.
    improve_tcg : bool, optional
        Whether to improve the steps computed by the truncated conjugate
        gradient method when the trust-region boundary is reached. Default is
        ``True``.

    References
    ----------
    .. [1] J. Nocedal and S. J. Wright. *Numerical Optimization*. Springer Ser.
       Oper. Res. Financ. Eng. Springer, New York, NY, USA, second edition,
       2006. `doi:10.1007/978-0-387-40065-5
       <https://doi.org/10.1007/978-0-387-40065-5>`_.
    .. [2] M. J. D. Powell. A direct search optimization method that models the
       objective and constraint functions by linear interpolation. In S. Gomez
       and J.-P. Hennart, editors, *Advances in Optimization and Numerical
       Analysis*, volume 275 of Math. Appl., pages 51--67. Springer, Dordrecht,
       Netherlands, 1994. `doi:10.1007/978-94-015-8330-5_4
       <https://doi.org/10.1007/978-94-015-8330-5_4>`_.
    .. [3] T. M. Ragonneau. *Model-Based Derivative-Free Optimization Methods
       and Software*. PhD thesis, Department of Applied Mathematics, The Hong
       Kong Polytechnic University, Hong Kong, China, 2022. URL:
       https://theses.lib.polyu.edu.hk/handle/200/12294.

    Examples
    --------
    To demonstrate how to use `minimize`, we first minimize the Rosenbrock
    function implemented in `scipy.optimize` in an unconstrained setting.

    .. testsetup::

        import numpy as np
        np.set_printoptions(precision=3, suppress=True)

    >>> from cobyqa import minimize
    >>> from scipy.optimize import rosen

    To solve the problem using COBYQA, run:

    >>> x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
    >>> res = minimize(rosen, x0)
    >>> res.x
    array([1., 1., 1., 1., 1.])

    To see how bound and constraints are handled using `minimize`, we solve
    Example 16.4 of [1]_, defined as

    .. math::

        \begin{aligned}
            \min_{x \in \mathbb{R}^2}   & \quad (x_1 - 1)^2 + (x_2 - 2.5)^2\\
            \text{s.t.}                 & \quad -x_1 + 2x_2 \le 2,\\
                                        & \quad x_1 + 2x_2 \le 6,\\
                                        & \quad x_1 - 2x_2 \le 2,\\
                                        & \quad x_1 \ge 0,\\
                                        & \quad x_2 \ge 0.
        \end{aligned}

    >>> import numpy as np
    >>> from scipy.optimize import Bounds, LinearConstraint

    Its objective function can be implemented as:

    >>> def fun(x):
    ...     return (x[0] - 1.0)**2 + (x[1] - 2.5)**2

    This problem can be solved using `minimize` as:

    >>> x0 = [2.0, 0.0]
    >>> bounds = Bounds([0.0, 0.0], np.inf)
    >>> constraints = LinearConstraint([
    ...     [-1.0, 2.0],
    ...     [1.0, 2.0],
    ...     [1.0, -2.0],
    ... ], -np.inf, [2.0, 6.0, 2.0])
    >>> res = minimize(fun, x0, bounds=bounds, constraints=constraints)
    >>> res.x
    array([1.4, 1.7])

    To see how nonlinear constraints are handled, we solve Problem (F) of [2]_,
    defined as

    .. math::

        \begin{aligned}
            \min_{x \in \mathbb{R}^2}   & \quad -x_1 - x_2\\
            \text{s.t.}                 & \quad x_1^2 - x_2 \le 0,\\
                                        & \quad x_1^2 + x_2^2 \le 1.
        \end{aligned}

    >>> from scipy.optimize import NonlinearConstraint

    Its objective and constraint functions can be implemented as:

    >>> def fun(x):
    ...     return -x[0] - x[1]
    >>>
    >>> def cub(x):
    ...     return [x[0]**2 - x[1], x[0]**2 + x[1]**2]

    This problem can be solved using `minimize` as:

    >>> x0 = [1.0, 1.0]
    >>> constraints = NonlinearConstraint(cub, -np.inf, [0.0, 1.0])
    >>> res = minimize(fun, x0, constraints=constraints)
    >>> res.x
    array([0.707, 0.707])

    Finally, to see how to supply linear and nonlinear constraints
    simultaneously, we solve Problem (G) of [2]_, defined as

    .. math::

        \begin{aligned}
            \min_{x \in \mathbb{R}^3}   & \quad x_3\\
            \text{s.t.}                 & \quad 5x_1 - x_2 + x_3 \ge 0,\\
                                        & \quad -5x_1 - x_2 + x_3 \ge 0,\\
                                        & \quad x_1^2 + x_2^2 + 4x_2 \le x_3.
        \end{aligned}

    Its objective and nonlinear constraint functions can be implemented as:

    >>> def fun(x):
    ...     return x[2]
    >>>
    >>> def cub(x):
    ...     return x[0]**2 + x[1]**2 + 4.0*x[1] - x[2]

    This problem can be solved using `minimize` as:

    >>> x0 = [1.0, 1.0, 1.0]
    >>> constraints = [
    ...     LinearConstraint(
    ...         [[5.0, -1.0, 1.0], [-5.0, -1.0, 1.0]],
    ...         [0.0, 0.0],
    ...         np.inf,
    ...     ),
    ...     NonlinearConstraint(cub, -np.inf, 0.0),
    ... ]
    >>> res = minimize(fun, x0, constraints=constraints)
    >>> res.x
    array([ 0., -3., -3.])
    Nr   z)The size of the history must be positive.z(The size of the filter must be positive.Ú__len__ç        FTz$Starting the optimization procedure.zInitial trust-region radius: ú.zFinal trust-region radius: z(Maximum number of function evaluations: zMaximum number of iterations: r   gš™™™™™¹?é   é   znonlinearly constrainedç       @zNew trust-region radius: r   )cÚdictÚgetr   ÚVERBOSEr   ÚboolÚFEASIBILITY_TOLÚfloatÚSCALEÚSTORE_HISTORYÚHISTORY_SIZEÚ
ValueErrorÚintÚFILTER_SIZEÚDEBUGÚ
isinstanceÚtupler	   ÚhasattrÚlenr
   Ú_get_boundsÚ_get_constraintsr   r   r   Ú_set_default_optionsÚnÚ_set_default_constantsÚboundsÚis_feasibleÚ_build_resultr   ÚINFEASIBLE_ERRORÚFIXED_SUCCESSÚprintÚRHOBEGÚRHOENDÚMAX_EVALÚMAX_ITERr   r   ÚTARGET_SUCCESSr   ÚCALLBACK_SUCCESSr   ÚFEASIBLE_SUCCESSr   ÚMAX_ITER_WARNINGÚnpÚlinalgÚLinAlgErrorÚLINALG_ERRORÚnormÚx_bestÚmodelsÚinterpolationÚx_baser   ÚLARGE_SHIFT_FACTORÚradiusÚshift_x_baseÚget_trust_region_stepÚSHORT_STEP_THRESHOLDÚ
resolutionÚDECREASE_RESOLUTION_FACTORÚget_index_to_removeÚmaxÚRESOLUTION_FACTORÚincrease_penaltyÚ_evalÚMAX_EVAL_WARNINGÚmeritÚfun_bestÚcub_bestÚceq_bestÚtypeÚBYRD_OMOJOKUN_FACTORÚ get_second_order_correction_stepÚget_reduction_ratioÚupdate_interpolationÚset_best_indexÚupdate_radiusÚVERY_LOW_RATIOÚfun_gradÚfun_alt_gradÚLARGE_GRADIENT_FACTORÚreset_modelsÚset_multipliersÚ	LOW_RATIOÚRADIUS_SUCCESSÚenhance_resolutionÚdecrease_penaltyÚmaxcvÚ_print_stepÚbuild_xÚn_evalÚget_geometry_stepÚpenalty)3ÚfunÚx0Úargsr7   ÚconstraintsÚcallbackÚoptionsÚkwargsÚverboseÚfeasibility_tolÚscaleÚstore_historyÚhistory_sizeÚfilter_sizeÚdebugÚobjÚn_origÚlinear_constraintsÚnonlinear_constraintsÚlinearÚ	nonlinearÚpbÚ	constantsÚ	frameworkÚsuccessÚn_iterÚk_newÚn_short_stepsÚn_very_short_stepsÚn_alt_modelsÚstatusÚradius_saveÚnormal_stepÚtangential_stepÚstepÚs_normrn   Úimprove_geometryÚdist_newÚsame_best_pointÚfun_valÚcub_valÚceq_valÚ	merit_oldÚ	merit_newÚsoc_stepÚratioÚill_conditionedÚgradÚgrad_altÚ	maxcv_vals3                                                      úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/_lib/cobyqa/main.pyÚminimizer¨   $   sò  € ðF €Øˆˆå�w‘-”-ˆØ�kŠk�'œ/­?½7¼?Ô+KÑLÔL€GÝ�7‰mŒm€GØ—k’kÝÔÝ�Ô/Ô0ñô €Oõ ˜OÑ,Ô,€OØ�KŠK�œ¥µw´}Ô'EÑFÔF€EÝ�‰KŒK€EØ—K’KÝÔÝ�Ô-Ô.ñô €Mõ ˜Ñ'Ô'€MÝÔ˜wÐ&Ð&¨7µ7Ô3GÔ+HÈAÒ+MÐ+MÝÐDÑEÔEÐEØ—;’;ÝÔÝ�Ô,Ô-ñô €Lõ �|Ñ$Ô$€LÝÔ˜gÐ%Ð%¨'µ'Ô2EÔ*FÈ!Ò*KÐ*KÝÐCÑDÔDÐDØ—+’+ÝÔÝ�Ô+Ô,ñô €Kõ �kÑ"Ô"€KØ�KŠK�œ¥µw´}Ô'EÑFÔF€EÝ�‰KŒK€Eõ �d�EÑ"Ô"ð ØˆwˆÝ
˜C ¨%Ð
7°$Ð
7Ð
7Ð
7€Cõ �2�yÑ!Ô!ð ØˆTˆÝ�‰WŒW€FÝ�k¨&°&Ñ9Ô9Ñ:Ô:€Fõ 1AÀÑ0MÔ0MÑ-ÐÐ-ÝÐ1°6¸5ÑAÔA€FÝ$Ð%:¸GÀUÑKÔK€Iõ 
ØØ
ØØØØØØØØØØñ
ô 
€Bõ  ˜ "¤$Ñ'Ô'Ð'Ý&Ð0Ð0¨Ð0Ð0€Ið Œ9Ô ð 
åØØØÝÔ'ØØñ
ô 
ð 	
ð 
Œ�ŠˆåØØØÝÔ$ØØñ
ô 
ð 	
ð ð 	ÝÐ4Ñ5Ô5Ð5ÝÐH¨gµg´nÔ.EÐHÐHÐHÑIÔIÐIÝÐF¨GµG´NÔ,CÐFÐFÐFÑGÔGÐGÝð,Ø•wÔ'Ô(ð,ð ,ð ,ñ	
ô 	
ð 	
õ 	ÐK¨wµwÔ7GÔ/HÐKÐKÐKÑLÔLÐLÝ‰Œˆð3
Ý  G¨YÑ7Ô7ˆ	ˆ	øÝð 	
ð 	
ð 	
åØØØÝÔ%ØØñ
ô 
ð 	
ð 	
ð 	
õ ð 	
ð 	
ð 	
åØØØÝÔ'ØØñ
ô 
ð 	
ð 	
ð 	
õ ð 	
ð 	
ð 	
åØØØÝÔ'ØØñ
ô 
ð 	
ð 	
ð 	
õ ð 	
ð 	
ð 	
åØØØÝÔ'ØØñ
ô 
ð 	
ð 	
ð 	
õ Œ9Ô ð 	
ð 	
ð 	
åØØØÝÔ#ØØñ
ô 
ð 	
ð 	
ð 	
ð	
øøøð €GØ€FØ€EØ€MØÐØ€Lð\'ð �W�WÔ-Ô.Ò.Ð.ÝÔ0ˆFÙØ�!‰ˆõ ŒI�NŠNØÔ  9Ô#3Ô#AÔ#HÑHñô ð �Ô5Ô6¸Ô9IÑIòJð Jð
 ×"Ò" 7Ñ+Ô+Ð+ð  Ô&ˆØ'0×'FÒ'FÀwÑ'OÔ'OÑ$ˆ�_Ø˜_Ñ,ˆÝ”—’ Ñ%Ô%ˆð Ø�Ô7Ô8¸9Ô;OÑOòPð Pð ÐÔ 	­)Ô*NÔ OÑOÐÔØ˜YÔ1Ò1Ð1Ø !�Ø%&Ð"Ð"à Ñ"�Ø" aÑ'Ð"Ø˜C )Ô"6Ñ6Ò6Ð6Ø)*Ð&Ø!.°!Ò!3Ð!NÐ7IÈQÒ7NÐØ!ð Ø !�Ø%&Ð"Ø#(Ð Ñ ðØ&/×&CÒ&CÑ&EÔ&E‘O�E˜8˜8øÝ”yÔ,ð ð ð Ý'Ô4�FØ‘Eðøøøð $,­cØÔ$Ø�iÔ9Ô:ØÔ*ñ+ñ/ô /ò $Ð Ñ ð (×8Ò8¸Ñ>Ô>ˆOØñ ])ðÝ05ØØ!ØØñ	1ô 1Ñ-�G˜W g gøõ %ð ð ð Ý'Ô6�FØ"�GØ‘EÝ&ð ð ð Ý'Ô8�FØ"�GØ‘EÝ&ð ð ð Ý'Ô8�FØ"�GØ‘EÝ#ð ð ð Ý'Ô8�FØ‘Eðøøøð
 &ŸOšOØÔ$ØÔ&ØÔ&ØÔ&ñ	ô �	ð &ŸOšOØÔ$ tÑ+¨W°g¸wñô �	ð ”GÐ8Ò8Ñ8Ø! IÒ-Ð-Ýœ	Ÿš {Ñ3Ô3Ø¥	Ô >Ô?À3ÑFØÔ&ñ'ò'ð 'ð  )×IÒIØ˜gñ ô  �Hõ ”y—~’~ hÑ/Ô/°#Ò5Ð5Ø Ñ(˜ð"Ý8=Ø "Ø )Ø $Ø 'ñ	9ô 9Ñ5˜G W¨g¨gøõ  -ð "ð "ð "Ý%/Ô%>˜FØ&*˜GØ!™EÝ.ð "ð "ð "Ý%/Ô%@˜FØ&*˜GØ!™EÝ.ð "ð "ð "Ý%/Ô%@˜FØ&*˜GØ!™EÝ+ð "ð "ð "Ý%/Ô%@˜FØ!™Eð"øøøð
 "×5Ò5ØØØØñ	ô �ðØ%×9Ò9Ø!Ô(¨4Ñ/ñô àô�E�Eøõ ”yÔ,ð ð ð Ý'Ô4�FØ‘Eðøøøð
Ø&/Ô&6×&KÒ&KØ˜yÔ/°$Ñ6¸ÀØñ'ô '�O�Oøõ ”yÔ,ð ð ð Ý'Ô4�FØ‘Eðøøøð ×(Ò(Ñ*Ô*Ð*ð ×'Ò'¨¨eÑ4Ô4Ð4ð Ô# yÔ';Ò;Ñ;Ø 	­)Ô*BÔ CÒCÐCØ'(˜™à$¨Ñ)˜Ø(Ô/×8Ò8¸Ô9IÑJÔJ˜ð"Ø'0Ô'7×'DÒ'DØ )Ô 0ñ(ô (˜H˜Høõ  "œyÔ4ð "ð "ð "Ý%/Ô%<˜FØ!™Eð"øøøõ œ9Ÿ>š>¨$Ñ/Ô/°)Ý%Ô;ô3åœIŸNšN¨8Ñ4Ô4ñ35ò 5ð 5ð ,-˜LØ'¨1Ò,Ð,ð&Ø )Ô 0× =Ò =Ñ ?Ô ?Ð ?Ð ?øÝ#%¤9Ô#8ð &ð &ð &Ý)3Ô)@ Ø %¡ð&øøøð ,-˜Lð ×)Ò)¨)Ô*:¸TÑ*AÑBÔBÐBðØ&/×&CÒ&CÑ&EÔ&E‘O�E˜8˜8øÝ”yÔ,ð ð ð Ý'Ô4�FØ‘Eðøøøð $ð Ø 	­)Ô*=Ô >Ò>ð Ø ÝØ!Ô(Ø!¥)Ô"=Ô>Ø#Ô.ñ/ñô òð !ð   9Ô#7Ò7ð -Ø ­9Ô+>Ô!?Ò?ð-à,Ð,ð #Ð"ð &+Ð"Ø#(Ð ð ð 	ØÔ# w­w¬~Ô'>Ò>Ð>Ø�Ý#Ô2�ÙØ×(Ò(¨Ñ1Ô1Ð1Ø×&Ò&Ñ(Ô(Ð(àð ØŸHšHØÔ$ iÔ&8¸)Ô:Lñô �	õ ØF°	Ô0DÐFÐFØØ—J’J˜yÔ/Ñ0Ô0ØÔ&ØØ”IØñô ð õ ‘”�ð ñ &	'ðØ ×2Ò2°5¸'ÑBÔB��øÝ”9Ô(ð ð ð Ý#Ô0�Ø�ðøøøð
Ý,1°"°iÀÀwÑ,OÔ,OÑ)�˜ ' 'øÝ ð ð ð Ý#Ô2�Ø�Ø�Ý"ð ð ð Ý#Ô4�Ø�Ø�Ý"ð ð ð Ý#Ô4�Ø�Ø�Ýð ð ð Ý#Ô4�Ø�ðøøøð

ØÔ ×5Ò5ØØÔ$ tÑ+ØØØñô ð ð øõ ”9Ô(ð ð ð Ý#Ô0�Ø�ðøøøð ×$Ò$Ñ&Ô&Ð&ñy\'õ| Ø
ØÔØØØØñô ð s&  Ð+P= Ð=(TÑ''TÒ'TÒ9'TÓ"1TÔTÙ8Z Ú Z4Ú3Z4Ü\ Ü^Ü5^Ý^Ý)^Þ^á a7 á7câcâ,cãcãcã;#d ä eåeå&e. å. fæfèh/ è/ iéiê2k ë k0ë/k0ìl+ ì+ mímòr* ò* sósós( ó(uôuôuô4uõuõ&u7 õ7 vövc                 óJ  — | €Kt          t          j        |t          j         ¦  «        t          j        |t          j        ¦  «        ¦  «        S t	          | t           ¦  «        rO| j        j        |fk    s| j        j        |fk    rt          d|› d�¦  «        ‚t          | j        | j        ¦  «        S t          | d¦  «        rTt          j
        | ¦  «        } | j        |dfk    rt          d¦  «        ‚t          | dd…df         | dd…df         ¦  «        S t          d	¦  «        ‚)
z 
    Uniformize the bounds.
    NzThe bounds must have z
 elements.r   é   zGThe shape of the bounds is not compatible with the number of variables.r   r   zPThe bounds must be an instance of scipy.optimize.Bounds or an array-like object.)r   rE   ÚfullÚinfr.   ÚlbÚshapeÚubr*   r0   ÚasarrayÚ	TypeError)r7   r5   s     r§   r2   r2   q  s"  € ð €~Ý•b”g˜a¥"¤& Ñ)Ô)­2¬7°1µb´fÑ+=Ô+=Ñ>Ô>Ð>Ý	�F�FÑ	#Ô	#ð 
ØŒ9Œ?˜q˜dÒ"Ð" f¤i¤o¸!¸Ò&=Ð&=ÝÐB°QÐBÐBÐBÑCÔCÐCÝ�f”i ¤Ñ+Ô+Ð+Ý	�˜Ñ	#Ô	#ð 
Ý”˜FÑ#Ô#ˆØŒ<˜A˜q˜6Ò!Ð!Ýð+ñô ð õ �f˜Q˜Q˜Q ˜T”l F¨1¨1¨1¨a¨4¤LÑ1Ô1Ð1åð=ñ
ô 
ð 	
ó    c           
      ó”  — t          | t          ¦  «        st          | d¦  «        s| f} g }g }| D �]•}t          |t          ¦  «        rct	          |j        d¦  «        }t	          |j        d¦  «        }|                     t          |j        gt          j
        ||¦  «        ¢R Ž ¦  «         Œ{t          |t          ¦  «        rct	          |j        d¦  «        }t	          |j        d¦  «        }|                     t          |j        gt          j
        ||¦  «        ¢R Ž ¦  «         Œót          |t          ¦  «        r€d|vs
|d         dvrt          d¦  «        ‚d	|vst          |d	         ¦  «        st          d
¦  «        ‚|                     |d	         |d         |                     dd¦  «        dœ¦  «         �Œˆt!          d¦  «        ‚||fS )z7
    Extract the linear and nonlinear constraints.
    r   z;The lower bound of the linear constraints must be a vector.z;The upper bound of the linear constraints must be a vector.z>The lower bound of the nonlinear constraints must be a vector.z>The upper bound of the nonlinear constraints must be a vector.r_   )ÚeqÚineqz+The constraint type must be "eq" or "ineq".rv   z)The constraint function must be callable.rx   r   )rv   r_   rx   zrThe constraints must be instances of scipy.optimize.LinearConstraint, scipy.optimize.NonlinearConstraint, or dict.)r.   r!   r0   r   r   r­   r¯   ÚappendÚArE   Úbroadcast_arraysr   rv   r*   Úcallabler"   r±   )ry   r†   r‡   Ú
constraintr­   r¯   s         r§   r3   r3   Š  sO  € õ �+�tÑ$Ô$ð %­G°KÀÑ,KÔ,Kð %Ø"�nˆð ÐØÐØ!ð 7ñ 7ˆ
Ý�jÕ"2Ñ3Ô3ð 6	ÝØ”ØMñô ˆBõ  Ø”ØMñô ˆBð ×%Ò%Ý Ø”LðåÔ(¨¨RÑ0Ô0ðð ð ñô ð ð õ ˜
Õ$7Ñ8Ô8ð '	ÝØ”ðñô ˆBõ  Ø”ðñô ˆBð "×(Ò(Ý#Ø”NðåÔ(¨¨RÑ0Ô0ðð ð ñô ð ð õ ˜
¥DÑ)Ô)ð 	Ø˜ZÐ'Ð'¨:°fÔ+=ð Fð ,ð ,õ !Ð!NÑOÔOÐOØ˜JÐ&Ð&­h°zÀ%Ô7HÑ.IÔ.IÐ&Ý Ð!LÑMÔMÐMØ!×(Ò(à% eÔ,Ø& vÔ.Ø&ŸNšN¨6°2Ñ6Ô6ðð ñô ð ñ õ ð?ñô ð ð
 Ð4Ð4Ð4r²   c                 óX  — t           j        | v r%| t           j                 dk    rt          d¦  «        ‚t           j        | v r%| t           j                 dk     rt          d¦  «        ‚t           j        | v rEt           j        | v r7| t           j                 | t           j                 k     rt          d¦  «        ‚�n
t           j        | v rNt	          j        t          t           j                 | t           j                 g¦  «        | t           j        j        <   n®t           j        | v rNt	          j        t          t           j                 | t           j                 g¦  «        | t           j        j        <   nRt          t           j                 | t           j        j        <   t          t           j                 | t           j        j        <   t          | t           j                 ¦  «        | t           j        j        <   t          | t           j                 ¦  «        | t           j        j        <   t           j
        | v r%| t           j
                 dk    rt          d¦  «        ‚t           j
        | v rA| t           j
                 |dz   |dz   z  dz  k    rt          d	|dz   |dz   z  dz  › d
�¦  «        ‚|                      t           j
        j        t          t           j
                 |¦  «        ¦  «         t          | t           j
                 ¦  «        | t           j
        j        <   t           j        | v r%| t           j                 dk    rt          d¦  «        ‚|                      t           j        j        t	          j        t          t           j                 |¦  «        | t           j
                 dz   g¦  «        ¦  «         t          | t           j                 ¦  «        | t           j        j        <   t           j        | v r%| t           j                 dk    rt          d¦  «        ‚|                      t           j        j        t          t           j                 |¦  «        ¦  «         t          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t%          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t%          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t%          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t          | t           j                 ¦  «        | t           j        j        <   |                      t           j        j        t          t           j                 ¦  «         t%          | t           j                 ¦  «        | t           j        j        <   | D ]A}|t           j                             ¦   «         vrt5          j        d|› d
�t8          d¦  «         ŒBdS )z"
    Set the default options.
    r   z1The initial trust-region radius must be positive.z2The final trust-region radius must be nonnegative.z_The initial trust-region radius must be greater than or equal to the final trust-region radius.r   z4The number of interpolation points must be positive.r   rª   z3The number of interpolation points must be at most r   z<The maximum number of function evaluations must be positive.z2The maximum number of iterations must be positive.zUnknown option: r   N)r   r=   r*   r>   rE   Úminr   ÚvaluerV   r&   ÚNPTÚ
setdefaultr+   r?   r@   ÚTARGETr%   r#   r$   r'   r,   r(   r)   r-   Ú__members__ÚvaluesÚwarningsÚwarnÚRuntimeWarning)r{   r5   Úkeys      r§   r4   r4   Ï  s^  € õ „~˜Ð Ð  W­W¬^Ô%<ÀÒ%CÐ%CÝÐLÑMÔMÐMÝ„~˜Ð Ð  W­W¬^Ô%<¸sÒ%BÐ%BÝÐMÑNÔNÐNÝ„~˜Ð Ð ¥W¤^°wÐ%>Ð%>Ø•7”>Ô" W­W¬^Ô%<Ò<Ð<ÝðBñô ð ñ =õ
 
Œ˜7Ð	"Ð	"Ý(*¬å¥¤Ô/Ø�œÔ'ðñ)
ô )
ˆ•”Ô$Ñ%Ð%õ 
Œ˜7Ð	"Ð	"Ý(*¬å¥¤Ô/Ø�œÔ'ðñ)
ô )
ˆ•”Ô$Ñ%Ð%õ )8½¼Ô(Gˆ•”Ô$Ñ%Ý(7½¼Ô(Gˆ•”Ô$Ñ%Ý$)¨'µ'´.Ô*AÑ$BÔ$B€G�GŒNÔ Ñ!Ý$)¨'µ'´.Ô*AÑ$BÔ$B€G�GŒNÔ Ñ!Ý„{�gÐÐ '­'¬+Ô"6¸!Ò";Ð";Ýð %ñ &ô &ð 	&õ 	Œ�wÐÐØ•G”KÔ  Q¨¡U¨q°1©uÑ$5¸!Ñ#;Ò;Ð;åð+Ø�Q‘˜1˜q™5Ñ! aÑ'ð+ð +ð +ñ
ô 
ð 	
ð ×Ò•w”{Ô(­/½'¼+Ô*FÀqÑ*IÔ*IÑJÔJÐJÝ!$ W­W¬[Ô%9Ñ!:Ô!:€G�GŒKÔÑÝÔ˜7Ð"Ð" w­wÔ/?Ô'@ÀAÒ'EÐ'EÝØJñ
ô 
ð 	
ð ×ÒÝÔÔÝ
Œå¥Ô 0Ô1°!Ñ4Ô4Ø�œÔ$ qÑ(ðñ	
ô 	
ñô ð õ '*¨'µ'Ô2BÔ*CÑ&DÔ&D€G�GÔÔ"Ñ#ÝÔ˜7Ð"Ð" w­wÔ/?Ô'@ÀAÒ'EÐ'EÝÐMÑNÔNÐNØ×ÒÝÔÔÝ�Ô(Ô)¨!Ñ,Ô,ñô ð õ '*¨'µ'Ô2BÔ*CÑ&DÔ&D€G�GÔÔ"Ñ#Ø×Ò•w”~Ô+­_½W¼^Ô-LÑMÔMÐMÝ$)¨'µ'´.Ô*AÑ$BÔ$B€G�GŒNÔ Ñ!Ø×ÒÝÔÔ%Ý�Ô/Ô0ñô ð õ .3Ø•Ô'Ô(ñ.ô .€G�GÔ#Ô)Ñ*ð ×Ò•w”Ô,­o½g¼oÔ.NÑOÔOÐOÝ%)¨'µ'´/Ô*BÑ%CÔ%C€G�GŒOÔ!Ñ"Ø×Ò•w”}Ô*­O½G¼MÔ,JÑKÔKÐKÝ#'¨µ´Ô(>Ñ#?Ô#?€G�GŒMÔÑ Ø×ÒÝÔÔ!Ý�Ô+Ô,ñô ð õ *-¨WµWÔ5HÔ-IÑ)JÔ)J€G�GÔÔ%Ñ&Ø×ÒÝÔÔ#Ý�Ô-Ô.ñô ð õ ,0°½Ô8MÔ0NÑ+OÔ+O€G�GÔ!Ô'Ñ(Ø×ÒÝÔÔ"Ý�Ô,Ô-ñô ð õ +.¨gµgÔ6JÔ.KÑ*LÔ*L€G�GÔ Ô&Ñ'Ø×Ò•w”}Ô*­O½G¼MÔ,JÑKÔKÐKÝ#'¨µ´Ô(>Ñ#?Ô#?€G�GŒMÔÑ ð ð Hð HˆØ•gÔ)×0Ò0Ñ2Ô2Ð2Ð2ÝŒMÐ3¨SÐ3Ð3Ð3µ^ÀQÑGÔGÐGøðHð Hr²   c                  ól  — t          | ¦  «        }|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    rt          d¦  «        ‚t          j	        |v r%|t          j	                 dk    rt          d¦  «        ‚t          j
        |v r%|t          j
                 dk    rt          d¦  «        ‚t          j	        |v rEt          j
        |v r7|t          j
                 |t          j	                 k    rt          d¦  «        ‚�nt          j	        |v rTt          j        t
          t          j
                 dd|t          j	                 z   z  g¦  «        |t          j
        j        <   n±t          j
        |v rQt          j        t
          t          j	                 d	|t          j
                 z  g¦  «        |t          j	        j        <   nRt
          t          j	                 |t          j	        j        <   t
          t          j
                 |t          j
        j        <   |                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d
¦  «        ‚t          j        |v r%|t          j                 dk    rt          d¦  «        ‚t          j        |v r%|t          j                 dk    rt          d¦  «        ‚t          j        |v rEt          j        |v r7|t          j                 |t          j                 k    rt          d¦  «        ‚�n
t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   n®t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   nRt
          t          j                 |t          j        j        <   t
          t          j                 |t          j        j        <   t          j        |v r;|t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚t          j        |v r;|t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚t          j        |v rEt          j        |v r7|t          j                 |t          j                 k    rt          d¦  «        ‚�n
t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   n®t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   nRt
          t          j                 |t          j        j        <   t
          t          j                 |t          j        j        <   |                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚t          j        |v r%|t          j                 dk     rt          d¦  «        ‚t          j        |v r%|t          j                 dk    rt          d¦  «        ‚t          j        |v rEt          j        |v r7|t          j                 |t          j                 k     rt          d¦  «        ‚�n
t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   n®t          j        |v rNt          j        t
          t          j                 |t          j                 g¦  «        |t          j        j        <   nRt
          t          j                 |t          j        j        <   t
          t          j                 |t          j        j        <   |                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    s|t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk     rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t          |t          j                 ¦  «        |t          j        j        <   |t          j                 dk    rt          d¦  «        ‚|                     t          j        j        t
          t          j                 ¦  «         t=          |t          j                 ¦  «        |t          j        j        <   | D ]A}|t          j                              ¦   «         vrtC          j"        d|› d�tF          d¦  «         ŒB|S )z$
    Set the default constants.
    r   g      ð?zCThe constant decrease_radius_factor must be in the interval (0, 1).z>The constant increase_radius_threshold must be greater than 1.z;The constant increase_radius_factor must be greater than 1.z>The constant decrease_radius_threshold must be greater than 1.zPThe constant decrease_radius_threshold must be less than increase_radius_factor.g      à?r    zGThe constant decrease_resolution_factor must be in the interval (0, 1).z?The constant large_resolution_threshold must be greater than 1.zBThe constant moderate_resolution_threshold must be greater than 1.zVThe constant moderate_resolution_threshold must be at most large_resolution_threshold.z6The constant low_ratio must be in the interval (0, 1).z7The constant high_ratio must be in the interval (0, 1).z2The constant low_ratio must be at most high_ratio.z;The constant very_low_ratio must be in the interval (0, 1).zKThe constant penalty_increase_threshold must be greater than or equal to 1.z<The constant penalty_increase_factor must be greater than 1.zaThe constant penalty_increase_factor must be greater than or equal to penalty_increase_threshold.zAThe constant short_step_threshold must be in the interval (0, 1).z>The constant low_radius_factor must be in the interval (0, 1).zAThe constant byrd_omojokun_factor must be in the interval (0, 1).z@The constant threshold_ratio_constraints must be greater than 1.z4The constant large_shift_factor must be nonnegative.z:The constant large_gradient_factor must be greater than 1.z6The constant resolution_factor must be greater than 1.zUnknown constant: r   r   )$r!   r¿   r   ÚDECREASE_RADIUS_FACTORr½   r   r&   r*   ÚINCREASE_RADIUS_THRESHOLDÚINCREASE_RADIUS_FACTORÚDECREASE_RADIUS_THRESHOLDrE   r¼   rV   rT   ÚLARGE_RESOLUTION_THRESHOLDÚMODERATE_RESOLUTION_THRESHOLDrl   Ú
HIGH_RATIOrf   ÚPENALTY_INCREASE_THRESHOLDÚPENALTY_INCREASE_FACTORrR   ÚLOW_RADIUS_FACTORr`   ÚTHRESHOLD_RATIO_CONSTRAINTSrN   ri   rW   ÚIMPROVE_TCGr$   rÁ   rÂ   rÃ   rÄ   rÅ   )r|   r‹   rÆ   s      r§   r6   r6   7  sL  € õ �V‘”€IØ×ÒÝÔ(Ô.Ý�)Ô:Ô;ñô ð õ 9>Ø•)Ô2Ô3ñ9ô 9€I�iÔ.Ô4Ñ5ð 	•)Ô2Ô3°sÒ:Ð:Ø•YÔ5Ô6¸#Ò=Ð=åðñ
ô 
ð 	
ð ×ÒÝÔ+Ô1Ý�)Ô=Ô>ñô ð õ <AØ•)Ô5Ô6ñ<ô <€I�iÔ1Ô7Ñ8ð •Ô4Ô5¸Ò<Ð<ÝØLñ
ô 
ð 	
õ 	Ô(¨IÐ5Ð5Ø•iÔ6Ô7¸3Ò>Ð>åØIñ
ô 
ð 	
õ 	Ô+¨yÐ8Ð8Ø•iÔ9Ô:¸cÒAÐAåØLñ
ô 
ð 	
õ 	Ô(¨IÐ5Ð5ÝÔ/°9Ð<Ð<ð •iÔ9Ô:Ø�Ô9Ô:ò;ð ;õ ð4ñô ð ñ;õ 
Ô	)¨YÐ	6Ð	6Ý?A¼vå!¥)Ô"EÔFØ�s˜Y¥yÔ'GÔHÑHÑIðñ@
ô @
ˆ	•)Ô5Ô;Ñ<Ð<õ 
Ô	,°	Ð	9Ð	9Ý<>¼Få!¥)Ô"BÔCØ�i¥	Ô CÔDÑDðñ=
ô =
ˆ	•)Ô2Ô8Ñ9Ð9õ =NÝÔ,ô=
ˆ	•)Ô2Ô8Ñ9õ �iÔAÔBð 	•)Ô5Ô;Ñ<à×ÒÝÔ,Ô2Ý�)Ô>Ô?ñô ð õ =BØ•)Ô6Ô7ñ=ô =€I�iÔ2Ô8Ñ9ð 	•)Ô6Ô7¸3Ò>Ð>Ø•YÔ9Ô:¸cÒAÐAåðñ
ô 
ð 	
õ
 	Ô,°	Ð9Ð9Ø•iÔ:Ô;¸sÒBÐBåØMñ
ô 
ð 	
õ 	Ô/°9Ð<Ð<Ø•iÔ=Ô>À#ÒEÐEåðñ
ô 
ð 	
õ
 	Ô,°	Ð9Ð9ÝÔ3°yÐ@Ð@ð •iÔ=Ô>Ø�	Ô<Ô=ò>ð >õ ð>ñô ð ñ>õ 
Ô	-°Ð	:Ð	:ÝCEÄ6å!¥)Ô"IÔJØ�)Ô>Ô?ðñD
ô D
ˆ	•)Ô9Ô?Ñ@Ð@õ 
Ô	0°IÐ	=Ð	=Ý@BÄå!¥)Ô"FÔGØ�)ÔAÔBðñA
ô A
ˆ	•)Ô6Ô<Ñ=Ð=õ �iÔBÔCð 	•)Ô6Ô<Ñ=õ �iÔEÔFð 	•)Ô9Ô?Ñ@õ Ô˜iÐ'Ð'Ø•)Ô%Ô&¨#Ò-Ð-Ø•YÔ(Ô)¨SÒ0Ð0åØDñ
ô 
ð 	
õ Ô˜yÐ(Ð(Ø•)Ô&Ô'¨3Ò.Ð.Ø•YÔ)Ô*¨cÒ1Ð1åØEñ
ô 
ð 	
õ Ô˜iÐ'Ð'­IÔ,@ÀIÐ,MÐ,MØ•YÔ(Ô)¨IµiÔ6JÔ,KÒKÐKÝØDñô ð ñ Lõ 
Ô	 	Ð	)Ð	)Ý02´å!¥)Ô"6Ô7Ø�)Ô-Ô.ðñ1
ô 1
ˆ	•)Ô&Ô,Ñ-Ð-õ 
Ô	 Ð	*Ð	*Ý/1¬vå!¥)Ô"5Ô6Ø�)Ô.Ô/ðñ0
ô 0
ˆ	•)Ô%Ô+Ñ,Ð,õ 0AÝÔô0
ˆ	•)Ô%Ô+Ñ,õ 1BÝÔ ô1
ˆ	•)Ô&Ô,Ñ-ð ×ÒÝÔ Ô&Ý�)Ô2Ô3ñô ð õ 16Ø•)Ô*Ô+ñ1ô 1€I�iÔ&Ô,Ñ-ð 	•)Ô*Ô+¨sÒ2Ð2Ø•YÔ-Ô.°#Ò5Ð5åØIñ
ô 
ð 	
õ 	Ô,°	Ð9Ð9Ø•iÔ:Ô;¸cÒAÐAåð*ñ
ô 
ð 	
õ
 	Ô)¨YÐ6Ð6Ø•iÔ7Ô8¸CÒ?Ð?åØJñ
ô 
ð 	
õ 	Ô,°	Ð9Ð9ÝÔ-°Ð:Ð:ð •iÔ7Ô8Ø�	Ô<Ô=ò>ð >õ ð.ñô ð ñ>õ 
Ô	-°Ð	:Ð	:Ý=?¼Vå!¥)Ô"CÔDØ�)Ô>Ô?ðñ>
ô >
ˆ	•)Ô3Ô9Ñ:Ð:õ 
Ô	*¨iÐ	7Ð	7Ý@BÄå!¥)Ô"FÔGØ�)Ô;Ô<ðñA
ô A
ˆ	•)Ô6Ô<Ñ=Ð=õ �iÔBÔCð 	•)Ô6Ô<Ñ=õ >OÝÔ-ô>
ˆ	•)Ô3Ô9Ñ:ð ×ÒÝÔ&Ô,Ý�)Ô8Ô9ñô ð õ 7<Ø•)Ô0Ô1ñ7ô 7€I�iÔ,Ô2Ñ3ð 	•)Ô0Ô1°SÒ8Ð8Ø•YÔ3Ô4¸Ò;Ð;åØOñ
ô 
ð 	
ð ×ÒÝÔ#Ô)Ý�)Ô5Ô6ñô ð õ 49Ø•)Ô-Ô.ñ4ô 4€I�iÔ)Ô/Ñ0ð 	•)Ô-Ô.°#Ò5Ð5Ø•YÔ0Ô1°SÒ8Ð8åØLñ
ô 
ð 	
ð ×ÒÝÔ&Ô,Ý�)Ô8Ô9ñô ð õ 7<Ø•)Ô0Ô1ñ7ô 7€I�iÔ,Ô2Ñ3ð 	•)Ô0Ô1°SÒ8Ð8Ø•YÔ3Ô4¸Ò;Ð;åØOñ
ô 
ð 	
ð ×ÒÝÔ-Ô3Ý�)Ô?Ô@ñô ð õ >CØ•)Ô7Ô8ñ>ô >€I�iÔ3Ô9Ñ:ð •Ô6Ô7¸3Ò>Ð>ÝØNñ
ô 
ð 	
ð ×ÒÝÔ$Ô*Ý�)Ô6Ô7ñô ð õ 5:Ø•)Ô.Ô/ñ5ô 5€I�iÔ*Ô0Ñ1ð •Ô-Ô.°Ò4Ð4Ýð (ñ )ô )ð 	)à×ÒÝÔ'Ô-Ý�)Ô9Ô:ñô ð õ 8=Ø•)Ô1Ô2ñ8ô 8€I�iÔ-Ô3Ñ4ð •Ô0Ô1°SÒ8Ð8ÝØHñ
ô 
ð 	
ð ×ÒÝÔ#Ô)Ý�)Ô5Ô6ñô ð õ 49Ø•)Ô-Ô.ñ4ô 4€I�iÔ)Ô/Ñ0ð •Ô,Ô-°Ò4Ð4ÝØDñ
ô 
ð 	
ð ×ÒÝÔÔ#Ý�)Ô/Ô0ñô ð õ .2Ø•)Ô'Ô(ñ.ô .€I�iÔ#Ô)Ñ*ð
 ð Jð JˆØ•iÔ+×2Ò2Ñ4Ô4Ð4Ð4ÝŒMÐ5¨sÐ5Ð5Ð5µ~ÀqÑIÔIÐIøØÐr²   c                 ój  — | j         |t          j                 k    rt          ‚|j        |z   } | ||j        ¦  «        \  }}}|                      |||¦  «        }||t          j                 k    r||t          j                 k    rt          ‚| j
        r||t          j                 k    rt          ‚|||fS )z:
    Evaluate the objective and constraint functions.
    )rs   r   r?   r   rJ   ru   rp   rÀ   r%   r   Úis_feasibilityr   )	rŠ   rŒ   r—   r{   Úx_evalrœ   r�   rž   Úr_vals	            r§   rY   rY   Ž  s·   € ð 
„y�G�GÔ,Ô-Ò-Ð-ÝÐØÔ Ñ$€FØ "  6¨9Ô+<Ñ =Ô =Ñ€GˆW�gØ�HŠH�V˜W gÑ.Ô.€Eà�7�7œ>Ô*Ò*Ð*Ø�W�WÔ4Ô5Ò5Ð5åÐØ	Ôð ˜U g­gÔ.EÔ&FÒFÐFÝÐØ�G˜WÐ$Ð$r²   c                 ó”  — |                       |¦  «        \  }}}|o't          j        |¦  «        ot          j        |¦  «        }|t          j        t          j        fvr|o||t          j                 k    }t          ¦   «         }	t          j	        dt          j        dt          j
        dt          j        dt          j        dt          j        dt          j        dt          j        dt          j        d	i	                     |d
¦  «        |	_        ||	_        |j        |	_        |                      |¦  «        |	_        ||	_        ||	_        | j        |	_        ||	_        |t          j                 r| j        |	_        | j        |	_        |t          j                 r3tA          |	j        | |	j        |	j        |	j        |	j        |	j        ¦  «         |	S )z7
    Build the result of the optimization process.
    z<The lower bound for the trust-region radius has been reachedz4The target objective function value has been reachedz0All variables are fixed by the bound constraintsz9The callback requested to stop the optimization procedurez=The feasibility problem received has been solved successfullyz<The maximum number of function evaluations has been exceededz2The maximum number of iterations has been exceededz$The bound constraints are infeasiblezA linear algebra error occurredzUnknown exit status)!Ú	best_evalrE   Úisfiniter   rA   rC   r   r%   r   rm   r;   rB   rZ   rD   r:   rH   r"   Úmessager�   r½   r“   rr   Úxrv   rp   rs   ÚnfevÚnitr(   Úfun_historyÚmaxcv_historyr#   rq   )
rŠ   ru   r�   r“   rŽ   r{   rÜ   rv   rp   Úresults
             r§   r9   r9   ¡  s¦  € ð
 —L’L Ñ)Ô)�M€A€sˆEØÐA�"œ+ cÑ*Ô*ÐA­r¬{¸5Ñ/AÔ/A€GØ•jÔ/µÔ1LÐMÐMÐMØÐG˜e w­wÔ/FÔ'GÒGˆÝÑÔ€FåÔ!ð $=åÔ!ð $2åÔ ð #0åÔ#ð &>åÔ#ð &@åÔ#ð &EåÔ#ð &5åÔ#Ð%KÝÔÐ!Bð!÷" 
‚cˆ&Ð'Ñ(Ô(ð# „Nð$ €F„NØ”L€F„MØ�zŠz˜!‰}Œ}€F„HØ€F„JØ€F„LØ”)€F„KØ€F„JØ�wÔ$Ô%ð 0Øœ^ˆÔØ!Ô/ˆÔð �wŒÔð 	
ÝØŒNØØŒHØŒJØŒLØŒKØŒJñ	
ô 	
ð 	
ð €Mr²   c                 ó€  — t          ¦   «          t          | › d�¦  «         t          d|› d�¦  «         t          d|› d�¦  «         |j        st          d|j        › d|› d�¦  «         t          d|› d�¦  «         t          j        d	i t
          ¤Ž5  t          d|› d�¦  «         ddd¦  «         dS # 1 swxY w Y   dS )
zP
    Print information about the current state of the optimization process.
    r   z Number of function evaluations: zNumber of iterations: zLeast value of z: zMaximum constraint violation: zCorresponding point: Nr   )r<   rÕ   Úfun_namerE   Úprintoptionsr   )rÛ   rŠ   rÜ   rœ   r×   rs   rŽ   s          r§   rq   rq   Ö  s2  € õ 
�G„G€GÝ	ˆWˆ-ˆ-ˆ-ÑÔÐÝ	Ð
6¨VÐ
6Ð
6Ð
6Ñ7Ô7Ð7Ý	Ð
, 6Ð
,Ð
,Ð
,Ñ-Ô-Ð-ØÔð ;ÝÐ9 ¤Ð9Ð9¨wÐ9Ð9Ð9Ñ:Ô:Ð:Ý	Ð
3¨5Ð
3Ð
3Ð
3Ñ4Ô4Ð4Ý	ŒÐ	)Ð	)�=Ð	)Ð	)ð ,ð ,ÝÐ* aÐ*Ð*Ð*Ñ+Ô+Ð+ð,ð ,ð ,ñ ,ô ,ð ,ð ,ð ,ð ,ð ,ð ,ð ,øøøð ,ð ,ð ,ð ,ð ,ð ,s   ÂB3Â3B7Â:B7)r   Nr   NN)%rÃ   ÚnumpyrE   Úscipy.optimizer   r   r   r   rŒ   r   Úproblemr	   r
   r   r   r   Úutilsr   r   r   r   r   Úsettingsr   r   r   r   r   r   r¨   r2   r3   r4   r6   rY   r9   rq   r   r²   r§   ú<module>rê      só  ðØ €€€à Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð #Ð "Ð "Ð "Ð "Ð "ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 
ØØØØðJð Jð Jð JðZ
ð 
ð 
ð2B5ð B5ð B5ðJeHð eHð eHðPTð Tð Tðn
%ð %ð %ð&2ð 2ð 2ðj,ð ,ð ,ð ,ð ,r²   