Basic JuMP Question

I’m just trying to get a feel for how to use JuMP.

I try

model = Model(optimizer_with_attributes(

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

status = @sprintf("%s", JuMP.termination_status(model));
if (status=="LOCALLY_SOLVED")
    @show value(x);
    @show objective_value(model);

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

The objective function is unbounded (when x gets bigger and bigger, the objective value also gets bigger in both negative and positive directions). What about adding the constraint

@constraint(model, x >= 0)