I am trying to get SimulatedAnnealing to work for an optimisation problem, so I first look at a basic example.
using Optim f(x) = (1.0 - x)^2 + 100.0 * (x - x^2)^2
This works fine:
x0 = [0.0,0.0] res = optimize(f, x0, NelderMead())
and the output claims success:
* Status: success * Candidate solution Final objective value: 3.525527e-09 * Found with Algorithm: Nelder-Mead * Convergence measures √(Σ(yᵢ-ȳ)²)/n ≤ 1.0e-08 * Work counters Seconds run: 0 (vs limit Inf) Iterations: 60 f(x) calls: 117
Next, I try using SimulatedAnnealing (with boundaries):
x0 = [0.0,0.0] lb = [-100.0, -100.0] ub = [100.0, 100.0] res = optimize(f, lb, ub, x0, SAMIN(), Optim.Options(iterations=10^6))
the output claims that this was a failure (
================================================================================ SAMIN results ==> Normal convergence <== total number of objective function evaluations: 23101 Obj. value: 0.0000000000 parameter search width 1.00000 0.00000 1.00000 0.00000 ================================================================================ * Status: failure * Candidate solution Final objective value: 3.005018e-17 * Found with Algorithm: SAMIN * Convergence measures |x - x'| = NaN ≰ 0.0e+00 |x - x'|/|x'| = NaN ≰ 0.0e+00 |f(x) - f(x')| = NaN ≰ 0.0e+00 |f(x) - f(x')|/|f(x')| = NaN ≰ 0.0e+00 |g(x)| = NaN ≰ 0.0e+00 * Work counters Seconds run: 1 (vs limit Inf) Iterations: 23101 f(x) calls: 23101 ∇f(x) calls: 0
however, the minimizer is still good, with
Finally, I try normal SimulatedAnnealing:
x0 = [0.0,0.0] res = optimize(f, x0, SimulatedAnnealing(), Optim.Options(iterations=10^6))
again the output claims failure, and this time gives a reason;
(reached maximum number of iterations). Again, the minimizer is actually good (
= [0.9999999587029669, 0.9999999176131619]).
What is going on here? This seems like a simple problem (I tried to use this one: Optim.jl). Also, why is it claiming failure while the result seems to be good, am I missing something?