简体   繁体   English

有可能从 Pyomo 的最优解中获得拉格朗日乘数吗?

[英]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?我想知道如何从用 glpk 解决的混凝土 model 的最佳解决方案中获得拉格朗日乘数?

Thanks!谢谢!

This works for me in gurobi , try it out and tell me if it works with glpk .这在gurobi中对我有用,试一试并告诉我它是否适用于glpk

You need to prompt getting the Lagrange multipliers / dual variable in pyomo by putting the following line somewhere before solving your model:在求解 model 之前,您需要通过在某处放置以下行来提示在 pyomo 中获取拉格朗日乘数/对偶变量:

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

And then after solving the model, you can get the dual variable for all your constraints by:然后在解决 model 之后,您可以通过以下方式获得所有约束的对偶变量:

model.dual.pprint()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM