# Default keyword arguments Optimization.jl

**URL:** https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271
**Category:** Optimization (Mathematical)
**Created:** [October 5, 2022, 5:33am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271 "2022-10-05T05:33:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [October 5, 2022, 5:33am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/1 "2022-10-05T05:33:44Z")

</div>

What are the default keyword arguments for `Optimization.solve` shown [here](https://optimization.sciml.ai/stable/API/solve/)?  
Can anyone point out to that code in Github?

---

<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: [October 8, 2022, 4:39am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/2 "2022-10-08T04:39:47Z")

</div>

Not an Optimization.jl developer, but I assume if not set, they default to the solver’s choice, so it will vary depending on the solver you choose.

---

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [October 8, 2022, 8:00am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/3 "2022-10-08T08:00:59Z")

</div>

I see. I think if `Optimization.jl` aims to be a consistent interface for numerical optimizers, perhaps it should provide the same default values for common parameters used by all back ends.

---

<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: [October 8, 2022, 8:48am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/4 "2022-10-08T08:48:02Z")

</div>

Different solvers implement different algorithms, so there isn’t one set of values would work by default for every solver.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 8, 2022, 9:02am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/5 "2022-10-08T09:02:30Z")

</div>

Arguments that have shared meaning get bubbled up to a higher level to be the common keyword arguments, such as with `maxiters` and tolerances. Those are then made to default similarly across the interface. However, arguments that are solver-specific are then defaulted specifically for the solvers. This of course is the same scheme throughout SciML. Optimization.jl is just orders of magnitude less developed than some other pieces, so it doesn’t have that many common args at this point.

---

<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: [October 8, 2022, 9:35am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/6 "2022-10-08T09:35:59Z")

</div>

I think the point was that two algorithms can both have a `maxiters` argument, but a common default value of `1000` doesn’t make sense.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 8, 2022, 9:55am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/7 "2022-10-08T09:55:45Z")

</div>

There is a sensible default, and that is to use a tolerance-based stopping criteria if the algorithm allows for it, or require `maxiters`. And that’s how the `maxiters` argument works.

---

<div class="post-metadata">

### Author: ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)
#### Post date: [October 8, 2022, 10:10am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/8 "2022-10-08T10:10:11Z")

</div>

So we can expect common defaults at some point in the future?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 8, 2022, 10:25am UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/9 "2022-10-08T10:25:22Z")

</div>

For anything that’s a common argument, yes. It’s an interface break if that’s the case.

---

<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: [October 8, 2022, 10:46pm UTC](https://discourse.julialang.org/t/default-keyword-arguments-optimization-jl/88271/10 "2022-10-08T22:46:55Z")

</div>

What is the mathematical definition of `abstol` and `reltol`? How do you set a reasonable common tolerance across solvers?

The only two common options that are (mostly) unambiguous across solvers are time limits and verbosity, which is why JuMP has `TimeLimitSec` and `Silent` as options. Even time limits have a number of non-trival differences in the implementation between solvers.
