Here is my code which utilizes Optimization.jl and ModelingToolkit.jl:
using BenchmarkTools, Optimization, OptimizationNLopt, ModelingToolkit
function func_1(x0,p)
sse = sum(x0) + p[1]
return sse
end
function cb(p,l)
println("Running callback")
display(p)
display(l)
return false
end
x0 = ones(2)
p = [2]
lower_bounds = zeros(2).-2
upper_bounds = zeros(2).+2
func = OptimizationFunction(func_1, AutoModelingToolkit(false,false))
prob = Optimization.OptimizationProblem(func,x0,p,lb = lower_bounds, ub = upper_bounds)
@time sol = solve(prob, NLopt.LD_LBFGS(), callback=cb, reltol = 1e2)
Code works fine, but the following line does not output anything:
sol.stats