
    bi
                     \    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d Z
 G d de	      Zy	)
    )problems)ParameterError)Constant)	Parameter)	Reductionc                    t        | t              r| D cg c]  }t        |       c}S t        | j	                               dk(  r| S t        | t
              r,| j                  t        d      t        | j                        S g }| j                  D ]  }|j                  t        |              | j                  |      S c c}w )Nr   z(Problem contains unspecified parameters.)
isinstancelistreplace_params_with_constslen
parametersr   valuer   r   argsappendcopy)exprelemnew_argsargs       W/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/reductions/eval_params.pyr   r      s    $=ABT*40BB	T__	1	$	D)	$:: !KLL

##99 	=COO6s;<	=yy"" Cs   Cc                   (    e Zd ZdZdefdZd Zd Zy)
EvalParamsz8Replaces symbolic parameters with their constant values.returnc                      y)NT )selfproblems     r   acceptszEvalParams.accepts   s        c                    t        |j                  j                               dkD  r;t        |j                  j                        } t        |j                        |      }n|j                  }g }|j                  D ]  }g }|j                  D ]  }|j                  t        |              t        d t        ||j                        D              r|j                  |       h|j                         }|!|j                   t        |      ||z           |j                   t        |      |         t        j                  j                  ||      g fS )a  Replace parameters with constant values.

        Parameters
        ----------
        problem : Problem
            The problem whose parameters should be evaluated.

        Returns
        -------
        Problem
            A new problem where the parameters have been converted to constants.

        Raises
        ------
        ParameterError
            If the ``problem`` has unspecified parameters (i.e., a parameter
            whose value is None).
        r   c              3   P   K   | ]  \  }}t        |      t        |      k(     y w)N)id).0newolds      r   	<genexpr>z#EvalParams.apply.<locals>.<genexpr>@   s!     H(#s2c7bg%Hs   $&)r   	objectiver   r   r   typeconstraintsr   r   allzipget_datar   r   Problem)	r   r   obj_exprr'   r)   cr   r   datas	            r   applyzEvalParams.apply   s-   * w  ++-.21'2C2C2H2HIH/W../9I))I$$ 	7ADvv =6s;<= Hc$6GHH""1% zz|#&&wtAw'>?&&wtAw~6	7 ''	;?CCr   c                     |S )zKReturns a solution to the original problem given the inverse_data.
        r   )r   solutioninverse_datas      r   invertzEvalParams.invertK   s	     r   N)__name__
__module____qualname____doc__boolr   r1   r5   r   r   r   r   r      s    B$ +DZr   r   N)cvxpyr   cvxpy.errorr   $cvxpy.expressions.constants.constantr   %cvxpy.expressions.constants.parameterr   cvxpy.reductions.reductionr   r   r   r   r   r   <module>r@      s%     & 9 ; 0# 6 6r   