# Changing Ipopt options

**URL:** <https://discourse.julialang.org/t/changing-ipopt-options/72156>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [November 27, 2021, 10:15am UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156 "2021-11-27T10:15:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)\
**Post date:** [November 27, 2021, 10:15am UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/1 "2021-11-27T10:15:04Z")

</div>

I have a nonlinear program which Ipopt finds the optimal solution for it, with adding some changes into the problem the solver can not find the optimal solution anymore and iterates till the maximum number of iterations.

Is there any option in Ipopt which I can change and tune for solving the problem?

---

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)\
**Post date:** [November 27, 2021, 11:37am UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/2 "2021-11-27T11:37:28Z")

</div>

There is a whole bunch of ipopt options that you could change ([Ipopt: Ipopt Options](https://coin-or.github.io/Ipopt/OPTIONS.html)) from JuMP ([Models · JuMP](https://jump.dev/JuMP.jl/stable/reference/models/#JuMP.optimizer_with_attributes)). It is difficult to say which options would be useful without knowing the problem.

Some ideas:

- You can always start with increasing the number of iterations - maybe ipopt just needs more iterations to find a solution.
- You can also look at detailed output from ipopt changing the print\_level option - maybe that would give some guidance. You could for instance look at what is happening to your objective - does it keep changing or does it get stuck somewhere?
- You can also start with giving ipopt a different initial guess ([Variables · JuMP](https://jump.dev/JuMP.jl/stable/reference/variables/#JuMP.set_start_value)) - in nonlinear optimisation a good starting point can help a lot.

At the same time - what do the changes do? Do you add more constraints? Are you sure that your problem has a solution after the changes are introduced?

---

<div class="post-metadata">

**Author:** ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)\
**Post date:** [November 27, 2021, 1:09pm UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/3 "2021-11-27T13:09:56Z")

</div>

Thanks for your attention  
The objective seems to be “oscillating” …

The changes turn a linear constraint into a nonlinear one , I also add a regularization term to the objective function to perform a feature selection .

Does Ipopt have different methods or something like that among the options ?

---

<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:** [November 27, 2021, 9:58pm UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/4 "2021-11-27T21:58:59Z")

</div>

> Does Ipopt have different methods or something like that among the options ?

Not really. Ipopt assumes problems are smooth and twice-differentiable. If your problem violates those assumptions things still generally work, but sometimes it won’t converge (try minimizing `abs(x)` starting at `x=1`, for example).

---

<div class="post-metadata">

**Author:** ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)\
**Post date:** [November 28, 2021, 5:08am UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/5 "2021-11-28T05:08:34Z")

</div>

Coincidentally your example is telling me what the problem is!  
The term which I add to my objective function contain `abs` …

Do you think changing the solver can help me?

I tried to use `MadNLP` :

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/6/56131cbe32a708ff7cef5bbf12a96b735f1eeed2.png)

Do we have gradient-based solvers for NLP in Julia ?

---

<div class="post-metadata">

**Author:** ![cvanaret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cvanaret/32/11594_2.png) [@cvanaret](https://discourse.julialang.org/u/cvanaret)\
**Post date:** [November 28, 2021, 11:51am UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/6 "2021-11-28T11:51:03Z")

</div>

You can reformulate your problem into a smooth problem.  
Replace \min\_{x, y} f(x) + |y| with \min\_{x, y, a} f(x) + a subject to a \ge y, a \ge -y.  
Keep Ipopt 😉

---

<div class="post-metadata">

**Author:** ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)\
**Post date:** [November 28, 2021, 12:37pm UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/7 "2021-11-28T12:37:42Z")

</div>

Thank you @cvanaret for your suggestion  
I’m not sure if I can implement that in my NLP as the term I’ve mentioned is L1 norm of a vector .

Actually I’m trying to perform feature selection with “lasso” method and the `abs` come from here.

---

<div class="post-metadata">

**Author:** ![cvanaret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cvanaret/32/11594_2.png) [@cvanaret](https://discourse.julialang.org/u/cvanaret)\
**Post date:** [November 28, 2021, 2:28pm UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/8 "2021-11-28T14:28:57Z")

</div>

Sure, that works too: use my suggestion componentwise on min\_{x,y} f(x) + ||y||\_1 = min\_{x,y} f(x) + \sum\_{i=1}^n |y\_i|.

---

<div class="post-metadata">

**Author:** ![FH96](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@FH96](https://discourse.julialang.org/u/FH96)\
**Post date:** [December 1, 2021, 12:28pm UTC](https://discourse.julialang.org/t/changing-ipopt-options/72156/9 "2021-12-01T12:28:37Z")

</div>

Thanks a lot @cvanaret😃 😃 😃 🙏
