NLopt.optimize returns a tuple (objvalue, xopt, flag)
, and flag is a symbol that can hold strings such as FTOL_REACHED or SUCCESS. The C API mentions that positive return values indicate success. Is there a similar way to test for success or failure with the Julia package? I can’t figure out how to get beyond a string, which I obtain using println("$flag")
. I don’t see how to find an associated numerical value.
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
Thanks, I will use this option.
1 Like