Ë
    âQ(h·à  ã                   óÌ   — 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$y)é    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_OPTIONSc                 óÊ  — |€i }nt        |«      }|j                  t        j                  t        t        j                     «      }t        |«      }|j                  t        j                  t        t        j                     «      }	t        |	«      }	|j                  t        j                  t        t        j                     «      }
t        |
«      }
|j                  t        j                  t        t        j                     «      }t        |«      }t        j                  |v r!|t        j                     dk  rt        d«      ‚|j                  t        j                  t        t        j                     «      }t        |«      }t        j                  |v r!|t        j                     dk  rt        d«      ‚|j                  t        j                  t        t        j                     «      }t        |«      }|j                  t        j                  t        t        j                     «      }t        |«      }t        |t         «      s|f}t#        | ||g|¢­Ž }t%        |d«      s|g}t'        |«      }t)        t+        ||«      «      }t-        |«      \  }}t/        |||«      }t1        |||«      }t3        |||||||	|
||||«      }t5        ||j6                  «       t9        di |¤Ž}|j:                  j<                  st?        |ddt@        jB                  d|«      S |j6                  dk(  rt?        |ddt@        jD                  d|«      S |r•tG        d	«       tG        d
|t        jH                     › d�«       tG        d|t        jJ                     › d�«       tG        d|t        jL                     › d�«       tG        d|t        jN                     › d�«       tG        «        	 tQ        |||«      }d}d}d}d}d}d}	 ||t        jN                     k\  rt@        j`                  }�nD|dz  }tb        jd                  jk                  |jl                  |jn                  jp                  jr                  z
  «      |tt        jv                     |jx                  z  k\  r|j{                  |«       |jx                  }|j}                  |«      \  } }!| |!z   }"tb        jd                  jk                  |"«      }#|#|tt        j~                     |j€                  z  k  r»|xjx                  |tt        j‚                     z  c_<        ||j€                  kD  rd}d}n|dz  }|dz  }|#d|j€                  z  kD  rd}|dk\  xs |dk\  }$|$rd}d}d}%�n¨	 |j…                  «       \  }}&|&t‡        |jx                  |tt        jˆ                     |j€                  z  «      kD  }%�n[|j‹                  |"«      }'|'�rC	 t�        |||"|«      \  }(})}*|j‘                  |jl                  |j’                  |j”                  |j–                  «      }+|j‘                  |jl                  |"z   |(|)|*«      },|j˜                  dk(  r”|,|+kD  r�tb        jd                  jk                  | «      |tt        jš                     dz  |jx                  z  kD  rL|j�                  |"|«      }-tb        jd                  jk                  |-«      dkD  r|"|-z  }"	 t�        |||"|«      \  }(})}*|jŸ                  |"|(|)|*«      }.	 |j…                  |jl                  |"z   «      d   }	 |jn                  j¡                  ||jl                  |"z   |(|)|*«      }/|j£                  «        |j¥                  |"|.«       |jx                  |j€                  k  rà|.|tt        j¦                     k\  rd}nÇ|dz  }|jn                  j©                  |jl                  «      }0	 |jn                  j«                  |jl                  «      }1tb        jd                  jk                  |0«      |tt        j¬                     tb        jd                  jk                  |1«      z  k  rd}|dk\  r	 |jn                  j¯                  «        d}|j±                  |jl                  |"z   «       	 |j…                  «       \  }}&|/xsO |.|tt        j²                     k  xr7 |&t‡        |jx                  |tt        jˆ                     |j€                  z  «      kD  }%||j€                  k  xr |.|tt        j²                     k  xr |% }$nd}$d}%|$rÝ|j€                  |t        jJ                     k  rd}t@        j´                  }�n|j·                  |«       |j¹                  «        |r†|j»                  |jl                  |j”                  |j–                  «      }2t½        d|j€                  › �||j¿                  |jl                  «      |j’                  |2|jÀ                  |«       tG        «        |%rc	 |jÃ                  ||«      }"	 t�        |||"|«      \  }(})}*	 |jn                  j¡                  ||jl                  |"z   |(|)|*«       |j£                  «        �Œlt?        ||jÄ                  ||||«      S # tR        $ r! t?        |ddt@        jT                  d|«      cY S tV        $ r! t?        |ddt@        jX                  d|«      cY S tZ        $ r! t?        |ddt@        j\                  d|«      cY S t^        $ r! t?        |ddt@        j`                  d|«      cY S tb        jd                  jf                  $ r! t?        |ddt@        jh                  d|«      cY S w xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œ+w xY w# tR        $ r t@        jT                  }d}Y �ŒMtZ        $ r t@        j\                  }d}Y �ŒjtV        $ r t@        jX                  }d}Y �Œ‡t^        $ r t@        jŽ                  }Y �Œ¢w xY w# tR        $ r t@        jT                  }d}Y �ŒÄtZ        $ r t@        j\                  }d}Y �ŒátV        $ r t@        jX                  }d}Y �Œþt^        $ r t@        jŽ                  }Y �Œw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �ŒMw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œ�w xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œµw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œéw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �ŒQw xY w# tR        $ r t@        jT                  }d}Y �ŒstZ        $ r t@        j\                  }d}Y �Œ�tV        $ r t@        jX                  }d}Y �Œ­t^        $ r t@        jŽ                  }Y �ŒÈw xY w# tb        jd                  jf                  $ r t@        jh                  }Y �Œüw xY w)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: © )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/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/_lib/cobyqa/main.pyÚminimizer¨   $   sî  € ðF €Ø‰ä�w“-ˆØ�k‰kœ'Ÿ/™/¬?¼7¿?¹?Ñ+KÓL€GÜ�7‹m€GØ—k‘kÜ×ÑÜœ×/Ñ/Ñ0ó€Oô ˜OÓ,€OØ�K‰KœŸ™¤´w·}±}Ñ'EÓF€EÜ�‹K€EØ—K‘KÜ×ÑÜœ×-Ñ-Ñ.ó€Mô ˜Ó'€MÜ×Ñ˜wÑ&¨7´7×3GÑ3GÑ+HÈAÒ+MÜÐDÓEÐEØ—;‘;Ü×ÑÜœ×,Ñ,Ñ-ó€Lô �|Ó$€LÜ×Ñ˜gÑ%¨'´'×2EÑ2EÑ*FÈ!Ò*KÜÐCÓDÐDØ—+‘+Ü×ÑÜœ×+Ñ+Ñ,ó€Kô �kÓ"€KØ�K‰KœŸ™¤´w·}±}Ñ'EÓF€EÜ�‹K€Eô �dœEÔ"ØˆwˆÜ
