@@ -3,6 +3,7 @@ module OptimizationNLopt
33using Reexport
44@reexport using NLopt, Optimization
55using Optimization. SciMLBase
6+ using Optimization: deduce_retcode
67
78(f:: NLopt.Algorithm )() = f
89
@@ -125,31 +126,6 @@ function __map_optimizer_args!(cache::OptimizationCache, opt::NLopt.Opt;
125126 return nothing
126127end
127128
128- function __nlopt_status_to_ReturnCode (status:: Symbol )
129- if status in Symbol .([
130- NLopt. SUCCESS,
131- NLopt. STOPVAL_REACHED,
132- NLopt. FTOL_REACHED,
133- NLopt. XTOL_REACHED,
134- NLopt. ROUNDOFF_LIMITED
135- ])
136- return ReturnCode. Success
137- elseif status == Symbol (NLopt. MAXEVAL_REACHED)
138- return ReturnCode. MaxIters
139- elseif status == Symbol (NLopt. MAXTIME_REACHED)
140- return ReturnCode. MaxTime
141- elseif status in Symbol .([
142- NLopt. OUT_OF_MEMORY,
143- NLopt. INVALID_ARGS,
144- NLopt. FAILURE,
145- NLopt. FORCED_STOP
146- ])
147- return ReturnCode. Failure
148- else
149- return ReturnCode. Default
150- end
151- end
152-
153129function SciMLBase. __solve (cache:: OptimizationCache {
154130 F,
155131 RC,
@@ -258,7 +234,7 @@ function SciMLBase.__solve(cache::OptimizationCache{
258234 t0 = time ()
259235 (minf, minx, ret) = NLopt. optimize (opt_setup, cache. u0)
260236 t1 = time ()
261- retcode = __nlopt_status_to_ReturnCode (ret)
237+ retcode = deduce_retcode (ret)
262238
263239 if retcode == ReturnCode. Failure
264240 @warn " NLopt failed to converge: $(ret) "
0 commit comments