opencobra / optlang

optlang - sympy based mathematical programming language
http://optlang.readthedocs.org/
Apache License 2.0
241 stars 50 forks source link

Access to value of constraint variable at the end of model.optimize? #254

Open janpeter19 opened 1 year ago

janpeter19 commented 1 year ago

Checklist

Question

I am a new user to Opltang and just used it for smaller problems, mainly linear-programming. It would be very convenient to have access to the actual value of a constraining variable at the end of an optimisation. The actual objectiv as well as variables I can get but I do not see how to read out the value of the constraint. Can you help me?

Examples: model.objective.value - ok model.variables.x_opt.primal - ok model.constraints.y_lim.value - not ok model.constraints.y_lim.primal - not ok

cdiener commented 1 year ago

As long as y_lim is the name of the constraint the last option should work. What error are you getting?