
    bi                         d dl mZ d dlmZ d dlZ ej
                         Z ej                         Z ej                         Z
dZdZdZdZdZd	Zd
ZdZd ZdZdZd Z G d de      Zd Zy)    )sparse)_scs_directNFii      c                 b   | j                  dd      rt        d      | j                  dd      r&| j                  dt              rddlm} |S ddlm} |S | j                  d	d      r%| j                  dd      rt        d
      ddlm} |S | j                  dt              rddlm} |S t        S )NcudssFz1To use cuDSS set gpu=True and use_indirect=False.gpuuse_indirectr   )_scs_gpu)
_scs_cudssmklzAMKL indirect solver not yet available, pass `use_indirect=False`.)_scs_mkl)_scs_indirect)
pop
ValueError_USE_INDIRECT_DEFAULTscsr   r   NotImplementedErrorr   r   r   )stgsr   r   r   r   s        G/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/scs/__init__.py_select_scs_moduler      s    	XXgu
H
II	XXeUxx 56o 	XXeUxx&
M  O	XXn34!	    c                   "    e Zd Zd ZddZddZy)SCSc                 b   || _         |r|st        d      d|vsd|vrt        d      d|vrt        d      |d   }|d   }|d   }|||t        d      t        j                  |      st	        d	      |j
                  d
k(  s%t        j                  d       |j                         }t        j                  |      r|j                         }t        j                  |      r|j                         }t        |      }t        |      }|j                  s|j                          |j                  |j                  |j                  }}
}	|j                   ||fk7  rt        d      d\  }}}d|v r|d   }|t        j                  |      st	        d      |j                   ||fk7  rt        d      |j
                  d
k(  s%t        j                  d       |j                         }t        j"                  |d      j                  j$                  dkD  rt        j&                  |d
      }|j                  s|j                          |j                  |j                  |j                  }}}t)        | j                         } |j*                  ||f|	|
|||||||f
i | j                   | _        y)zInitialize the SCS solver.

    @param data     Dictionary containing keys `P`, `A`, `b`, `c`.
    @param cone     Dictionary containing cone information.
    @param settings Settings as kwargs, see docs.
    z Missing data or cone informationbcz(Missing one of b, c from data dictionaryAzMissing A from data dictionaryNzIncomplete data specificationz#A is required to be a sparse matrixcsczJConverting A to a CSC (compressed sparse column) matrix; may take a while.zA shape not compatible with b,c)NNNPz#P is required to be a sparse matrixz!P shape not compatible with A,b,czJConverting P to a CSC (compressed sparse column) matrix; may take a while.r	   r   )format)	_settingsr   r   issparse	TypeErrorr&   warningswarntocsctodenselenhas_sorted_indicessort_indicesdataindicesindptrshapetrilsizetriur   r   _solver)selfr1   conesettingsr#   r!   r"   mnAdataAindicesAcolptrPdataPindicesPcolptrr%   _scss                    r   __init__zSCS.__init__>   st    DNt9::
$#T/ABB
$788S	AS	AS	AyAI677??1;<<88umm '')aq
))+aq
))+aAAAAnn vvqyy!((W8Eww1a&899/E8W
d{
s)a	
q!?@
@77q!f>?
?xx5 
--* ggi!;;q"""''!+kk!E*!##
..
#$66199ahhx dnn-D 488	
A		 ..DLr   Nc                 >    | j                   j                  ||||      S )a  Solve the optimization problem.

    @param warm_start   Whether to warm-start. By default the solution of
                        the previous problem is used as the warm-start. The
                        warm-start can be overridden to another value by
                        passing `x`, `y`, `s` args.
    @param x            Primal warm-start override.
    @param y            Dual warm-start override.
    @param s            Slack warm-start override.

    @return dictionary with solution with keys:
         'x' - primal solution
         's' - primal slack solution
         'y' - dual solution
         'info' - information dictionary (see docs)
    )r8   solve)r9   
warm_startxyss        r   rG   z	SCS.solve   s    " <<j!Q22r   c                 <    | j                   j                  ||       y)a  Update the `b` vector, `c` vector, or both, before another solve.

    After a solve we can reuse the SCS workspace in another solve if the
    only problem data that has changed are the `b` and `c` vectors.

    @param  b   New `b` vector.
    @param  c   New `c` vector.
    N)r8   update)r9   r!   r"   s      r   rM   z
SCS.update   s     	LL1r   )TNNN)NN)__name__
__module____qualname__rE   rG   rM    r   r   r   r   <   s    Tl3&	r   r   c                     t        | |fi |}d x}x}}d| v r| d   }d| v r| d   }d| v r| d   }|j                  d|||      S )NrI   rJ   rK   T)rH   rI   rJ   rK   )r   rG   )r1   r:   r;   solverrI   rJ   rK   s          r   rG   rG      sk    tT&X&& !a!D[S	AD[S	AD[S	A	a1	55r   )scipyr   r   r   r*   version__version__
sizeof_int__sizeof_int__sizeof_float__sizeof_float__r   INFEASIBLE_INACCURATEUNBOUNDED_INACCURATESIGINTFAILEDINDETERMINATE
INFEASIBLE	UNBOUNDED
UNFINISHEDSOLVEDSOLVED_INACCURATEr   objectr   rG   rQ   r   r   <module>rf      s      !k!!#''')+;++-  
   		
	
	
 @t& tp6r   