I’m just trying to get a feel for how to use JuMP.
I try
model = Model(optimizer_with_attributes(
Ipopt.Optimizer))
f(x) = x^2
register(model, :f, 1, f; autodiff = true)
@variable(model, x)
@NLconstraint(model, x <= 5)
@NLobjective(model, Max, f(x))
using Printf
optimize!(model);
status = @sprintf("%s", JuMP.termination_status(model));
if (status=="LOCALLY_SOLVED")
@show value(x);
@show objective_value(model);
end
I get: EXIT: Iterates diverging; problem might be unbounded.
Full output: here.
I also tried changing the constraint to @NLconstraint(model, x^3 <= 5)
, and that gave a solution at x^*=0, which is wrong.
Can someone tell me what’s wrong? Thanks