Skip to main content

Issue with dual values for continuous model

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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.ub

    Best regards, 
    Jaromił

    1
  • Zhiyuan
    First Comment

    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

Please sign in to leave a comment.