Optimization.jl
Optimization.jl copied to clipboard
Add trait for checking if OptimizationFunction is used for derivative based optimizers
Describe the bug 🐞
Currently the error thrown when a user has not used OptimizationFunction
is something like grad not found
. The way to do this would be define a trait like https://github.com/SciML/SciMLBase.jl/blob/0998e074058c99098c673bb3f6f37e30d282ea2f/src/alg_traits.jl#L77-L131, namely a requiresderivative
and then in the solver subpackages check for that based on the algorithms, similar to how other traits are used now https://github.com/SciML/Optimization.jl/blob/master/lib/OptimizationOptimJL/src/OptimizationOptimJL.jl#L9-L16.
Expected behavior
User is informed that the algorithm choice requires OptimizationFunction
Minimal Reproducible Example 👇
using Optimization
rosenbrock(u, p) = (p[1] - u[1])^2 + p[2] * (u[2] - u[1]^2)^2
u0 = zeros(2)
p = [1.0, 100.0]
prob = OptimizationProblem(rosenbrock, u0, p)
using OptimizationOptimJL
sol = solve(prob, LBFGS())