Search code examples
cvxpy

How to use warm_start with Dual variables in cvxpy


How do I set starting guess for dual variable in cvxpy? for a normal single value problem the solution is

x.value = 1/2

How would this be done for a dual variable problem?

Code example

import cvxpy as cp

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

# Create two constraints.
constraints = [x + y == 1,
               x - y >= 1]

# Form objective.
obj = cp.Minimize((x - y)**2)

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

# This is the way I amagine but it does not work
constraints[0].dual_value = 3
prob.solve()

# The optimal dual variable (Lagrange multiplier) for
# a constraint is stored in constraint.dual_value.
print("optimal (x + y == 1) dual variable", constraints[0].dual_value)
print("optimal (x - y >= 1) dual variable", constraints[1].dual_value)
print("x - y value:", (x - y).value)

Solution

  • CVXPY does not currently support starting guesses, neither for primal or dual variables.