NLopt.jl
NLopt.jl copied to clipboard
"nlopt failure" should be recoverable
In the function "chk", you often throw which causes the final value of the optimum to be unavailable. In some cases, the optimum is still useful. It would be better to have access to this.
I agree (I just ran into this myself).
One can work around this by keeping track of the current best variable in the objective function, but it's a bit ugly.
Which exception in particular are you thinking of as being recoverable? In general, the underlying nlopt library may not save the final value best of the optimum on failures.
At least NLOPT_ROUNDOFF_LIMITED should be recoverable, since the documentation specifically states that "the optimization still typically returns a useful result" in this case.
Looking at the code, I see that in fact chk() already handles the NLOPT_ROUNDOFF_LIMITED case, so that's good.
Closing as stale.
We graceful handle ROUNDOFF_LIMITED and FORCED_STOP errors.
Please re-open if you're still interested in this and have a different error code that you'd like to be recoverable.