PyPSA / linopy

Linear optimization with N-D labeled arrays in Python
https://linopy.readthedocs.io
MIT License
154 stars 42 forks source link

Add solution values for linear expressions #230

Closed brynpickering closed 4 months ago

brynpickering commented 4 months ago

Variables have computed values in the solution after a successful model solve, but linear expressions do not.

It would be great for solution values to be computed for any linear expressions that are stored in memory at solve time. Or, like Pyomo, to have linear expressions added to the model (add_linexpr?) and then have values computed for those expressions on a successful solve.

FabianHofmann commented 4 months ago

Hey @brynpickering, thanks for your comment. This would actually be quite nice. We could add a solution attribute to the LinearExpression/QuadraticExpression class. Since these are always referenced to a model instance, it will be easy to retrieve/process the values.

leuchtum commented 4 months ago

I was about to open an issue before I saw this already existing one. The proposed feature would be a great benefit for us, since our models consist of a composition of many linear expressions, but each expression itself is an important part of subsequent analyses.

FabianHofmann commented 4 months ago

I totally agree, the feature is coming in #249 :)