I’m trying to use NLopt
though GalacticOptim
, but can’t get it work. What am I doing wrong below?
using NLopt
using GalacticOptim
# rosenbrock
function f(x; a=1, b=100)
(a - x[1])^2 + b*(x[2] - x[1]^2)^2
end
# GO wrapper
function go_f(x, p)
f(x; a=p[1], b=p[2])
end
p = [1, 100]
x0 = [10, 10]
nlopt_go = Opt(:LD_MMA, 2)
nlopt_go.lower_bounds = [-Inf, -Inf]
nlopt_go.xtol_rel = 1e-8
prob = OptimizationProblem(go_f, x0, p)
go_sol = solve(prob, nlopt_go)
the last line is supposed to do the optimization but all I get in return is the initial point x0
.