Python中的线性编程? [英] linear programming in python?

查看:104
本文介绍了Python中的线性编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立一个线性规划模型.这是我正在使用的不平等现象(例如):

I need to make a linear programming model. Here are the inequalities I'm using (for example):

6x + 4y <= 24
x + 2y <= 6
-x + y <= 1
y <= 2

我需要找到由这些不等式描述的区域,并在图形中对其进行阴影处理,并跟踪该区域的边界线的顶点,并以不同的颜色绘制边界线.请参见下图,以了解我要寻找的示例.

I need to find the area described by these inequalities, and shade it in a graph, as well as keep track of the vertices of the bounding lines of this area, and draw the bounding line in a different color. See the graph below for an example of what I'm looking for.

.

我正在使用Python 3.2,numpy和matplotlib.是否有更好的Python线性编程模块?

I'm using Python 3.2, numpy, and matplotlib. Are there better modules for linear programming in Python?

推荐答案

更新:在过去的4年中,答案已经有些过时了, 这是一个更新.您有很多选择:

UPDATE: The answer has become somewhat outdated in the past 4 years, here is an update. You have many options:

我个人使用 Gurobi 这些 天通过其Python API.这是一个商业的,封闭源代码的 产品,但可免费用于学术研究.

I personally use Gurobi these days through its Python API. It is a commercial, closed-source product but free for academic research.

SciPy提供了线性编程: scipy. optimize.linprog . (我有 从来没有尝试过这个.)

SciPy offers linear programming: scipy.optimize.linprog. (I have never tried this one.)

使用 PuLP ,您可以创建

With PuLP you can create MPS and LP files and then solve them with GLPK, COIN CLP/CBC, CPLEX, or XPRESS through their command-line interface. This approach has its advantages and disadvantages.

显然, CVXOPT 提供了 GLPK 8年了,我可以 强烈推荐GLPK. CVXOPT的示例和教程看起来非常好!

Apparently, CVXOPT offers a Python interface to GLPK, I did not know that. I have been using GLPK for 8 years now and I can highly recommend GLPK. The examples and tutorial of CVXOPT seem really nice!

您可以在Wikibook的以下位置找到其他可能性 GLPK/Python .请注意,其中许多未必会被限制 到GLPK.

You can find other possibilites at in the Wikibook under GLPK/Python. Note that many of these are not necessarily resticted to GLPK.

这篇关于Python中的线性编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