# Inconsistance between @NLobjective and @objective

**URL:** <https://discourse.julialang.org/t/inconsistance-between-nlobjective-and-objective/54520>\
**Category:** Optimization (Mathematical)\
**Tags:** package, jump, optimization\
**Created:** [February 3, 2021, 9:07am UTC](https://discourse.julialang.org/t/inconsistance-between-nlobjective-and-objective/54520 "2021-02-03T09:07:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 3, 2021, 9:07am UTC](https://discourse.julialang.org/t/inconsistance-between-nlobjective-and-objective/54520/1 "2021-02-03T09:07:37Z")

</div>

Let’s consider the following model:

```julia
model = Model(with_optimizer(Ipopt.Optimizer))
@variable(model, x >= 0)
@variable(model, y >= 1)

```

Then the macro `@objective` can be used both as:

`@objective(model, Min, x+2*y)`

or

```julia
@objective model Min begin
    x+2*y
end

```

The macro @NLobjective however can be used only as:

`@NLobjective(model, Min, exp(x)+y)`

But NOT as:

```julia
@NLobjective model Min begin
    exp(x)+y
end

```

The above script would indeed lead to weird error messages.

Should it be reported as a bug ?  
The best solution for me would be to uniform the two APIs, but at least a better error message could be provided…

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [February 3, 2021, 9:31am UTC](https://discourse.julialang.org/t/inconsistance-between-nlobjective-and-objective/54520/2 "2021-02-03T09:31:31Z")

</div>

Yes, thanks for letting us know. Please file an issue with the error you get.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 3, 2021, 9:39am UTC](https://discourse.julialang.org/t/inconsistance-between-nlobjective-and-objective/54520/3 "2021-02-03T09:39:21Z")

</div>

Thanks, done: [Inconsistance between @NLobjective and @objective · Issue #2448 · jump-dev/JuMP.jl · GitHub](https://github.com/jump-dev/JuMP.jl/issues/2448)
