Open
Description
Describe the bug π
Using certain solvers, one cannot change the state of the optimization in the callback function
Expected behavior
The state to be updateable in the callback function
Minimal Reproducible Example π
using Optimization, OptimizationOptimJL
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
optf = OptimizationFunction(rosenbrock, AutoFiniteDiff())
prob = Optimization.OptimizationProblem(optf, x0, p)
function callback(state, loss)
state.u .= 0
false
end
sol = solve(prob, Optimization.LBFGS(), callback=callback) # changes state
sol = solve(prob, OptimizationOptimJL.LBFGS(), callback=callback) # does not change state
Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
[7f7a1694] Optimization v4.0.5
[36348300] OptimizationOptimJL v0.4.1
- Output of
versioninfo()
Julia Version 1.10.7
Commit 4976d05258 (2024-11-26 15:57 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 Γ 12th Gen Intel(R) Core(TM) i5-1240P
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
Threads: 10 default, 0 interactive, 5 GC (on 16 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS = 10