˜C ¨%Ð
7°$Ò
7€Cô �2�yÔ!ØˆTˆÜ�‹W€FÜœk¨&°&Ó9Ó:€Fô 1AÀÓ0MÑ-ÐÐ-ÜÐ1°6¸5ÓA€FÜ$Ð%:¸GÀUÓK€Iô 
ØØ
ØØØØØØØØØØó
€Bô  ˜ "§$¡$Ô'Ü&Ñ0¨Ñ0€Ið �9‰9× Ò äØØØÜ×'Ñ'ØØó
ð 	
ð 
�‰�ŠäØØØÜ×$Ñ$ØØó
ð 	
ñ ÜÐ4Ô5ÜÐ-¨g´g·n±nÑ.EÐ-FÀaÐHÔIÜÐ+¨G´G·N±NÑ,CÐ+DÀAÐFÔGÜØ6Ø”w×'Ñ'Ñ(Ð)¨ð,ô	
ô 	Ð.¨w´w×7GÑ7GÑ/HÐ.IÈÐKÔLÜŒð3
Ü  G¨YÓ7ˆ	ðj €GØ€FØ€EØ€MØÐØ€LØ
ð �WœW×-Ñ-Ñ.Ò.Ü×0Ñ0ˆFÙØ�!‰ˆô �I‰I�N‰NØ× Ñ  9×#3Ñ#3×#AÑ#A×#HÑ#HÑHóð œ×5Ñ5Ñ6¸×9IÑ9IÑIòJð
 ×"Ñ" 7Ô+ð  ×&Ñ&ˆØ'0×'FÑ'FÀwÓ'OÑ$ˆ�_Ø˜_Ñ,ˆÜ—‘—‘ Ó%ˆð Øœ×7Ñ7Ñ8¸9×;OÑ;OÑOòPð ×Ò 	¬)×*NÑ*NÑ OÑOÕØ˜Y×1Ñ1Ò1Ø !�Ø%&Ñ"à Ñ"�Ø" aÑ'Ð"Ø˜C )×"6Ñ"6Ñ6Ò6Ø)*Ð&Ø!.°!Ñ!3Ò!NÐ7IÈQÑ7NÐÙ!Ø !�Ø%&Ð"Ø#(Ò ðØ&/×&CÑ&CÓ&E‘O�E˜8ð $,¬cØ×$Ñ$Øœi×9Ñ9Ñ:Ø×*Ñ*ñ+ó/ñ $Ò ð (×8Ñ8¸Ó>ˆOÚðÜ05ØØ!ØØó	1Ñ-�G˜W gð. &ŸO™OØ×$Ñ$Ø×&Ñ&Ø×&Ñ&Ø×&Ñ&ó	�	ð &ŸO™OØ×$Ñ$ tÑ+¨W°g¸wó�	ð —G‘GÐ8Ò8Ø! IÒ-ÜŸ	™	Ÿ™ {Ó3Ø¤	× >Ñ >Ñ?À3ÑFØ×&Ñ&ñ'ò'ð  )×IÑIØ˜gó �Hô —y‘y—~‘~ hÓ/°#Ò5Ø Ñ(˜ð"Ü8=Ø "Ø )Ø $Ø 'ó	9Ñ5˜G W¨gð. "×5Ñ5ØØØØó	�ðØ%×9Ñ9Ø!×(Ñ(¨4Ñ/óàñ�EðØ&/×&6Ñ&6×&KÑ&KØ˜y×/Ñ/°$Ñ6¸ÀØó'�Oð ×(Ñ(Ô*ð ×'Ñ'¨¨eÔ4ð ×#Ñ# y×';Ñ';Ò;Ø 	¬)×*BÑ*BÑ CÒCØ'(™à$¨Ñ)˜Ø(×/Ñ/×8Ñ8¸×9IÑ9IÓJ˜ð"Ø'0×'7Ñ'7×'DÑ'DØ )× 0Ñ 0ó(˜Hô Ÿ9™9Ÿ>™>¨$Ó/°)Ü%×;Ñ;ñ3äŸI™IŸN™N¨8Ó4ñ35ò 5ð ,-˜LØ'¨1Ò,ð&Ø )× 0Ñ 0× =Ñ =Ô ?ð ,-˜Lð ×)Ñ)¨)×*:Ñ*:¸TÑ*AÔBðØ&/×&CÑ&CÓ&E‘O�E˜8ð
 $ò Ø 	¬)×*=Ñ*=Ñ >Ñ>ò Ø ÜØ!×(Ñ(Ø!¤)×"=Ñ"=Ñ>Ø#×.Ñ.ñ/óñð !ð   9×#7Ñ#7Ñ7ò -Ø ¬9×+>Ñ+>Ñ!?Ñ?ò-à,Ð,ñ #ð &+Ð"Ø#(Ð ñ Ø×#Ñ# w¬w¯~©~Ñ'>Ò>Ø�Ü#×2Ñ2�ÙØ×(Ñ(¨Ô1Ø×&Ñ&Ô(áØŸH™HØ×$Ñ$ i×&8Ñ&8¸)×:LÑ:Ló�	ô Ø/°	×0DÑ0DÐ/EÐFØØ—J‘J˜y×/Ñ/Ó0Ø×&Ñ&ØØ—I‘IØôô ”ñ ðØ ×2Ñ2°5¸'ÓB�ðÜ,1°"°iÀÀwÓ,OÑ)�˜ 'ð$
Ø× Ñ ×5Ñ5ØØ×$Ñ$ tÑ+ØØØôð ×$Ñ$Ô&ñy ô| Ø
Ø×ÑØØØØóð øôq
 ò 	
äØØØÜ×%Ñ%ØØó
ò 	
ô ò 	
äØØØÜ×'Ñ'ØØó
ò 	
ô ò 	
äØØØÜ×'Ñ'ØØó
ò 	
ô ò 	
äØØØÜ×'Ñ'ØØó
ò 	
ô �9‰9× Ñ ò 	
äØØØÜ×#Ñ#ØØó
ò 	
ð	
ûôJ —y‘y×,Ñ,ò Ü'×4Ñ4�FÚðûô( %ò Ü'×6Ñ6�FØ"�GÚÜ&ò Ü'×8Ñ8�FØ"�GÚÜ&ò Ü'×8Ñ8�FØ"�GÚÜ#ò Ü'×8Ñ8�FÚðûôF  -ò "Ü%/×%>Ñ%>˜FØ&*˜GÚ!Ü.ò "Ü%/×%@Ñ%@˜FØ&*˜GÚ!Ü.ò "Ü%/×%@Ñ%@˜FØ&*˜GÚ!Ü+ò "Ü%/×%@Ñ%@˜FÚ!ð"ûô" —y‘y×,Ñ,ò Ü'×4Ñ4�FÚðûô —y‘y×,Ñ,ò Ü'×4Ñ4�FÚðûô&  "Ÿy™y×4Ñ4ò "Ü%/×%<Ñ%<˜FÚ!ð"ûô $&§9¡9×#8Ñ#8ò &Ü)3×)@Ñ)@ Ú %ð&ûô —y‘y×,Ñ,ò Ü'×4Ñ4�FÚðûôh —9‘9×(Ñ(ò Ü#×0Ñ0�Úðûô !ò Ü#×2Ñ2�Ø�ÚÜ"ò Ü#×4Ñ4�Ø�ÚÜ"ò Ü#×4Ñ4�Ø�ÚÜò Ü#×4Ñ4�Úðûô —9‘9×(Ñ(ò Ü#×0Ñ0�Úðús&  Ïi? Õ8m  ×n Ûp Ü !r Ü",r6 ß%s* át âu èv èv: è',x1 é?'mê(&më&më8&mì :mímí -nînîpî2pïpï,pðpðq?ð)q?ñq?ñ#q?ñ>q?ò-r3ò2r3ò6-s'ó&s'ó*-tôtô-uõuõ-vövö-v7ö6v7ö:x.÷x.÷5x.øx.ø-x.ø1-y"ù!y"c                 óR  — | €Qt        t        j                  |t        j                   «      t        j                  |t        j                  «      «      S t	        | t         «      rc| j
                  j                  |fk7  s| j                  j                  |fk7  rt        d|› d�«      ‚t        | j
                  | j                  «      S t        | d«      rKt        j                  | «      } | j                  |dfk7  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‘g˜a¤"§&¡& Ó)¬2¯7©7°1´b·f±fÓ+=Ó>Ð>Ü	�FœFÔ	#Ø�9‰9�?‰?˜q˜dÒ" f§i¡i§o¡o¸!¸Ò&=ÜÐ4°Q°C°zÐBÓCÐCÜ�f—i‘i §¡Ó+Ð+Ü	�˜Ô	#Ü—‘˜FÓ#ˆØ�<‰<˜A˜q˜6Ò!Üð+óð ô �fšQ ˜T‘l Fª1¨a¨4¡LÓ1Ð1äð=ó
ð 	
ó    c           
      ó,  — t        | t        «      st        | d«      s| f} g }g }| D �]h  }t        |t        «      rft	        |j
                  d«      }t	        |j                  d«      }|j                  t        |j                  gt        j                  ||«      ¢­Ž «       Œzt        |t        «      rft	        |j
                  d«      }t	        |j                  d«      }|j                  t        |j                  gt        j                  ||«      ¢­Ž «       Œðt        |t        «      r`d|vs|d   dvrt        d«      ‚d	|vst        |d	   «      st        d
«      ‚|j                  |d	   |d   |j                  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   Š  s¼  € ô �+œtÔ$¬G°KÀÔ,KØ"�nˆð ÐØÐØ!ó 7ˆ
Ü�jÔ"2Ô3ÜØ—‘ØMóˆBô  Ø—‘ØMóˆBð ×%Ñ%Ü Ø—L‘Lðä×(Ñ(¨¨RÓ0òõô ˜
Ô$7Ô8ÜØ—‘ðóˆBô  Ø—‘ðóˆBð "×(Ñ(Ü#Ø—N‘Nðä×(Ñ(¨¨RÓ0òõô ˜
¤DÔ)Ø˜ZÑ'¨:°fÑ+=ð Fñ ,ô !Ð!NÓOÐOØ˜JÑ&¬h°zÀ%Ñ7HÔ.IÜ Ð!LÓMÐMØ!×(Ñ(à% eÑ,Ø& vÑ.Ø&ŸN™N¨6°2Ó6ñöô ð?óð ðg7ðp Ð4Ð4Ð4r²   c                 óÀ  — 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 r3| t         j                     | t         j                     k  �rEt        d«      ‚t         j                  | v rYt	        j
                  t        t         j                     | t         j                     g«      | t         j                  j                  <   nÏt         j                  | v rYt	        j                  t        t         j                     | t         j                     g«      | t         j                  j                  <   ndt        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 r=| t         j                     |dz   |dz   z  dz  kD  rt        d	|dz   |dz   z  dz  › d
�«      ‚| j                  t         j                  j                  t        t         j                     |«      «       t        | t         j                     «      | t         j                  j                  <   t         j                  | v r!| t         j                     dk  rt        d«      ‚| j                  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«      ‚| j                  t         j                  j                  t        t         j                     |«      «       t        | t         j                     «      | t         j                  j                  <   | j                  t         j                  j                  t        t         j                     «       t        | t         j                     «      | t         j                  j                  <   | j                  t         j                   j                  t        t         j                      «       t        | t         j                      «      | t         j                   j                  <   | j                  t         j"                  j                  t        t         j"                     «       t%        | t         j"                     «      | t         j"                  j                  <   | j                  t         j&                  j                  t        t         j&                     «       t%        | t         j&                     «      | t         j&                  j                  <   | j                  t         j(                  j                  t        t         j(                     «       t        | t         j(                     «      | t         j(                  j                  <   | j                  t         j*                  j                  t        t         j*                     «       t%        | t         j*                     «      | t         j*                  j                  <   | j                  t         j,                  j                  t        t         j,                     «       t        | t         j,                     «      | t         j,                  j                  <   | j                  t         j.                  j                  t        t         j.                     «       t%        | t         j.                     «      | t         j.                  j                  <   | D ]B  }|t         j0                  j3                  «       vsŒ$t5        j6                  d|› d
�t8        d«       ŒD y)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ÜÐLÓMÐMÜ‡~�~˜Ñ  W¬W¯^©^Ñ%<¸sÒ%BÜÐMÓNÐNÜ‡~�~˜Ñ ¤W§^¡^°wÑ%>Ø”7—>‘>Ñ" W¬W¯^©^Ñ%<Ó<ÜðBóð ô 
�‰˜7Ñ	"Ü(*¯©ä¤§¡Ñ/ØœŸ™Ñ'ðó)
ˆ”—‘×$Ñ$Ò%ô 
�‰˜7Ñ	"Ü(*¯©ä¤§¡Ñ/ØœŸ™Ñ'ðó)
ˆ”—‘×$Ñ$Ò%ô )8¼¿¹Ñ(Gˆ”—‘×$Ñ$Ñ%Ü(7¼¿¹Ñ(Gˆ”—‘×$Ñ$Ñ%Ü$)¨'´'·.±.Ñ*AÓ$B€GŒG�N‰N× Ñ Ñ!Ü$)¨'´'·.±.Ñ*AÓ$B€GŒG�N‰N× Ñ Ñ!Ü‡{�{�gÑ '¬'¯+©+Ñ"6¸!Ò";Üð %ó &ð 	&ô 	�‰�wÑØ”G—K‘KÑ  Q¨¡U¨q°1©uÑ$5¸!Ñ#;Ò;äØAØ�Q‘˜1˜q™5Ñ! aÑ'Ð(¨ð+ó
ð 	
ð ×Ñ”w—{‘{×(Ñ(¬/¼'¿+¹+Ñ*FÀqÓ*IÔJÜ!$ W¬W¯[©[Ñ%9Ó!:€GŒG�K‰K×ÑÑÜ×Ñ˜7Ñ" w¬w×/?Ñ/?Ñ'@ÀAÒ'EÜØJó
ð 	
ð ×ÑÜ×Ñ×ÑÜ
�‰ä¤× 0Ñ 0Ñ1°!Ó4ØœŸ™Ñ$ qÑ(ðó	
ôô '*¨'´'×2BÑ2BÑ*CÓ&D€GŒG×Ñ×"Ñ"Ñ#Ü×Ñ˜7Ñ" w¬w×/?Ñ/?Ñ'@ÀAÒ'EÜÐMÓNÐNØ×ÑÜ×Ñ×ÑÜœ×(Ñ(Ñ)¨!Ó,ôô '*¨'´'×2BÑ2BÑ*CÓ&D€GŒG×Ñ×"Ñ"Ñ#Ø×Ñ”w—~‘~×+Ñ+¬_¼W¿^¹^Ñ-LÔMÜ$)¨'´'·.±.Ñ*AÓ$B€GŒG�N‰N× Ñ Ñ!Ø×ÑÜ×Ñ×%Ñ%Üœ×/Ñ/Ñ0ôô .3Ø”×'Ñ'Ñ(ó.€GŒG×#Ñ#×)Ñ)Ñ*ð ×Ñ”w—‘×,Ñ,¬o¼g¿o¹oÑ.NÔOÜ%)¨'´'·/±/Ñ*BÓ%C€GŒG�O‰O×!Ñ!Ñ"Ø×Ñ”w—}‘}×*Ñ*¬O¼G¿M¹MÑ,JÔKÜ#'¨´·±Ñ(>Ó#?€GŒG�M‰M×ÑÑ Ø×ÑÜ×Ñ×!Ñ!Üœ×+Ñ+Ñ,ôô *-¨W´W×5HÑ5HÑ-IÓ)J€GŒG×Ñ×%Ñ%Ñ&Ø×ÑÜ×Ñ×#Ñ#Üœ×-Ñ-Ñ.ôô ,0°¼×8MÑ8MÑ0NÓ+O€GŒG×!Ñ!×'Ñ'Ñ(Ø×ÑÜ×Ñ×"Ñ"Üœ×,Ñ,Ñ-ôô +.¨g´g×6JÑ6JÑ.KÓ*L€GŒG× Ñ ×&Ñ&Ñ'Ø×Ñ”w—}‘}×*Ñ*¬O¼G¿M¹MÑ,JÔKÜ#'¨´·±Ñ(>Ó#?€GŒG�M‰M×ÑÑ ð ò HˆØ”g×)Ñ)×0Ñ0Ó2Ò2Ü�M‰MÐ,¨S¨E°Ð3´^ÀQÕGñHr²   c                  óº  — t        | «      }|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«      ‚|j                  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 r3|t        j                     |t        j                     k\  �rNt        d«      ‚t        j                  |v r_t        j                  t
        t        j                     dd|t        j                     z   z  g«      |t        j                  j                  <   nÒt        j                  |v r\t        j                  t
        t        j                     d	|t        j                     z  g«      |t        j                  j                  <   ndt
        t        j                     |t        j                  j                  <   t
        t        j                     |t        j                  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 r3|t        j                      |t        j                     kD  �rEt        d«      ‚t        j                  |v rYt        j                  t
        t        j                      |t        j                     g«      |t        j                   j                  <   nÏt        j                   |v rYt        j                  t
        t        j                     |t        j                      g«      |t        j                  j                  <   ndt
        t        j                     |t        j                  j                  <   t
        t        j                      |t        j                   j                  <   t        j"                  |v r7|t        j"                     dk  s|t        j"                     dk\  rt        d«      ‚t        j$                  |v r7|t        j$                     dk  s|t        j$                     dk\  rt        d«      ‚t        j"                  |v rEt        j$                  |v r3|t        j"                     |t        j$                     kD  �rEt        d«      ‚t        j"                  |v rYt        j                  t
        t        j$                     |t        j"                     g«      |t        j$                  j                  <   nÏt        j$                  |v rYt        j                  t
        t        j"                     |t        j$                     g«      |t        j"                  j                  <   ndt
        t        j"                     |t        j"                  j                  <   t
        t        j$                     |t        j$                  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 r3|t        j*                     |t        j(                     k  �rEt        d«      ‚t        j(                  |v rYt        j                  t
        t        j*                     |t        j(                     g«      |t        j*                  j                  <   nÏt        j*                  |v rYt        j                  t
        t        j(                     |t        j*                     g«      |t        j(                  j                  <   ndt
        t        j(                     |t        j(                  j                  <   t
        t        j*                     |t        j*                  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«      ‚|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«      ‚|j                  t        j0                  j                  t
        t        j0                     «       t        |t        j0                     «      |t        j0                  j                  <   |t        j0                     dk  s|t        j0                     dk\  rt        d«      ‚|j                  t        j2                  j                  t
        t        j2                     «       t        |t        j2                     «      |t        j2                  j                  <   |t        j2                     dk  rt        d«      ‚|j                  t        j4                  j                  t
        t        j4                     «       t        |t        j4                     «      |t        j4                  j                  <   |t        j4                     dk  rt        d«      ‚|j                  t        j6                  j                  t
        t        j6                     «       t        |t        j6                     «      |t        j6                  j                  <   |t        j6                     dk  rt        d«      ‚|j                  t        j8                  j                  t
        t        j8                     «       t        |t        j8                     «      |t        j8                  j                  <   |t        j8                     dk  rt        d«      ‚|j                  t        j:                  j                  t
        t        j:                     «       t=        |t        j:                     «      |t        j:                  j                  <   | D ]B  }|t        j>                  jA                  «       vsŒ$tC        jD                  d|› d�tF        d«       ŒD |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  sX  € ô �V“€IØ×ÑÜ×(Ñ(×.Ñ.Üœ)×:Ñ:Ñ;ôô 9>Ø”)×2Ñ2Ñ3ó9€IŒi×.Ñ.×4Ñ4Ñ5ð 	”)×2Ñ2Ñ3°sÒ:Ø”Y×5Ñ5Ñ6¸#Ò=äðó
ð 	
ð ×ÑÜ×+Ñ+×1Ñ1Üœ)×=Ñ=Ñ>ôô <AØ”)×5Ñ5Ñ6ó<€IŒi×1Ñ1×7Ñ7Ñ8ð ”×4Ñ4Ñ5¸Ò<ÜØLó
ð 	
ô 	×(Ñ(¨IÑ5Ø”i×6Ñ6Ñ7¸3Ò>äØIó
ð 	
ô 	×+Ñ+¨yÑ8Ø”i×9Ñ9Ñ:¸cÒAäØLó
ð 	
ô 	×(Ñ(¨IÑ5Ü×/Ñ/°9Ñ<ð ”i×9Ñ9Ñ:Øœ×9Ñ9Ñ:ó;ô ð4óð ô 
×	)Ñ	)¨YÑ	6Ü?A¿v¹vä!¤)×"EÑ"EÑFØ�s˜Y¤y×'GÑ'GÑHÑHÑIðó@
ˆ	”)×5Ñ5×;Ñ;Ò<ô 
×	,Ñ	,°	Ñ	9Ü<>¿F¹Fä!¤)×"BÑ"BÑCØ�i¤	× CÑ CÑDÑDðó=
ˆ	”)×2Ñ2×8Ñ8Ò9ô =NÜ×,Ñ,ñ=
ˆ	”)×2Ñ2×8Ñ8Ñ9ô œi×AÑAÑBð 	”)×5Ñ5×;Ñ;Ñ<à×ÑÜ×,Ñ,×2Ñ2Üœ)×>Ñ>Ñ?ôô =BØ”)×6Ñ6Ñ7ó=€IŒi×2Ñ2×8Ñ8Ñ9ð 	”)×6Ñ6Ñ7¸3Ò>Ø”Y×9Ñ9Ñ:¸cÒAäðó
ð 	
ô
 	×,Ñ,°	Ñ9Ø”i×:Ñ:Ñ;¸sÒBäØMó
ð 	
ô 	×/Ñ/°9Ñ<Ø”i×=Ñ=Ñ>À#ÒEäðó
ð 	
ô
 	×,Ñ,°	Ñ9Ü×3Ñ3°yÑ@ð ”i×=Ñ=Ñ>Øœ	×<Ñ<Ñ=ó>ô ð>óð ô 
×	-Ñ	-°Ñ	:ÜCEÇ6Á6ä!¤)×"IÑ"IÑJØœ)×>Ñ>Ñ?ðóD
ˆ	”)×9Ñ9×?Ñ?Ò@ô 
×	0Ñ	0°IÑ	=Ü@BÇÁä!¤)×"FÑ"FÑGØœ)×AÑAÑBðóA
ˆ	”)×6Ñ6×<Ñ<Ò=ô œi×BÑBÑCð 	”)×6Ñ6×<Ñ<Ñ=ô œi×EÑEÑFð 	”)×9Ñ9×?Ñ?Ñ@ô ×Ñ˜iÑ'Ø”)×%Ñ%Ñ&¨#Ò-Ø”Y×(Ñ(Ñ)¨SÒ0äØDó
ð 	
ô ×Ñ˜yÑ(Ø”)×&Ñ&Ñ'¨3Ò.Ø”Y×)Ñ)Ñ*¨cÒ1äØEó
ð 	
ô ×Ñ˜iÑ'¬I×,@Ñ,@ÀIÑ,MØ”Y×(Ñ(Ñ)¨I´i×6JÑ6JÑ,KÓKÜØDóð ô 
×	Ñ	 	Ñ	)Ü02·±ä!¤)×"6Ñ"6Ñ7Øœ)×-Ñ-Ñ.ðó1
ˆ	”)×&Ñ&×,Ñ,Ò-ô 
×	Ñ	 Ñ	*Ü/1¯v©vä!¤)×"5Ñ"5Ñ6Øœ)×.Ñ.Ñ/ðó0
ˆ	”)×%Ñ%×+Ñ+Ò,ô 0AÜ×Ññ0
ˆ	”)×%Ñ%×+Ñ+Ñ,ô 1BÜ× Ñ ñ1
ˆ	”)×&Ñ&×,Ñ,Ñ-ð ×ÑÜ× Ñ ×&Ñ&Üœ)×2Ñ2Ñ3ôô 16Ø”)×*Ñ*Ñ+ó1€IŒi×&Ñ&×,Ñ,Ñ-ð 	”)×*Ñ*Ñ+¨sÒ2Ø”Y×-Ñ-Ñ.°#Ò5äØIó
ð 	
ô 	×,Ñ,°	Ñ9Ø”i×:Ñ:Ñ;¸cÒAäð*ó
ð 	
ô
 	×)Ñ)¨YÑ6Ø”i×7Ñ7Ñ8¸CÒ?äØJó
ð 	
ô 	×,Ñ,°	Ñ9Ü×-Ñ-°Ñ:ð ”i×7Ñ7Ñ8Øœ	×<Ñ<Ñ=ó>ô ð.óð ô
 
×	-Ñ	-°Ñ	:Ü=?¿V¹Vä!¤)×"CÑ"CÑDØœ)×>Ñ>Ñ?ðó>
ˆ	”)×3Ñ3×9Ñ9Ò:ô 
×	*Ñ	*¨iÑ	7Ü@BÇÁä!¤)×"FÑ"FÑGØœ)×;Ñ;Ñ<ðóA
ˆ	”)×6Ñ6×<Ñ<Ò=ô œi×BÑBÑCð 	”)×6Ñ6×<Ñ<Ñ=ô >OÜ×-Ñ-ñ>
ˆ	”)×3Ñ3×9Ñ9Ñ:ð ×ÑÜ×&Ñ&×,Ñ,Üœ)×8Ñ8Ñ9ôô 7<Ø”)×0Ñ0Ñ1ó7€IŒi×,Ñ,×2Ñ2Ñ3ð 	”)×0Ñ0Ñ1°SÒ8Ø”Y×3Ñ3Ñ4¸Ò;äØOó
ð 	
ð ×ÑÜ×#Ñ#×)Ñ)Üœ)×5Ñ5Ñ6ôô 49Ø”)×-Ñ-Ñ.ó4€IŒi×)Ñ)×/Ñ/Ñ0ð 	”)×-Ñ-Ñ.°#Ò5Ø”Y×0Ñ0Ñ1°SÒ8äØLó
ð 	
ð ×ÑÜ×&Ñ&×,Ñ,Üœ)×8Ñ8Ñ9ôô 7<Ø”)×0Ñ0Ñ1ó7€IŒi×,Ñ,×2Ñ2Ñ3ð 	”)×0Ñ0Ñ1°SÒ8Ø”Y×3Ñ3Ñ4¸Ò;äØOó
ð 	
ð ×ÑÜ×-Ñ-×3Ñ3Üœ)×?Ñ?Ñ@ôô >CØ”)×7Ñ7Ñ8ó>€IŒi×3Ñ3×9Ñ9Ñ:ð ”×6Ñ6Ñ7¸3Ò>ÜØNó
ð 	
ð ×ÑÜ×$Ñ$×*Ñ*Üœ)×6Ñ6Ñ7ôô 5:Ø”)×.Ñ.Ñ/ó5€IŒi×*Ñ*×0Ñ0Ñ1ð ”×-Ñ-Ñ.°Ò4Üð (ó )ð 	)à×ÑÜ×'Ñ'×-Ñ-Üœ)×9Ñ9Ñ:ôô 8=Ø”)×1Ñ1Ñ2ó8€IŒi×-Ñ-×3Ñ3Ñ4ð ”×0Ñ0Ñ1°SÒ8ÜØHó
ð 	
ð ×ÑÜ×#Ñ#×)Ñ)Üœ)×5Ñ5Ñ6ôô 49Ø”)×-Ñ-Ñ.ó4€IŒi×)Ñ)×/Ñ/Ñ0ð ”×,Ñ,Ñ-°Ò4ÜØDó
ð 	
ð ×ÑÜ×Ñ×#Ñ#Üœ)×/Ñ/Ñ0ôô .2Ø”)×'Ñ'Ñ(ó.€IŒi×#Ñ#×)Ñ)Ñ*ð
 ò JˆØ”i×+Ñ+×2Ñ2Ó4Ò4Ü�M‰MÐ.¨s¨e°1Ð5´~ÀqÕIðJð Ðr²   c                 ó~  — | j                   |t        j                     k\  rt        ‚|j                  |z   } | ||j
                  «      \  }}}| 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�y�GœG×,Ñ,Ñ-Ò-ÜÐØ×Ñ Ñ$€FÙ " 6¨9×+<Ñ+<Ó =Ñ€GˆW�gØ�H‰H�V˜W gÓ.€Eà�7œ7Ÿ>™>Ñ*Ò*Ø�WœW×4Ñ4Ñ5Ò5äÐØ	×Ò˜U g¬g×.EÑ.EÑ&FÒFÜÐØ�G˜WÐ$Ð$r²   c                 ó<  — | j                  |«      \  }}}|xr, t        j                  |«      xr t        j                  |«      }|t        j                  t        j
                  fvr|xr ||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	j!                  |d
«      |	_        ||	_        |j&                  |	_        | j+                  |«      |	_        ||	_        ||	_        | j2                  |	_        ||	_        |t        j8                     r"| j:                  |	_        | j<                  |	_        |t        j>                     rMtA        |	j"                  | |	j,                  |	j.                  |	j0                  |	j4                  |	j6                  «       |	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€GØ”j×/Ñ/´×1LÑ1LÐMÑMØÒG˜e w¬w×/FÑ/FÑ'GÑGˆÜÓ€Fä×!Ñ!ð $=ä×!Ñ!ð $2ä× Ñ ð #0ä×#Ñ#ð &>ä×#Ñ#ð &@ä×#Ñ#ð &Eä×#Ñ#ð &5ä×#Ñ#Ð%KÜ×ÑÐ!Bð!÷" 
�cˆ&Ð'Ó(ð# „Nð$ €F„NØ—L‘L€F„MØ�z‰z˜!‹}€F„HØ€F„JØ€F„LØ—)‘)€F„KØ€F„JØŒw×$Ñ$Ò%ØŸ^™^ˆÔØ!×/Ñ/ˆÔð Œw�‰ÒÜØ�N‰NØØ�H‰HØ�J‰JØ�L‰LØ�K‰KØ�J‰Jô	
ð €Mr²   c                 óX  — 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«       y# 1 sw Y   yxY w)
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   Ö  s§   € ô 
„GÜ	ˆWˆI�Qˆ-ÔÜ	Ð,¨V¨H°AÐ
6Ô7Ü	Ð" 6 (¨!Ð
,Ô-Ø×ÒÜ� §¡˜}¨B¨w¨i°qÐ9Ô:Ü	Ð*¨5¨'°Ð
3Ô4Ü	�‰Ñ	)œ=Ñ	)ñ ,ÜÐ% a S¨Ð*Ô+÷,÷ ,ñ ,ús   ÂB Â B))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òZ
ò2B5òJeHòPTòn
%ò&2ój,r²   