
    bi              	           d Z ddlmZmZ ddlZddlmZ dde	de
dedej                  fdZdej                  fd	Zd
 Zdeeef   fdZy)a,  
Copyright 2013 Steven Diamond

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    )AnyDictN	variablesdefaultorderreturnc                    g }| D ]m  }|j                   0|j                  t        j                  |j                   |             ?|j                  t        j                  |j
                  |             o t        j                  |      S )a"  Stacks the values of the given variables.

    Parameters
    ----------
    variables: list of cvxpy variables.
    default: value to use when variable value is None.
    order: unravel values in C or Fortran ("F") order

    Returns
    -------
    An initial guess for the solution.
    )valueappendnpravelfullsizeconcatenate)r   r   r   r
   variables        ]/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/reductions/solvers/utilities.py
stack_valsr      si     E :>>%LL(..%89LL89	:
 >>%      c                     t        j                  t        j                  |      |       }dt        j                  t        j                  |       d      z  }||z   }|S )N   )r   tilearrayrepeatarange)n_conesexp_cone_orderr   offsetsperms        r   expcone_permutorr   .   sG    GGBHH^,g6E"))BIIg.22G7?DKr   c                     | |||j                   z    }|j                   dk(  rt        j                  |      }||j                   z  }||fS )N   )r   intfscalar_value)
result_vecoffset
constraintr
   s       r   extract_dual_valuer'   5   sK    vfz67E!!!%(
jooF&=r   c                 P    i }d}|D ]  } || ||      \  ||j                   <   } |S )a  Gets the values of the dual variables.

    Parameters
    ----------
    result_vec : array_like
        A vector containing the dual variable values.
    parse_func : function
        A function that extracts a dual value from the result vector
        for a particular constraint. The function should accept
        three arguments: the result vector, an offset, and a
        constraint, in that order. An example of a parse_func is
        extract_dual_values, defined in this module. Some solvers
        may need to implement their own parse functions.
    constraints : list
        A list of the constraints in the problem.

    Returns
    -------
       A map of constraint id to dual variable value.
    r   )id)r$   
parse_funcconstraints	dual_varsr%   constrs         r   get_dual_valuesr.   =   sC    * IF N'1*ff'M$	&))fN r   )F)__doc__typingr   r   numpyr   cvxpy.interface	interfacer"   listfloatstrndarrayr   r   r'   r.    r   r   <module>r:      sc       !$ ! !s !RZZ !, DcN r   