I am trying to print shadow prices, but they are equal to zero even for binding constraints. Is there something wrong in the model below?
from pulp import *
# Instantiate our problem class
model = LpProblem("Producao", LpMaximize)
Q9X1 = pulp.LpVariable('Q9X1', lowBound=0, cat='Integer')
Q9X2 = pulp.LpVariable('Q9X2', lowBound=0, cat='Integer')
Q6X1 = pulp.LpVariable('Q6X1', lowBound=0, cat='Integer')
Q6X2 = pulp.LpVariable('Q6X2', lowBound=0, cat='Integer')
# Objective function
model += (1.5 - 1.05) * (Q9X1 + Q6X1) + (1.5 - 0.70) * (Q9X2 + Q6X2)
# Constraints
model += (Q9X1 * 9 + Q6X1 * 6) >= 7 * (Q9X1 + Q6X1), "r1: quali_X1"
model += (Q9X2 * 9 + Q6X2 * 6) >= 8 * (Q9X2 + Q6X2), "r2: quali_X2"
model += Q9X1 + Q9X2 <= 100000, "r3: disp Q9"
model += Q6X1 + Q6X2 <= 120000, "r4: disp Q6"
# Solve our problem
model.solve()
LpStatus[model.status]
# Print our decision variable values
print("Q9X1 = {}".format(Q9X1.varValue))
print("Q6X1 = {}".format(Q6X1.varValue))
print("Q9X2 = {}".format(Q9X2.varValue))
print("Q6X2 = {}".format(Q6X2.varValue))
# Print our objective function value
print("Lucro= $", pulp.value(model.objective))
# Calcula e imprime a análise de sensibilidade:
print("\n Análise de Sensibilidade \n Restrições \t\t Custo Reduzido \t\t Preço Sombra \t\t Folga")
print("\n Análise de Sensibilidade \n Restrições \t\t Preço Sombra \t\t Folga")
for name, c in list(model.constraints.items()):
print(name, "\t\t\t", c.pi, "\t\t", c.slack)
Here's the result:
Análise de Sensibilidade
Restrições Preço Sombra Folga
r1:_quali_X1 -0.0 -0.0
r2:_quali_X2 -0.0 -0.0
r3:_disp_Q9 -0.0 -0.0
r4:_disp_Q6 -0.0 1.0
Process finished with exit code 0