BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
569 stars 102 forks source link

Better error when no solution found #150

Closed marcosfelt closed 1 year ago

marcosfelt commented 1 year ago

Currently, when the solver doesn't find a solution, it raises a generic exception. Using a generic exception makes it difficult to specifically catch failed solutions and do custom error handling.

https://github.com/BYU-PRISM/GEKKO/blob/3e2698a5324a5fce87a659c94ae3c7cd1bff7922/gekko/gekko.py#L2140

Would you accept a PR that creates a custom error for failed solutions?

APMonitor commented 1 year ago

Try setting debug=0 to allow the code to proceed without the exception with m.solve(debug=0). The status is reported by m.options.APPSTATUS or m.options.APPINFO for more specific error information.