python 利用cvxopt线性规划

from cvxopt import matrix, solvers

########################################################################

## mimimize 2 x1 + x2

##      subject to

## -x1 +x2 <= 1

## x1 + x2 >= 2

## x2 >= 0

## x1 - 2 x2 <= 4

########################################################################

c = matrix([2.0, 1.0])

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

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

sol = solvers.lp(c,A,b)

print sol['x']

禁止转载,看过请指正,互相学习

原文地址:https://www.cnblogs.com/Kermit-Li/p/5884561.html