cvxpy.reductions.qp2quad_form package

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

Subpackages

Submodules

cvxpy.reductions.qp2quad_form.qp2symbolic_qp module

Copyright 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.qp2quad_form.qp2symbolic_qp.Qp2SymbolicQp(problem=None)[source]

Bases: Canonicalization

Reduces a quadratic problem to a problem that consists of affine expressions and symbolic quadratic forms.

accepts(problem)[source]

Problems with quadratic, piecewise affine objectives, piecewise-linear constraints inequality constraints, and affine equality constraints are accepted.

apply(problem)[source]

Converts a QP to an even more symbolic form.

cvxpy.reductions.qp2quad_form.qp2symbolic_qp.accepts(problem)[source]

Problems with quadratic, piecewise affine objectives, piecewise-linear constraints inequality constraints, and affine equality constraints are accepted by the reduction.

cvxpy.reductions.qp2quad_form.qp_matrix_stuffing module

Copyright 2016 Jaehyun Park, 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.qp2quad_form.qp_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

nonpos

The dimension of the non-positive 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

class cvxpy.reductions.qp2quad_form.qp_matrix_stuffing.ParamQuadProg(P, q, x, A, variables, var_id_to_col, constraints, parameters, param_id_to_col, formatted: bool = False)[source]

Bases: ParamProb

Represents a parameterized quadratic program.

minimize x’Px + q^Tx + d subject to (in)equality_constr1(A_1*x + b_1, …)

… (in)equality_constrK(A_i*x + b_i, …)

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

apply_param_jac(delP, delq, 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)[source]

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

Parameters:
  • id_to_param_value – (optional) dict mapping parameter ids to values

  • zero_offset – (optional) if True, zero out the constant offset in the parameter vector

  • keep_zeros – (optional) if True, store explicit zeros in A where parameters are affected

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.

class cvxpy.reductions.qp2quad_form.qp_matrix_stuffing.QpMatrixStuffing(canon_backend: str | None = None)[source]

Bases: MatrixStuffing

Fills in numeric values for this problem instance.

Outputs a DCP-compliant minimization problem with an objective of the form

QuadForm(x, p) + q.T * x

and Zero/NonNeg constraints, both of which exclusively carry affine arguments.

static 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]

See docstring for MatrixStuffing.apply

invert(solution, inverse_data)[source]

Retrieves the solution to the original problem.

stuffed_objective(problem, extractor)[source]

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.