Question about Ipopt solver

using JuMP
using Ipopt

m=Model(solver=IpoptSolver())
@variable(m, x1)
@variable(m, x2)
@variable(m, x3)
@NLobjective(m, Max, (log(x1)+log(x2)+log(x3)-1/(1-x1-x2-x3)^2))
@constraint(m,0<=x1)
@constraint(m,0<=x2)
@constraint(m,0<=x3)
@constraint(m,x1+x2+x3<=1)
solve(m)
return getvalue(x1), getvalue(x2), getvalue(x3),getobjectivevalue(m)

After I run the code, it shows that “Invalid number in NLP function or derivative detected.” Could any one tell me what does that mean?

The default start value for variables is zero, so at the start value your objective function is taking the log of zero. You can use the start keyword when creating the variables to use a different value, see Variables · JuMP, or reformulate your problem with a change of variables yi = log(xi).

Thanks!!

1 Like