Different Dual values?
Awaiting user inputWhy do I get different dual values for the same problem when I use model.getAttr("Pi", constraint list) and model.getConstrbyName("Constraint Name").pi?
mdlSP = gurobipy.model("Problem")
#1st Formulation
for j in jc:
for c in co:
for t in tm:
Supply[j,c,t] =mdlSP.addConstr((quicksum(ot[j,jdash,c,t]for jdash in jc)+
quicksum(cta[j]*cta[jdash]*orr[j,jdash,c,t]for jdash in jc)+
quicksum(EC[equ,c]*xt[j,i,c,t,equ]for i in ip for equ in eq)+
quicksum((EC[equ,c]*pta[i]*cta[j]*xr[j,i,c,t,equ])for i in ip for equ in eq)<=
q[j,c,t]), name = "Supply_%s_%s_%s"%(j,c,t))
#Get Dual
mdlSP.getAttr('Pi',Supply)
#2nd Formulation
#Constraint:
for j in jc:
for c in co:
for t in tm:
mdlSP.addConstr((quicksum(ot[j,jdash,c,t]for jdash in jc)+
quicksum(cta[j]*cta[jdash]*orr[j,jdash,c,t]for jdash in jc)+
quicksum(EC[equ,c]*xt[j,i,c,t,equ]for i in ip for equ in eq)+
quicksum((EC[equ,c]*pta[i]*cta[j]*xr[j,i,c,t,equ])for i in ip for equ in eq)<=
q[j,c,t]), name = "Supply_%s_%s_%s"%(j,c,t))
#Get Dual
for j in jc:
for c in co:
for t in tm:
nu[j,c,t] = mdlSP.getConstrByName("Supply_%s_%s_%s"%(jdash,c,t)).pi
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Sanjeev!
Could you please try posting a minimal reproducible example (MRE)?
Thanks,
Matthias0
Post is closed for comments.
Comments
2 comments