Both shadow price and slack equal zero

171 views
Skip to first unread message

Felipe

unread,
May 5, 2020, 5:16:25 PM5/5/20
to pulp-or-discuss
Hi 

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

Franco Peschiera

unread,
May 6, 2020, 5:55:24 AM5/6/20
to pulp-or-discuss
Hey Felipe.

There are no shadow prices in MIPs. Only in LPs.

Your variables are integer. If you try making them all continuous, you should see them, I guess.

F.

Felipe

unread,
May 6, 2020, 4:43:35 PM5/6/20
to pulp-or...@googlegroups.com
Thank you Franco
Felipe


--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pulp-or-discuss/5f1ee94d-ca1c-48be-85b2-d364746e5355%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages