I have the following MWE, with most of the code just copied from the MultiStartOptimization.jl documentation:
using Optimization, OptimizationMultistartOptimization, OptimizationNLopt
using Zygote
using ForwardDiff
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
f = OptimizationFunction(rosenbrock)
function solve_rosenbrock(p)
prob = Optimization.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, MultistartOptimization.TikTak(100), NLopt.LD_LBFGS())
println(sol.minimizer)
return rosenbrock(sol.minimizer, p)
end
Zygote.gradient(x -> solve_rosenbrock(x), [1.0, 1.0])
When running it, I get the error:
ERROR: DomainError with -1: Cannot raise an integer x to a negative power -1. Make x or -1 a float by adding a zero decimal (e.g., 2.0^-1 or 2^-1.0 instead of 2^-1)or write 1/x^1, float(x)^-1, x^float(-1) or (x//1)^-1..
Is it just that MultiStartOptimization is not compatible with Zygote ? Because when I use ForwardDiff instead of Zygote, I do not get any errors. I would really prefer to use Zygote if possible.
Thanks in advance for any help