Issue with dual values for continuous model
回答済みI have a continuous model with a linear objective function with a minimization sense.
My expectation of duality would be that given:
total = 0
for c in rm.getConstrs():
total += c.RHS * c.Pi
"total" would be equal to the objective value, if strong duality holds, or at least less than the objective value, if weak duality holds.
However,
print(total - rm.ObjVal)
751391.7872288637
Which has me pretty confused. The Objective value of my model is:
Optimal objective 1.099028532e+07
I'm optimizing with default parameters. Is Gurobi maybe not updating the dual values to the final value after finishing optimization? And if this is the case, can I force this update? Or am I missing something else entirely?
-
正式なコメント
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
In theory your code is correct. However, in practice, models are not in standard form, i.e., there are also variable bounds and objective constants you have to consider . The following code should do the trick
total = m.ObjCon
for c in m.getConstrs():
total += c.RHS * c.Pi
for v in m.getVars():
if v.VBasis == -1:
total += v.RC * v.lb
if v.VBasis == -2:
total += v.RC * v.ubBest regards,
Jaromił1 -
I also had this problem, Jaromił is correct. Please use GRB_INFINITY to define the UB of the variable if it is implicitly bounded by some constraints elsewhere.
0
投稿コメントは受け付けていません。
コメント
3件のコメント