import pulp
model = pulp.LpProblem("Profit_maximising_problem", pulp.LpMaximize)
A = pulp.LpVariable('A', lowBound=0, cat='Integer')
B = pulp.LpVariable('B', lowBound=0, cat='Integer')
# Objective function
model += 5000 * A + 2500 * B, "Profit"
# Constraints
model += 3 * A + 2 * B <= 20
model += 4 * A + 3 * B <= 30
model += 4 * A + 3 * B <= 44
# Solve our problem
model.solve()
pulp.LpStatus[model.status]
print (A.varValue)
print (B.varValue)
print (pulp.value(model.objective))
python线性规划
最新推荐文章于 2024-08-14 21:31:57 发布