
    -i,                     T    S SK Jr  S SKrS SKJs  Js  Jr  S SK	J
r  S SKJr  S rS rg)    )warnN)_highs_options)OptimizeWarningc
                 ^   U R                   n
UR                   nUSL=(       a    [        R                  " U5      S:  nSSS.n[        R                  " 5       nXl        Xl        XR                  l        XR                  l        [        R                  R                  UR                  l
        Xl        Xnl        X~l        XNl        X^l        XR                  l        X.R                  l        X>R                  l        UR                   S:  a,  U Vs/ s H  n[        R&                  " U5      PM     snUl        [        R*                  " 5       n[        R,                  " 5       n[.        R0                  " 5       nU	R3                  5        GH  u  nnUb  US;   a  M  UR5                  U5      nSU:X  a  [7        S[9        UU05       3[:        SS9  MH  US	;   a9  [=        U[>        5      (       a  U(       a  S
OSnO[7        SU SU S3[:        SS9  M  [        R@                  " U5      n[C        UUU5      u  nnU[        R@                  RD                  :X  a-  [=        U[>        5      (       d  [7        SU SU S3[:        SS9  M  US:w  a  [7        U[:        SS9  GM  [G        UUU5        GM      URI                  U5      nU[        RJ                  RL                  :X  aA  URO                  URQ                  5       URS                  URQ                  5       5      S.5        U$ URU                  U5      nU[        RJ                  RL                  :X  a?  [        RV                  RX                  nURO                  UURS                  U5      S.5        U$ UR[                  5       nU[        RJ                  RL                  :X  aA  URO                  URQ                  5       URS                  URQ                  5       5      S.5        U$ URQ                  5       nUR]                  5       nU[        RV                  R^                  [        RV                  R`                  [        RV                  Rb                  [        RV                  Rd                  4;  =(       dt    U[        RV                  R`                  [        RV                  Rb                  [        RV                  Rd                  1;   =(       a    URf                  [        Rh                  :H  nU[        RV                  R^                  :g  nU(       a  U(       d  U(       dl  U(       ae  URO                  USURS                  U5       SURk                  URl                  5       3URn                  URp                  URr                  S.5        U$ URu                  5       n URw                  5       n![        Rx                  " SU
45      n"U!Rz                  n#U R|                  n$[        U
5       H]  n%U#U%   [        R                  R                  :X  a  U$U%   U"SU%4'   M0  U#U%   [        R                  R                  :X  d  MS  U$U%   U"SU%4'   M_     URO                  UURS                  U5      [        R                  " U R                  5      UU R                  -
  [        R                  " U R                  5      U"URf                  URn                  URp                  URr                  S.
5        U(       a3  URO                  UR                  UR                  UR                  S.5        U$ s  snf )a	  Solve linear programs using HiGHS [1]_.

Assume problems of the form:

    MIN c.T @ x
    s.t. lhs <= A @ x <= rhs
         lb <= x <= ub

Parameters
----------
c : 1-D array, (n,)
    Array of objective value coefficients.
astart : 1-D array
    CSC format index array.
aindex : 1-D array
    CSC format index array.
avalue : 1-D array
    Data array of the matrix.
lhs : 1-D array (or None), (m,)
    Array of left hand side values of the inequality constraints.
    If ``lhs=None``, then an array of ``-inf`` is assumed.
rhs : 1-D array, (m,)
    Array of right hand side values of the inequality constraints.
lb : 1-D array (or None), (n,)
    Lower bounds on solution variables x.  If ``lb=None``, then an
    array of all `0` is assumed.
ub : 1-D array (or None), (n,)
    Upper bounds on solution variables x.  If ``ub=None``, then an
    array of ``inf`` is assumed.
options : dict
    A dictionary of solver options

Returns
-------
res : dict

    If model_status is one of kOptimal,
    kObjectiveBound, kTimeLimit,
    kIterationLimit:

        - ``status`` : HighsModelStatus
            Model status code.

        - ``message`` : str
            Message corresponding to model status code.

        - ``x`` : list
            Solution variables.

        - ``slack`` : list
            Slack variables.

        - ``lambda`` : list
            Lagrange multipliers associated with the constraints
            Ax = b.

        - ``s`` : list
            Lagrange multipliers associated with the constraints
            x >= 0.

        - ``fun``
            Final objective value.

        - ``simplex_nit`` : int
            Number of iterations accomplished by the simplex
            solver.

        - ``ipm_nit`` : int
            Number of iterations accomplished by the interior-
            point solver.

    If model_status is not one of the above:

        - ``status`` : HighsModelStatus
            Model status code.

        - ``message`` : str
            Message corresponding to model status code.

Notes
-----
If ``options['write_solution_to_file']`` is ``True`` but
``options['solution_file']`` is unset or ``''``, then the solution
will be printed to ``stdout``.

If any iteration limit is reached, no solution will be
available.

``OptimizeWarning`` will be raised if any option value set by
the user is found to be incorrect.

References
----------
.. [1] https://highs.dev/
.. [2] https://www.maths.ed.ac.uk/hall/HiGHS/HighsOptions.html
Nr   )xfun)sensezUnrecognized options detected:    )
stacklevel)presolveparallelonoffz	Option f"z" is "z4", but only True or False is allowed. Using default.)statusmessagezmodel_status is z; primal_status is )r   r   simplex_nitipm_nitcrossover_nit   )
r   r   r   slacklambda	marg_bndsr   r   r   r   )mip_node_countmip_dual_boundmip_gap)Jsizenpsum_hHighsLpnum_col_num_row_	a_matrix_MatrixFormatkColwiseformat_	col_cost_
col_lower_
col_upper_
row_lower_
row_upper_start_index_value_HighsVarTypeintegrality__HighsHighsOptionshoptHighsOptionsManageritemsget_option_typer   dictr   
isinstanceboolHighsOptionTypecheck_optionkBoolsetattrpassOptionsHighsStatuskErrorupdategetModelStatusmodelStatusToString	passModelHighsModelStatuskModelErrorrungetInfokOptimal
kTimeLimitkIterationLimitkSolutionLimitobjective_function_value	kHighsInfsolutionStatusToStringprimal_solution_statussimplex_iteration_countipm_iteration_countcrossover_iteration_countgetSolutiongetBasiszeros
col_statuscol_dualrangeHighsBasisStatuskLowerkUpperarray	col_value	row_valuerow_dualr   r   r   )&cindptrindicesdatalhsrhslbubintegralityoptionsnumcolnumrowisMipreslpihighshighs_optionshoptmanagerkeyvalopt_typer   msg
opt_statusinit_statuserr_model_status
run_statusmodel_statusinfomipFailConditionlpFailConditionsolutionbasisr   basis_col_statussolution_col_dualiis&                                         Y/var/www/html/venv/lib/python3.13/site-packages/scipy/optimize/_highspy/_highs_wrapper.py_highs_wrapperr   	   s!   B VVFXXFt#?{(;a(?E C 
BKK"LL"LL??33BLLLMMMM LL!LLLL!7BC{!2??1-{C IIKEOO%M**,KMMOS;#+ ..s3>1$Sz2B1CD
 ..c4(("%$5C#C5se 42 3'#$	 ))(3H&uc37KFC2--333!#t,,#C5se 42 3'#$	  {S/a8sC0W $Z ""=1JR^^***

..0 44U5I5I5KL	
 
//"%Kbnn+++..::

* 445EF	
 
 JR^^***

..0 44U5I5I5KL	
 
 '')L ==?D $
$$
&&
++
**	,   	**//..
	
 	< **bll:  #b&9&9&B&BBO"Eo

&-,,\:; <$//0K0KLMO  $;;33!%!?!?		
 
   "HNNE !V%I'' ))FmB2#6#6#=#==04Iaeb!R%8%8%?%??04Iae	  JJ"00>(,,- 8---hhx001"0077//!;;	
& 

"&"5"5"&"5"5<<	
 JW Ds    \*c                    U R                  U5      u  p4[        R                  " 5       nU[        R                  R
                  :w  a  g[        R                  R                  [        [        R                  R                  [        [        R                  R                  [        [        R                  R                  [        0nUR                  US 5      nU[        L a  UR!                  X5      (       d  gU[        L a  UR#                  X5      (       d  gU[        L a  UR%                  X5      (       d  gUc  gU R'                  U5      u  p8U[        R                  R
                  :w  a  gg)N)r
   zInvalid option name.)r
   zInvalid option value.)   zUnknown option type.)   z Failed to validate option value.)r   zCheck option succeeded.)getOptionTyper4   r5   r    r@   kOkr;   r=   r:   kIntintkDoublefloatkStringstrgetcheck_string_optioncheck_double_optioncheck_int_optiongetOptionValue)	
highs_instoptionvaluer   option_typert   valid_typesexpected_typecurrent_values	            r   r<   r<   2  s   $226:F**,K###) 	  $

""E
""C	K  OOK6M..v==...v==.++F::.(&55f=F###4'    )warningsr   numpyr   scipy.optimize._highspy._coreoptimize_highspy_corer    scipy.optimize._highspyr   r4   scipy.optimizer   r   r<    r   r   <module>r      s#      * * : *fR	 (r   