Optimization Problems

The Problem class allows one to define optimization problems of various types. Consider the following problem:

\[ \begin{align}\begin{aligned}\text{minimize } & \| A^\top x - b \|\\\text{subject to } & x \geq 0\end{aligned}\end{align} \]

with \(x\in\mathbb{R}^4\). We can define it as:

import numpy as np
from disropt.problems import Problem
from disropt.functions import Variable, Norm

x = Variable(4)
A = np.random.randn(n, n)
b = np.random.randn(n, 1)

obj = Norm(A @ x - b)
constr = x >= 0

pb = Problem(objective_function = obj, constraints = constr)

If the problem is convex, it can be solved as:

solution = pb.solve()

Generic (convex) nonlinear problems of the form

\[ \begin{align}\begin{aligned}\text{minimize } & f(x)\\\text{subject to } & g(x) \leq 0\\ & h(x) = 0\end{aligned}\end{align} \]

are solved through the cvxpy solver (when possible), or with the cvxopt solver, while more structured problems (LPs and QPs) can be solved through other solvers (osqp and glpk). The integration with other solvers will be provided in future releases. LPs and QPs can be directly defined through specific classes (LinearProblem and QuadraticProblem). However, the Problem class is capable to recognize LPs and QPs, which are automatically converted into the appropriate format.

Projection onto the constraints set

Projecting a point onto the constraints set of a problem is often required in distributed optimization algorithms. The method project_on_constraint_set is available to do this:

projected_point = pb.project_on_constraint_set(pt)