Hi all, I am trying to use Optimization.jl package together with GCMAES.jl. The solve
function of Optimization.jl should accept a callback function, but I am not able to make it work. Here is a MWE
using Optimization, OptimizationGCMAES
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock)
prob = Optimization.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
function cb(p, l) #callback function to observe training
println("Running callback")
display(p)
display(l)
return false
end
sol = solve(prob, GCMAESOpt(), callback=cb)
It seems like the solve
does not react to the callback at all, not even when the callback function returns true
. Is there something fundamental I am missing about the use of callbacks?
I am doing this in order to track the changes in the optimised parameter of a more complicated function.