Create quadratic objective will @objective and @NLobjective lead to different solution using Ipopt


#1

We can create quadratic objective with either @objective or @NLobjective. The following is an example created with @NLobjective, and I get the objective value -17. However, when I changed @NLobjective to @objective and run the script again, I got the objective value 0. Anyone know why there is this difference?

using JuMP
using Ipopt
m=Model(solver=IpoptSolver())
@variable(m, 0<= x1 <= 1, start=1)
@variable(m, 0<= x2 <=1, start=1)
@variable(m, 0<= x3 <=1)
@variable(m, 0<= x4 <=1, start=1)
@variable(m, 0<= x5 <=1)
@constraint(m, 20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40)
@NLobjective(m, Min, 42*x1 - 0.5*(100*x1*x1 + 100*x2*x2 + 100*x3*x3 + 100*x4*x4 + 100*x5*x5) + 44*x2 + 45*x3 + 47*x4 + 47.5*x5)

status=solve(m)
println("Objective Value ", getobjectivevalue(m))

#2

You’ve uncovered a slight inconsistency in the LPQP and nonlinear pathways. Expect a fix in JuMP 0.16: https://github.com/JuliaOpt/JuMP.jl/pull/944.