python线性规划

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,算法,python,算法)