please help me to apply equal constrains into cvxopt for LP problems

52 views
Skip to first unread message

AhmadReza Montazerolghaem

unread,
Aug 19, 2015, 11:41:37 AM8/19/15
to CVXOPT

hi,
The following link demonstrates how to use the LP solver:

but the none of the constrains in the above link is not equal.
please help me to apply the equal constrain in to cvxopt.
for example the follow LP: 
thanks.



Rms Danaraj

unread,
Oct 19, 2015, 12:34:17 PM10/19/15
to CVXOPT

Hi
I have added an equality constrain x1+x2=0 to the same problem and solved it

lp(c, G, h, A=None, b=None, solver=None, primalstart=None, dualstart=None)

Solves a pair of primal and dual LPs

minimize c'*x

subject to G*x + s = h

A*x = b

s >= 0

maximize -h'*z - b'*y

subject to G'*z + A'*y + c = 0

z >= 0.


from cvxopt import matrix, solvers

G = matrix([ [-1.0, -1.0, 0.0, 1.0], [1.0, -1.0, -1.0, -2.0] ])

h = matrix([ 1.0, -2.0, 0.0, 4.0 ])

c = matrix([ 2.0, 1.0 ])

A=matrix([1.,1.])

b=matrix([10.])

sol=solvers.lp(c,G,h,A.T,b)

x=sol['x']

print x


runfile('/home/rms/U/DA/cvx/zlp.py', wdir=r'/home/rms/U/DA/cvx')

pcost dcost gap pres dres k/t

0: 1.7143e+01 1.3500e+01 2e+01 4e-16 2e+00 1e+00

1: 1.6767e+01 1.6166e+01 4e+00 8e-16 3e-01 2e-01

2: 1.4528e+01 1.4434e+01 2e+00 1e-15 1e-01 2e-01

3: 1.4501e+01 1.4500e+01 2e-02 6e-16 1e-03 2e-03

4: 1.4500e+01 1.4500e+01 2e-04 6e-16 1e-05 2e-05

5: 1.4500e+01 1.4500e+01 2e-06 7e-16 1e-07 2e-07

6: 1.4500e+01 1.4500e+01 2e-08 7e-16 1e-09 2e-09

Optimal solution found.

[ 4.50e+00]

[ 5.50e+00]

 

I think this will be enough.
Bye



Reply all
Reply to author
Forward
0 new messages