Questions tagged [cvxpy]

For mathematical questions about CVXPY; questions purely about the language, syntax, or runtime errors would likely be better received on Stack Overflow. CVXPY is a Python-embedded modeling language for convex optimization problems.

CVXPY is a Python-embedded modeling language for convex optimization problems. It allows problems to be expressed in a natural syntax which follows the math, rather in the restrictive standard form in other solvers.

For example, the following code shows an intuitive syntax for a sample problem.

from cvxpy import *

# Create two scalar optimization variables.
x = Variable()
y = Variable()

# Create two constraints.
constraints = [3*x + 2*y == 1,
               x - y <= 1]

# Form objective.
obj = Minimize(square(x + y))

# Form and solve problem.
pblm = Problem(obj, constraints)
pblm.solve()

# The optimal value for x is stored in x.value.
print x.value
# The optimal dual variable (Lagrange multiplier) for
# a constraint is stored in constraint.dual_value.
print constraints[1].dual_value

CVXPY is licensed under Apache 2.0, so you are free to use it for any purpose as long as the license text is retained.

Some useful resources for users:

29 questions