Closed dtxl closed 1 month ago
@gdalle is this supposed to be living in ADTypes?
For what it's worth I don't think our recent changes caused this bug, but we could definitely add something like NoAD
to ADTypes.jl. Although I would rather call it AutoNothing
to respect the naming conventions.
MWE showing that this can be triggered by using OptimizationOptim.JL Optim.BFGS(), when using upper/lower bounds:
(NB: Looks like this is a regression introduced in Optimization.jl v3.25.0)
import Optimization
import OptimizationOptimJL
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
optfunc = Optimization.OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff())
x0 = zeros(2)
_p = [1.0, 100.0]
prob = Optimization.OptimizationProblem(optfunc, x0, _p)
sol = Optimization.solve(prob, OptimizationOptimJL.Optim.BFGS()) # OK
prob_lbub = Optimization.OptimizationProblem(optfunc, x0, _p; lb=[-2.0, -1.0], ub=[2.0, 3.0])
sol = Optimization.solve(prob_lbub, OptimizationOptimJL.Optim.BFGS()) # fails
with stack trace:
ERROR: UndefVarError: `NoAD` not defined
Stacktrace:
[1] #__init#2
@ ~/.julia/packages/OptimizationOptimJL/heecd/src/OptimizationOptimJL.jl:93 [inlined]
[2] __init (repeats 2 times)
@ ~/.julia/packages/OptimizationOptimJL/heecd/src/OptimizationOptimJL.jl:75 [inlined]
[3] #init#628
@ ~/.julia/packages/SciMLBase/SDjaO/src/solve.jl:174 [inlined]
[4] init
@ ~/.julia/packages/SciMLBase/SDjaO/src/solve.jl:172 [inlined]
[5] solve(::SciMLBase.OptimizationProblem{…}, ::Optim.BFGS{…}; kwargs::@Kwargs{})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/solve.jl:96
[6] solve(::SciMLBase.OptimizationProblem{…}, ::Optim.BFGS{…})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/solve.jl:93
[7] top-level scope
@ REPL[50]:1
Some type information was truncated. Use `show(err)` to see complete types.
The breaking change is this commit: https://github.com/SciML/Optimization.jl/commit/3d5d10261f2c9d6b2bd2d6f443f4fd1a456ebe2c PR https://github.com/SciML/Optimization.jl/pull/741 @Vaibhavdixit02
@sjdaines you are correct, I don't know how I missed this. Thanks a lot!
Describe the bug 🐞
Since yesterday the error "LoadError: UndefVarError:
NoAD
not defined" appears after updating packages.Expected behavior
Previously, the code did not give this error, it is unclear why it no longer works or what a proper way to code.
Minimal Reproducible Example 👇
The code is extensive, so I can only provide a code fragment here for now
Error & Stacktrace ⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context