Optim.jl icon indicating copy to clipboard operation
Optim.jl copied to clipboard

improve SAMIN convergence message, fix issue #960

Open mcreel opened this issue 3 years ago • 1 comments

This PR makes SAMIN report function and parameter convergence messages so that they are correctly reported to Optim, and convergence is correctly displayed.

The code

using Optim
rosenbrock(x, p) =  (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2

function main()
x0 = zeros(2)
p  = [1.0, 100.0]
obj = x -> rosenbrock(x,p)
lb = fill(-100., 2)
ub = fill(100., 2)
prob = Optim.optimize(obj, lb, ub, x0, SAMIN(), Optim.Options(iterations=10^6))
end
main()

now gives the output

julia> include("CheckSAMIN.jl")
================================================================================
SAMIN results
==> Normal convergence <==
total number of objective function evaluations: 23801

     Obj. value:      0.0000000000

       parameter      search width
         1.00000           0.00000 
         1.00000           0.00000 
================================================================================

 * Status: success

 * Candidate solution
    Final objective value:     8.834636e-17

 * Found with
    Algorithm:     SAMIN

 * Convergence measures
    |x - x'|               = 2.07e-07 ≤ 1.0e-06
    |x - x'|/|x'|          = NaN ≰ 0.0e+00
    |f(x) - f(x')|         = 4.39e-13 ≤ 1.0e-12
    |f(x) - f(x')|/|f(x')| = NaN ≰ 0.0e+00
    |g(x)|                 = NaN ≰ 0.0e+00

``

mcreel avatar Jun 03 '22 14:06 mcreel

Codecov Report

Merging #988 (75990d2) into master (d5cb5da) will increase coverage by 0.07%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #988      +/-   ##
==========================================
+ Coverage   85.34%   85.41%   +0.07%     
==========================================
  Files          42       42              
  Lines        3187     3189       +2     
==========================================
+ Hits         2720     2724       +4     
+ Misses        467      465       -2     
Impacted Files Coverage Δ
src/multivariate/solvers/constrained/samin.jl 78.82% <100.00%> (+1.44%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d5cb5da...75990d2. Read the comment docs.

codecov[bot] avatar Jun 03 '22 15:06 codecov[bot]

Thanks a lot!

pkofod avatar Sep 04 '22 06:09 pkofod