Personal tools
You are here: Home Examples Documentation Chapter 10 roblp.py
Document Actions

roblp.py

The robust LP example of section 10.5

# The robust LP example of section 10.5.

from cvxopt.base import normal, uniform
from cvxopt.modeling import variable, dot, op, sum
from cvxopt.blas import nrm2

m, n = 500, 100
A = normal(m,n)
b = uniform(m)
c = normal(n)

x = variable(n)
op(dot(c,x), A*x+sum(abs(x)) <= b).solve()

x2 = variable(n)
y = variable(n)
op(dot(c,x2), [A*x2+sum(y) <= b, -y <= x2, x2 <= y]).solve()

print "\nDifference between two solutions %e" %nrm2(x.value - x2.value)
 

Powered by Plone CMS, the Open Source Content Management System