Transforms provide additional ways of manipulating CVXPY objects beyond the atomic functions. While atomic functions operate only on expressions, transforms may also take Problem, Objective, or Constraint objects as input. Transforms do not need to conform to any specific API.


The SuppFunc transform accepts an implicit representation of a convex set in terms of some CVXPY Variable and returns a function handle representing the convex set’s support function. When the function handle is evaluated it returns a SuppFuncAtom object. Such objects can be used like any other CVXPY Expression for purposes of convex optimization modeling.

class cvxpy.transforms.suppfunc.SuppFunc(x, constraints)[source]

Given a list of CVXPY Constraint objects \(\texttt{constraints}\) involving a real CVXPY Variable \(\texttt{x}\), consider the convex set

\[S = \{ v : \text{it's possible to satisfy all } \texttt{constraints} \text{ when } \texttt{x.value} = v \}.\]

This object represents the support function of \(S\). This is the convex function

\[y \mapsto \max\{ \langle y, v \rangle : v \in S \}.\]

The support function is a fundamental object in convex analysis. It’s extremely useful for expressing dual problems using Fenchel duality.

  • x (Variable) – This variable cannot have any attributes, such as PSD=True, nonneg=True, symmetric=True, etc…

  • constraints (list[Constraint]) – Usually, these are constraints over \(\texttt{x}\), and some number of auxiliary CVXPY Variables. It is valid to supply \(\texttt{constraints = []}\).


If \(\texttt{h = cp.SuppFunc(x, constraints)}\), then you can use \(\texttt{h}\) just like any other scalar-valued atom in CVXPY. For example, if \(\texttt{x}\) was a CVXPY Variable with \(\texttt{x.ndim == 1}\), you could do the following:

z = cp.Variable(shape=(10,))
A = np.random.standard_normal((x.size, 10))
c = np.random.rand(10)
objective =  h(A @ z) - c @ z
prob = cp.Problem(cp.Minimize(objective), [])


You are allowed to use CVXPY Variables other than \(\texttt{x}\) to define \(\texttt{constraints}\), but the set \(S\) only consists of objects (vectors or matrices) with the same shape as \(\texttt{x}\).

It’s possible for the support function to take the value \(+\infty\) for a fixed vector \(\texttt{y}\). This is an important point, and it’s one reason why support functions are actually formally defined with the supremum “\(\sup\)” rather than the maximum “\(\max\)”. For more information on support functions, check out this Wikipedia page.

__call__(y) SuppFuncAtom[source]

Return an atom representing

max{ cvxpy.vec(y) @ cvxpy.vec(x) : x in S }

where S is the convex set associated with this SuppFunc object.


The scalarize transforms convert a list of objectives into a single objective, for example a weighted sum. All scalarizations are monotone in each objective, which means that optimizing over the scalarized objective always returns a Pareto-optimal point with respect to the original list of objectives. Moreover, all points on the Pareto curve except for boundary points can be attained given some weighting of the objectives.

scalarize.weighted_sum(weights) Minimize | Maximize

Combines objectives as a weighted sum.

  • objectives – A list of Minimize/Maximize objectives.

  • weights – A vector of weights.


A Minimize/Maximize objective.

scalarize.max(weights) Minimize

Combines objectives as max of weighted terms.

  • objectives – A list of Minimize/Maximize objectives.

  • weights – A vector of weights.


A Minimize objective.

scalarize.log_sum_exp(weights, gamma: float = 1.0) Minimize

Combines objectives as log_sum_exp of weighted terms.

The objective takes the form

log(sum_{i=1}^n exp(gamma*weights[i]*objectives[i]))/gamma

As gamma goes to 0, log_sum_exp approaches weighted_sum. As gamma goes to infinity, log_sum_exp approaches max.

  • objectives – A list of Minimize/Maximize objectives.

  • weights – A vector of weights.

  • gamma – Parameter interpolating between weighted_sum and max.


A Minimize objective.

scalarize.targets_and_priorities(priorities, targets, limits=None, off_target: float = 1e-05) Minimize | Maximize

Combines objectives with penalties within a range between target and limit.

Each Minimize objective i has value

priorities[i]*objectives[i] when objectives[i] >= targets[i]

+infinity when objectives[i] > limits[i]

Each Maximize objective i has value

priorities[i]*objectives[i] when objectives[i] <= targets[i]

+infinity when objectives[i] < limits[i]

  • objectives – A list of Minimize/Maximize objectives.

  • priorities – The weight within the trange.

  • targets – The start (end) of penalty for Minimize (Maximize)

  • limits – The hard end (start) of penalty for Minimize (Maximize)

  • off_target – Penalty outside of target.


A Minimize/Maximize objective.


Here we list other available transforms.

class cvxpy.transforms.indicator(constraints: List[Constraint], err_tol: float = 0.001)[source]
An expression representing the convex function I(constraints) = 0

if constraints hold, +infty otherwise.

  • constraints (list) – A list of constraint objects.

  • err_tol – A numeric tolerance for determining whether the constraints hold.


Returns an affine approximation to the expression computed at the variable/parameter values.

Gives an elementwise lower (upper) bound for convex (concave) expressions that is tight at the current variable/parameter values. No guarantees for non-DCP expressions.

If f and g are convex, the objective f - g can be (heuristically) minimized using the implementation below of the convex-concave method:

for iters in range(N):
    Problem(Minimize(f - linearize(g))).solve()

Returns None if cannot be linearized.


expr – An expression.


An affine expression or None.


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.