JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.12k stars 217 forks source link

`outer_x_abstol` option ignored #1023

Open soldasim opened 1 year ago

soldasim commented 1 year ago

Hello,

It seems that the outer_x_abstol option is ingored by Optim.

Consider the mwe below.

using Optim

function test()
    f(x) = exp(x[1]) * sin(x[2]) * cos(x[3])
    domain = ([0.,0.,0.], [20.,20.,20.])

    show_trace=false
    # Optim.optimize(f, domain..., [15.,15.,15.], Fminbox(LBFGS()), Optim.Options(; outer_iterations=20, show_trace))
    Optim.optimize(f, domain..., [15.,15.,15.], Fminbox(LBFGS()), Optim.Options(; outer_x_abstol=1., outer_iterations=20, show_trace))
    # Optim.optimize(f, domain..., [15.,15.,15.], Fminbox(LBFGS()), Optim.Options(; outer_x_tol=1., outer_iterations=20, show_trace))
end

Both the version without any convergence measure and with the outer_x_abstol option give the following result:

julia> test()
 * Status: success

 * Candidate solution
    Final objective value:     -4.851652e+08

 * Found with
    Algorithm:     Fminbox with L-BFGS

 * Convergence measures
    |x - x'|               = 5.63e-11 ≰ 0.0e+00
    |x - x'|/|x'|          = 1.90e-12 ≰ 0.0e+00
    |f(x) - f(x')|         = 0.00e+00 ≤ 0.0e+00
    |f(x) - f(x')|/|f(x')| = 0.00e+00 ≤ 0.0e+00
    |g(x)|                 = 3.39e-03 ≰ 1.0e-08

 * Work counters
    Seconds run:   0  (vs limit Inf)
    Iterations:    7
    f(x) calls:    703
    ∇f(x) calls:   703

While the option with the outer_x_tol option gives:

julia> test()
 * Status: success

 * Candidate solution
    Final objective value:     -4.851652e+08

 * Found with
    Algorithm:     Fminbox with L-BFGS

 * Convergence measures
    |x - x'|               = 1.62e-05 ≰ 0.0e+00
    |x - x'|/|x'|          = 5.48e-07 ≰ 0.0e+00
    |f(x) - f(x')|         = 0.00e+00 ≤ 0.0e+00
    |f(x) - f(x')|/|f(x')| = 0.00e+00 ≤ 0.0e+00
    |g(x)|                 = 1.15e+00 ≰ 1.0e-08

 * Work counters
    Seconds run:   0  (vs limit Inf)
    Iterations:    2
    f(x) calls:    83
    ∇f(x) calls:   83

I was under the impression that the outer_x_abstol and outer_x_tol options should be equivalent.

pkofod commented 1 year ago

That looks suspicious, yes.