I have tried GalacticOptim.jl
but I did not manage to get the constraints to work.
using GalacticOptim, Optim
using Plots
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
circle_constr(x, p) = [x[1]^2 + x[2]^2 - 1] # x_1^2 + x_^2 <= 1
x0 = zeros(2)
optprob = OptimizationFunction(rosenbrock, GalacticOptim.AutoForwardDiff(); cons=circle_constr)
prob = OptimizationProblem(optprob, x0, p, lcons = [-Inf], ucons = [Inf])
sol = solve(prob, IPNewton())
plot(ratio=:equal)
contourf!(-1:0.1:1, -1:0.1:1, (x,y)->rosenbrock([x,y], p), c=:viridis, lw=0)
contour!(-1:0.1:1, -1:0.1:1, (x,y)->circle_constr([x,y], p)[1], levels=[0], c=:blue)
scatter!([sol.u[1]], [sol.u[1]], c=:red, label="solution")
Although no error is thrown the result is incorrect. It is the unconstrained optimum.
Am I doing something wrong?