Skip to main content

Cannot retrieve dual variables even after fixing all binary variables and resolving

Awaiting user input

Comments

3 comments

  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi Panagiotis,

    The KeyError does not seem to originate from Pyomo or Gurobi, it seems to be come from the data structures you obtain (dicts, pandas dataframe). Did you check how the data structures (and their contents) look like?

    Best regards,
    Mario

    0
  • Shahin Parvar
    First Comment
    First Question

    Hello,

    I am facing the same problem and can't the dual value that I get as None for all constraints, I am wondering after:

     model.dual = Suffix(direction=Suffix.IMPORT)

    How should I exactly extract these dual variables? I found the following code:

    model.dual_val = model.dual.get(model.c)

    which gives me an error for the constraint index! 

    I appreciate your comments.

     

    0
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi Shahin,

    The constraint indices are created and maintained by Pyomo, not by Gurobi.
    From the Gurobi side, you need to ensure that the optimization result is "optimal" to obtain the dual values.

    Mario

    0

Please sign in to leave a comment.