PuLP
可用于解决线性、整形规划问题
常用框架
from pulp import *
## max 3 x + 5 y
## s.t. x <= 4
## 2y <= 12
## 3 x + 2 y <= 18
## x >= 0
## y >= 0
prob = LpProblem("WynCor", LpMaximize)
# Decision variables
x = LpVariable("x", 0)
y = LpVariable("y", 0)
# Constraints
prob += x <=4
prob += 2*y <=12
prob += 3*x + 2*y <=18
# Objective
prob += 3*x + 5*y
# Solve
prob.solve()
LpStatus[prob.status]
# Results
x.varValue
y.varValue
value(prob.objective)
解决线性规划问题: 一个比较复杂的示例例 in Jupyter Notebook
Document Information
- Author: Zeka Lee
- Link: https://zhekaili.github.io/wiki/python-libs/python-lib-PuLP/
- Copyright: 自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)