NLopt return flag: is there a simple way to check for success?

You can see the return codes here:
https://github.com/JuliaOpt/NLopt.jl/blob/c93b84844e7e372d03658a90b7f1cf108969bc2a/src/NLopt.jl#L66-L78
but unfortunately NLopt returns a Symbol instead of the enum:
https://github.com/JuliaOpt/NLopt.jl/blob/c93b84844e7e372d03658a90b7f1cf108969bc2a/src/NLopt.jl#L622
So you probably just need to deal with each of the possible return values.

Or something like

is_success(ret::Symbol) = ret == :SUCCESS || endswith("$ret", "_REACHED")
1 Like