oemof / oemof-solph

A model generator for energy system modelling and optimisation (LP/MILP).
https://oemof.org
MIT License
297 stars 126 forks source link

Results processing should check if optimisation succeeded #1056

Open p-snft opened 7 months ago

p-snft commented 7 months ago

It would be easier to pin down issues like #1045 if we checked the status of the optimisation before collecting the results.

More context: When an energy system model is infeasible, solph.Model.solve() will just warn ("UserWarning: Optimization ended with status warning and termination condition infeasible") return without an error. Then, latter solph.processing.results(model) will just seem to work (but not return meaningful results), but processing.meta_results(model) throws a KeyError. This is because it cannot find the objective value in an infeasible model.

As you see, the error handling is not intuitive at all. I see some options:

Model.solve():

processing.results() with (non-existing) "results":

As it will fail anyway, there are no options for processing.meta_results(). We should handle that in our code and provide a meaningful error message.