Skip to content
Advertisement

it’s possible to obtain the lagrange multipliers from an optimal solution in Pyomo?

I’d like to know how it’s possible to obtain the lagrange multipliers from an optimal solution in a Concrete model solved with glpk?

Thanks!

Advertisement

Answer

This works for me in gurobi, try it out and tell me if it works with glpk.

You need to prompt getting the Lagrange multipliers / dual variable in pyomo by putting the following line somewhere before solving your model:

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

And then after solving the model, you can get the dual variable for all your constraints by:

model.dual.pprint()
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement