首页 > 编程语言 > 详细

python 利用cvxopt线性规划

时间:2016-09-19 13:02:47      阅读:1096      评论:0      收藏:0      [点我收藏+]

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‘]

 

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

python 利用cvxopt线性规划

原文:http://www.cnblogs.com/Kermit-Li/p/5884561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!