# Transforms¶

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.

## Scalarize¶

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(objectives, weights)

Combines objectives as a weighted sum.

Parameters: objectives – A list of Minimize/Maximize objectives. weights – A vector of weights. A Minimize/Maximize objective.
scalarize.max(objectives, weights)

Combines objectives as max of weighted terms.

Parameters: objectives – A list of Minimize/Maximize objectives. weights – A vector of weights. A Minimize objective.
scalarize.log_sum_exp(objectives, weights, gamma=1)

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.

Parameters: 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(objectives, priorities, targets, limits=None, off_target=1e-05)

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]

Parameters: 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.

## Other¶

Here we list other available transforms.

class cvxpy.transforms.indicator(constraints, err_tol=0.001)[source]
An expression representing the convex function I(constraints) = 0
if constraints hold, +infty otherwise.
Parameters: constraints (list) – A list of constraint objects. err_tol – A numeric tolerance for determining whether the constraints hold.
transforms.linearize(expr)

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.

Parameters: expr – An expression. An affine expression or None.
transforms.partial_optimize()