diff --git a/lib/OptimizationNLopt/src/OptimizationNLopt.jl b/lib/OptimizationNLopt/src/OptimizationNLopt.jl index 660034f43..516d47850 100644 --- a/lib/OptimizationNLopt/src/OptimizationNLopt.jl +++ b/lib/OptimizationNLopt/src/OptimizationNLopt.jl @@ -125,31 +125,6 @@ function __map_optimizer_args!(cache::OptimizationCache, opt::NLopt.Opt; return nothing end -function __nlopt_status_to_ReturnCode(status::Symbol) - if status in Symbol.([ - NLopt.SUCCESS, - NLopt.STOPVAL_REACHED, - NLopt.FTOL_REACHED, - NLopt.XTOL_REACHED, - NLopt.ROUNDOFF_LIMITED - ]) - return ReturnCode.Success - elseif status == Symbol(NLopt.MAXEVAL_REACHED) - return ReturnCode.MaxIters - elseif status == Symbol(NLopt.MAXTIME_REACHED) - return ReturnCode.MaxTime - elseif status in Symbol.([ - NLopt.OUT_OF_MEMORY, - NLopt.INVALID_ARGS, - NLopt.FAILURE, - NLopt.FORCED_STOP - ]) - return ReturnCode.Failure - else - return ReturnCode.Default - end -end - function SciMLBase.__solve(cache::OptimizationCache{ F, RC, @@ -258,7 +233,7 @@ function SciMLBase.__solve(cache::OptimizationCache{ t0 = time() (minf, minx, ret) = NLopt.optimize(opt_setup, cache.u0) t1 = time() - retcode = __nlopt_status_to_ReturnCode(ret) + retcode = deduce_retcode(ret) if retcode == ReturnCode.Failure @warn "NLopt failed to converge: $(ret)" diff --git a/src/utils.jl b/src/utils.jl index cf219df5d..b58dc937f 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -94,7 +94,8 @@ const STOP_REASON_MAP = Dict( r"STOP: XTOL.TOO.SMALL" => ReturnCode.ConvergenceFailure, r"STOP: TERMINATION" => ReturnCode.Terminated, r"Optimization completed" => ReturnCode.Success, - r"Convergence achieved" => ReturnCode.Success + r"Convergence achieved" => ReturnCode.Success, + r"ROUNDOFF_LIMITED" => ReturnCode.Success ) # Function to deduce ReturnCode from a stop_reason string using the dictionary