Error with Ipopt

Hi, I am using JuMP and IPOPT to solve an non-linear optimization, below is my code

using JuMP
using Ipopt
model =Model(solver=IpoptSolver())
@variable(model, x )
@variable(model, y )
@variable(model, z )
#define our objective function
@NLobjective(model, Min,x/z)
#define our constraints
@constraint(model, x+y-1<=-0.01)
@NLconstraint(model, -x+y*z+1<=-0.01)
@constraint(model, -x<=-0.01)
@constraint(model, -y<=-0.01)
@constraint(model, -z<=-0.01)

print(model)
#solve statement
status = solve(model)
println("Objective value: ", getobjectivevalue(model))
println("x = ", getvalue(x))
println("y = ", getvalue(y))
println("z = ", getvalue(z))

And for some reasons it returns

EXIT: Invalid number in NLP function or derivative detected.
┌ Warning: Ipopt finished with status Invalid_Number_Detected
└ @ Ipopt ~/.julia/packages/Ipopt/Iu7vT/src/MPB_wrapper.jl:178
┌ Warning: Not solved to optimality, status: Error
└ @ JuMP ~/.julia/packages/JuMP/PbnIJ/src/nlp.jl:1283
Objective value: 0.0
x = 0.0
y = 0.0
z = 0.0

I can’t find any error in the code. Isn’t ipopt supposed to solve non-linear constraint optimization?

It looks like ‘dividing by zero’ problem. In your objective function, you may add a small constant to the denominator, for example:

@NLobjective(model, Min, x / (z + 1e-9) )

Ipopt still didn’t give an optimal solution though. I think you need to consider reformulating the problem.

1 Like

Thanks!