Ipopt and external function

I think you want to register the function as in: https://jump.dev/JuMP.jl/latest/nlp/#User-defined-Functions-1

I got a solution of (x=1.0000000000034162, y=1.0000000000069469) with the following code:

using JuMP
using Ipopt

model = Model(Ipopt.Optimizer)
function fopt(x,y) 
  return (1 - x)^2 + 100 * (y - x^2)^2;
end
@variable(model, x, start = 0.0)
@variable(model, y, start = 0.0)

register(model, :fopt, 2, fopt, autodiff=true)

@NLobjective(model, Min, fopt(x,y))
JuMP.optimize!(model)
2 Likes