# Problem in @NLobjective

**URL:** <https://discourse.julialang.org/t/problem-in-nlobjective/33190>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, first-steps\
**Created:** [January 10, 2020, 10:40am UTC](https://discourse.julialang.org/t/problem-in-nlobjective/33190 "2020-01-10T10:40:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiuliaM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giuliam/32/209287_2.png) [@GiuliaM](https://discourse.julialang.org/u/GiuliaM)\
**Post date:** [January 10, 2020, 10:40am UTC](https://discourse.julialang.org/t/problem-in-nlobjective/33190/1 "2020-01-10T10:40:28Z")

</div>

Hi everyone!  
I’m a new Julia user.  
I am using Julia 1.2 and JuMP v0.20.0 for some optimization problems.  
I have a constrained nonlinear optimization and I would like to define a nonlinear objective function composed by two parts: one is a sum of vector components (each multiplied by a different coefficient), while the other one should be insert in the objective function only if some optimization variables (xNL[[Nvar\*(i-1)+1]]) assume a value above a certain tolerance (\>1e-4).  
I think the expression “\>” is not supported in @NLobjective, is there some way to obtain the NLobjective function I need?  
I attach a photo which shows part of my JuMP model and the relative error.  
Thanks in advance for help!

 ![Schermata 2020-01-10 alle 12.31.36](https://global.discourse-cdn.com/julialang/original/3X/8/8/883456045d2a05e95df6e209352f4da742ba2f6a.png)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 10, 2020, 2:38pm UTC](https://discourse.julialang.org/t/problem-in-nlobjective/33190/2 "2020-01-10T14:38:07Z")

</div>

You cannot use `>` in a sum like this. To model this properly, you will need to add binary variables, transforming your problem into a mixed-integer nonlinear program (i.e., very hard to solve), and you won’t be able to use Ipopt. Are you sure you want to have a hard 0-1 jump?

A slightly relaxed approach could be to use a [sigmoid](https://en.wikipedia.org/wiki/Sigmoid_function) centered at `1e-4`.

p.s., You should read the first post of: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757). In particular, it’s much easier to help if you post the text of your code, rather than a photo.

---

<div class="post-metadata">

**Author:** ![GiuliaM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giuliam/32/209287_2.png) [@GiuliaM](https://discourse.julialang.org/u/GiuliaM)\
**Post date:** [January 13, 2020, 10:22am UTC](https://discourse.julialang.org/t/problem-in-nlobjective/33190/3 "2020-01-13T10:22:00Z")

</div>

thank you very much for the answer! I used the sigmoid and it works!  
I’m sorry for posting the screenshot, next time I’ll text my code following the ten points shown in the post!  
Thanks again!
