Skip to content

Instantly share code, notes, and snippets.

@osin-vladimir
Created November 11, 2015 11:09
Show Gist options
  • Select an option

  • Save osin-vladimir/a8242115728343a5378a to your computer and use it in GitHub Desktop.

Select an option

Save osin-vladimir/a8242115728343a5378a to your computer and use it in GitHub Desktop.
from cvxpy import *
import numpy
numpy.random.seed(1)
n = 20
x1 = Variable(n)
x2 = Variable(n)
a = Variable(n)
objective = Minimize(2*x1 + 3*a)
constraints = [a>=x2-10,
a>=10-x2,
x1+x2<=3,
x2-x1>=-3,
x2-x1<=7,
x1+x2>=7]
prob = Problem(objective, constraints)
result = prob.solve()
print result
print x1.value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment