1. 导入库函数
from pulp import *
2. 定义线性规划问题
PB = LpProblem(problom name, sense)
name指定问题名
sense值是LpMinimize 或LpMaximize中的一个用来指定目标函数是求最大值还是最小值
**3.定义决策变量 **
DV = LpVariable (decision variable name , lowbound, upbound,category)
decision variable name 指定变量名,也就是x1,x2,~.lowBound,upBound 是上界和下界,默认值是负无穷到正无穷,category用来指定变量是离散(Lpinterger,LpBinary)还是连续(LpContnuous)
4. 添加目标函数
PB += linear objective in equantion from objective name
5.添加约束条件
PB += linear objective in equantion from constraint name
6.写入LP文件
PB.writeLP(filename)
7.模型求解
PB.solve()
8.结果显示