# Optimization taking too long

**URL:** <https://discourse.julialang.org/t/optimization-taking-too-long/91159>\
**Category:** Optimization (Mathematical)\
**Tags:** ipopt\
**Created:** [December 2, 2022, 9:25pm UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159 "2022-12-02T21:25:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mb96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mb96/32/45786_2.png) [@mb96](https://discourse.julialang.org/u/mb96)\
**Post date:** [December 2, 2022, 9:25pm UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/1 "2022-12-02T21:25:27Z")

</div>

Hi everyone,

I am solving an optimization problem with a lot of variables through JuMP with Ipopt solver. The convergence time is extremely sensitive to one of my constraints:

for example if I use a linear functional form in that constraint the convergence takes place in 3 seconds  
if I use a square root functional form it takes 260 seconds

Does anyone have any experience with other solvers that might improve convergence time with functions like square root?

Any help would be very much appreciated!  
Thanks,  
Miguel.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 2, 2022, 9:54pm UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/2 "2022-12-02T21:54:10Z")

</div>

> [@mb96](#):
>
> for example if I use a linear functional form in that constraint the convergence takes place in 3 seconds  
> if I use a square root functional form it takes 260 seconds

The derivative of a square root blows up; in general you want to do optimization on functions whose first and second derivatives are bounded (otherwise convergence may be very slow or fail completely, depending on the algorithm and the problem).

---

<div class="post-metadata">

**Author:** ![mb96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mb96/32/45786_2.png) [@mb96](https://discourse.julialang.org/u/mb96)\
**Post date:** [December 2, 2022, 11:51pm UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/3 "2022-12-02T23:51:18Z")

</div>

Thanks for the answer but I also use the following function:

e^(a+bx)/(1+e^(a+bx))

in which case its first and second derivative does not blow up and it is equally slow so I am guessing that the non linearity is slowing it down for other reason. Maybe someone has had experience with non linear solver which had proven to be fast for them.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 3, 2022, 12:02am UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/4 "2022-12-03T00:02:24Z")

</div>

We need more details to say anything sensible. How many dimensions? What kind of constraints? Smooth? How are you computing derivatives? How expensive is the objective function to evaluate?

---

<div class="post-metadata">

**Author:** ![mb96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mb96/32/45786_2.png) [@mb96](https://discourse.julialang.org/u/mb96)\
**Post date:** [December 3, 2022, 1:30am UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/5 "2022-12-03T01:30:08Z")

</div>

I understand the information is vague. My question is whether people have a common prior on what solvers in Julia generally work better with these kind on non-linear constraints.

---

<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:** [December 3, 2022, 3:00am UTC](https://discourse.julialang.org/t/optimization-taking-too-long/91159/6 "2022-12-03T03:00:27Z")

</div>

> [@mb96](#):
>
> I understand the information is vague

It’s hard to offer advice without a reproducible example. Too often, the answer is “it depends.”
