Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback function cannot change the state of the optimization #866

Open
oameye opened this issue Dec 24, 2024 · 0 comments
Open

Callback function cannot change the state of the optimization #866

oameye opened this issue Dec 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@oameye
Copy link

oameye commented Dec 24, 2024

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
@oameye oameye added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant