JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.11k stars 213 forks source link

`... || isnan(g_residual(r))` missing in `converged(::MultiVariateOptimizationResult)`? #1010

Open jlbosse opened 1 year ago

jlbosse commented 1 year ago

I am implementing my own ZerothOrderOptimizer and have the suspicion that

https://github.com/JuliaNLSolvers/Optim.jl/blob/38cfbe895dc8126ae029c5d3165d92b6232f3bd4/src/api.jl#L87

should be

    g_isfinite = isfinite(g_residual(r)) || isnan(g_residual(r))

instead. Note that for non-differentiable functions g_residual(d) is defined as

https://github.com/JuliaNLSolvers/Optim.jl/blob/38cfbe895dc8126ae029c5d3165d92b6232f3bd4/src/utilities/assess_convergence.jl#L14

so that for such functions res.g_residual will always be Nan (see https://github.com/JuliaNLSolvers/Optim.jl/blob/38cfbe895dc8126ae029c5d3165d92b6232f3bd4/src/multivariate/optimize/optimize.jl#L110)

and thus the success message printed by

https://github.com/JuliaNLSolvers/Optim.jl/blob/38cfbe895dc8126ae029c5d3165d92b6232f3bd4/src/types.jl#L238

will always be "failure", even if x_converged or f_converged are true

pkofod commented 1 year ago

Hm, I see... Yes we could consider considering NaN as a signal of "unset" for zero order methods, but the only problem is: what if the convergence measure for nelder mead is actually NaN because of a problematic calculation? I suppose a problem here is that NelderMead should have used something else than "g" from the beginning.