I am using CVXOPT for linear programming according to the following example:
http://abel.ee.ucla.edu/cvxopt/examples/tutorial/lp.html
I am pretty sure I express a constraint that
X1 >= 0
But get a negative value for it.
How come? I get the “optimal solution found” message
A = matrix( [ [0.0, 0.0, 1.0, 1.0, -0.0, -0.0, -1.0, -1.0, -1.0, 0.0, 0.0],
[0.0, 1.0, 1.0, 0.0, -0.0, -1.0, -1.0, -0.0, 0.0, -1.0, 0.0],
[1.0, 0.0, 0.0, 1.0, -1.0, -0.0, -0.0, -1.0, 0.0, 0.0, -1.0]
]
)
Constraint values (right hand side)
b = matrix( [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0] )
Minimizing function:
c = matrix( [-1.0, -1.0, -1.0] )
Calling:
sol=solvers.lp(c,A,b)
But:
print (sol['x']):
[-4.83e-09]
[ 1.00e+00]
[ 1.00e+00]
-4.83e-09>=0
False
Thanks
The default feasibility tolerance in CVXOPT is 1.0e-7, according to the user guide. Therefore you should expect that your constraints are only fulfilled to this level of accuracy.
EDIT Thus, to ensure that your “hard” constraint is fulfilled for certain, you need to set your lower variable bounds to equal your “hard” constraint (i.e. 0 in your case) plus the feasibility tolerance: