zhanglab / psamm

Curation and analysis of metabolic models
https://zhanglab.github.io/psamm/
GNU General Public License v3.0
34 stars 15 forks source link

Forward solver errors and raise error on non-optimal solutions #256

Closed jonls closed 7 years ago

jonls commented 7 years ago

Adds the SolverError in the lp module. Exceptions raised from the solver when solve() is called should inherit from this or should be wrapped as this to allow callers to handle such conditions gracefully.

In addition, the SolverError is also raised by solve() when a non-optimal solution is found. This helps avoid a common bug where the result is not checked and therefore non-optimal solution values are used as though an optimal solution was found. Instead the solve() now raises a SolverError when no optimal solution is found. This makes it impossible to forget to check the solution in the most common case. In cases when the exception is not desired the new solve_unchecked() can be used which has the old behavior.