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

**URL:** <https://discourse.julialang.org/t/create-quadratic-objective-will-objective-and-nlobjective-lead-to-different-solution-using-ipopt/1666>\
**Category:** Optimization (Mathematical)\
**Created:** [January 24, 2017, 7:09pm UTC](https://discourse.julialang.org/t/create-quadratic-objective-will-objective-and-nlobjective-lead-to-different-solution-using-ipopt/1666 "2017-01-24T19:09:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yankai\_Cao](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yankai\_Cao](https://discourse.julialang.org/u/Yankai_Cao)\
**Post date:** [January 24, 2017, 7:09pm UTC](https://discourse.julialang.org/t/create-quadratic-objective-will-objective-and-nlobjective-lead-to-different-solution-using-ipopt/1666/1 "2017-01-24T19:09:48Z")

</div>

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?

```julia
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))

```

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [January 24, 2017, 7:35pm UTC](https://discourse.julialang.org/t/create-quadratic-objective-will-objective-and-nlobjective-lead-to-different-solution-using-ipopt/1666/2 "2017-01-24T19:35:46Z")

</div>

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](https://github.com/JuliaOpt/JuMP.jl/pull/944).
