ó
    Eñ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X®l        X¾l        X®R                  l        X¾R                  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)Úsenseéÿÿÿÿz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&                                         Úc/home/mande/repo/quber/.venv/lib/python3.13/site-packages/scipy/optimize/_highspy/_highs_wrapper.pyÚ_highs_wrapperr‡   	   s!  € ðB �V‰V€FØ�X‰X€FØ˜tÐ#×?¬¯ª¨{Ó(;¸aÑ(?€Eð Øñ€Cô 
�Š‹€BØ„KØ„KØ"‡L�LÔØ"‡L�LÔÜŸ?™?×3Ñ3€B‡L�LÔØ„LØ„MØ„MØ„MØ„MØ ‡L�LÔØ!‡L�LÔØ‡L�LÔØ×Ñ˜!ÓÙ7BÓC²{°!œ2Ÿ?š?¨1Ö-±{ÑCˆŒô �IŠI‹K€EÜ—O’OÓ%€MÜ×*Ò*Ó,€KØ—M‘M—O‰ˆˆSà‰;˜# Ó+Ùð ×.Ñ.¨sÓ3ˆØ�‹>ÜØ1´$¸¸S°zÓ2BÐ1CÐDÜØòñ
 àÐ.Ó.ä˜c¤4×(Ñ(Þ"%™$¨5‘CäØ# C 5¨¨s¨eð 42ð 3ä'Ø#$ò	ñ Ü×)Ò)¨(Ó3ˆHÜ& u¨c°3Ó7‰KˆF�CØœ2×-Ñ-×3Ñ3Ó3Ü! #¤t×,Ñ,ÜØ# C 5¨¨s¨eð 42ð 3ä'Ø#$ò	ñ ð ˜‹{Ü�Sœ/°aÕ8ä˜ s¨C×0ñW $ðZ ×"Ñ" =Ó1€JØ”R—^‘^×*Ñ*Ó*Ø�
‰
à×.Ñ.Ó0Ø ×4Ñ4°U×5IÑ5IÓ5KÓLñô	
ð ˆ
à—/‘/ "Ó%€KØ”b—n‘n×+Ñ+Ó+ä×.Ñ.×:Ñ:ÐØ�
‰
à*Ø ×4Ñ4Ð5EÓFñô	
ð ˆ
ð —‘“€JØ”R—^‘^×*Ñ*Ó*Ø�
‰
à×.Ñ.Ó0Ø ×4Ñ4°U×5IÑ5IÓ5KÓLñô	
ð ˆ
ð ×'Ñ'Ó)€Lð �=‰=‹?€Dð $Ü
×Ñ×$Ñ$Ü
×Ñ×&Ñ&Ü
×Ñ×+Ñ+Ü
×Ñ×*Ñ*ð	,ñ ÷ ð 	ä×Ñ×*Ñ*Ü×Ñ×/Ñ/Ü×Ñ×.Ñ.ð
ñ	
÷ 	<ð ×*Ñ*¬b¯l©lÑ:ð ð #¤b×&9Ñ&9×&BÑ&BÑB€OÞÖ"®E¶oØ�
‰
à&Ø-Ø×,Ñ,¨\Ó:Ð;ð <$à×/Ñ/°×0KÑ0KÓLÐMðOð  $×;Ñ;Ø×3Ñ3Ø!%×!?Ñ!?ñ	ô	
ð ˆ
ð × Ñ Ó"€HØ�N‰NÓ€Eô —’˜!˜V˜Ó%€IØ×'Ñ'ÐØ ×)Ñ)ÐÜ�FŽmˆØ˜BÑ¤2×#6Ñ#6×#=Ñ#=Ó=Ø0°Ñ4ˆI�a˜�eÓØ˜bÑ!¤R×%8Ñ%8×%?Ñ%?Õ?Ø0°Ñ4ˆI�a˜�eÓñ	 ð ‡J�Jà"Ø×0Ñ0°Ó>ä—’˜(×,Ñ,Ó-ð ˜8×-Ñ-Ñ-ä—h’h˜x×0Ñ0Ó1Ø"Ø×0Ñ0Ø×7Ñ7Ø×/Ñ/Ø!×;Ñ;ñ	
ôö& Ø�
‰
à"&×"5Ñ"5Ø"&×"5Ñ"5ØŸ<™<ñô	
ð €JùòW 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Ñ2°6Ó:Ñ€FÜ×*Ò*Ó,€Kà”—‘×#Ñ#Ó#Ø)ô 	×Ñ× Ñ ¤$Ü
×Ñ×Ñ¤Ü
×Ñ×"Ñ"¤EÜ
×Ñ×"Ñ"¤Cð	€Kð  —O‘O K°Ó6€MàœÒØ×.Ñ.¨v×=Ñ=Ø.ØœÒØ×.Ñ.¨v×=Ñ=Ø.ØœÒØ×+Ñ+¨F×:Ñ:Ø.àÑØ(à&×5Ñ5°fÓ=Ñ€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Ÿ   