cvxpy.reductions.dcp2cone packageΒΆ

Please see our disclaimer about the Reductions API before using these directly in your code.

SubpackagesΒΆ

SubmodulesΒΆ

cvxpy.reductions.dcp2cone.cone_matrix_stuffing moduleΒΆ

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

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.

class cvxpy.reductions.dcp2cone.cone_matrix_stuffing.ConeDims(constr_map)[source]ΒΆ

Bases: object

Summary of cone dimensions present in constraints.

Constraints must be formatted as dictionary that maps from constraint type to a list of constraints of that type.

zeroΒΆ

The dimension of the zero cone.

Type:ΒΆ

int

nonnegΒΆ

The dimension of the non-negative cone.

Type:ΒΆ

int

expΒΆ

The number of 3-dimensional exponential cones.

Type:ΒΆ

int

socΒΆ

A list of the second-order cone dimensions.

Type:ΒΆ

list of int

psdΒΆ

A list of the positive semidefinite cone dimensions, where the dimension of the PSD cone of k by k matrices is k.

Type:ΒΆ

list of int

EQ_DIM = 'f'ΒΆ
EXP_DIM = 'ep'ΒΆ
LEQ_DIM = 'l'ΒΆ
P3D_DIM = 'p3'ΒΆ
PND_DIM = 'pnd'ΒΆ
PSD_DIM = 's'ΒΆ
SOC_DIM = 'q'ΒΆ
class cvxpy.reductions.dcp2cone.cone_matrix_stuffing.ConeMatrixStuffing(quad_obj: bool = False, canon_backend: str | None = None)[source]ΒΆ

Bases: MatrixStuffing

Construct matrices for linear cone problems.

Linear cone problems are assumed to have a linear objective and cone constraints which may have zero or more arguments, all of which must be affine.

CONSTRAINTS = 'ordered_constraints'ΒΆ
accepts(problem)[source]ΒΆ

States whether the reduction accepts a problem.

Parameters:ΒΆ
problem : ProblemΒΆ

The problem to check.

Returns:ΒΆ

True if the reduction can be applied, False otherwise.

Return type:ΒΆ

bool

apply(problem)[source]ΒΆ

Returns a stuffed problem.

The returned problem is a minimization problem in which every constraint in the problem has affine arguments that are expressed in the form A @ x + b.

Parameters:ΒΆ
problem : The problem to stuff; the arguments of every constraintΒΆ

must be affine

Returns:ΒΆ

  • Problem – The stuffed problem

  • InverseData – Data for solution retrieval

invert(solution, inverse_data)[source]ΒΆ

Retrieves a solution to the original problem

stuffed_objective(problem, extractor)[source]ΒΆ
class cvxpy.reductions.dcp2cone.cone_matrix_stuffing.ParamConeProg(q, x, A, variables, var_id_to_col, constraints, parameters, param_id_to_col, P=None, formatted: bool = False, lower_bounds: ndarray | None = None, upper_bounds: ndarray | None = None)[source]ΒΆ

Bases: ParamProb

Represents a parameterized cone program

minimize q’x + d + [(1/2)x’Px] subject to cone_constr1(A_1*x + b_1, …)

… cone_constrK(A_i*x + b_i, …)

The constant offsets d and b are the last column of c and A.

apply_param_jac(delc, delA, delb, active_params=None)[source]ΒΆ

Multiplies by Jacobian of parameter mapping.

Assumes delA is sparse.

Returns:ΒΆ

A dictionary param.id -> dparam

apply_parameters(id_to_param_value=None, zero_offset: bool = False, keep_zeros: bool = False, quad_obj: bool = False)[source]ΒΆ

Returns A, b after applying parameters (and reshaping).

Parameters:ΒΆ
id_to_param_value=NoneΒΆ

(optional) dict mapping parameter ids to values.

zero_offset: bool = FalseΒΆ

(optional) if True, zero out the constant offset in the parameter vector.

keep_zeros: bool = FalseΒΆ

(optional) if True, store explicit zeros in A where parameters are affected.

quad_obj: bool = FalseΒΆ

(optional) if True, include quadratic objective term.

is_mixed_integer() bool[source]ΒΆ

Is the problem mixed-integer?

split_adjoint(del_vars=None)[source]ΒΆ

Adjoint of split_solution.

split_solution(sltn, active_vars=None)[source]ΒΆ

Splits the solution into individual variables.

cvxpy.reductions.dcp2cone.dcp2cone moduleΒΆ

Copyright 2013 Steven Diamond, 2017 Akshay Agrawal, 2017 Robin Verschueren

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

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.

class cvxpy.reductions.dcp2cone.dcp2cone.Dcp2Cone(problem=None, quad_obj: bool = False, solver_context=None)[source]ΒΆ

Bases: Canonicalization

Reduce DCP problems to a conic form.

This reduction takes as input (minimization) DCP problems and converts them into problems with affine or quadratic objectives and conic constraints whose arguments are affine.

accepts(problem)[source]ΒΆ

A problem is accepted if it is a minimization and is DCP.

apply(problem)[source]ΒΆ

Converts a DCP problem to a conic form.

canonicalize_expr(expr, args, affine_above: bool) tuple[Expression, list][source]ΒΆ

Canonicalize an expression, w.r.t. canonicalized arguments.

Parameters:ΒΆ
expr : The expression tree to canonicalize.ΒΆ

args : The canonicalized arguments of expr.ΒΆ

affine_above : The path up to the root node is all affine atoms.ΒΆ

Return type:ΒΆ

A tuple of the canonicalized expression and generated constraints.

canonicalize_tree(expr, affine_above: bool) tuple[Expression, list][source]ΒΆ

Recursively canonicalize an Expression.

Parameters:ΒΆ
expr : The expression tree to canonicalize.ΒΆ

affine_above : The path up to the root node is all affine atoms.ΒΆ

Return type:ΒΆ

A tuple of the canonicalized expression and generated constraints.

Module contentsΒΆ

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

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.