# How to specify algorithm-specific parameters in NLopt.jl?

**URL:** https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765
**Category:** Optimization (Mathematical)
**Created:** [September 25, 2021, 11:52pm UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765 "2021-09-25T23:52:06Z")
**Posts on this page:** 8
**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: [September 25, 2021, 11:52pm UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/1 "2021-09-25T23:52:07Z")

</div>

The General Reference of NLopt [here](https://nlopt.readthedocs.io/en/latest/NLopt_Reference/#algorithm-specific-parameters) describes how to specify algorithm-specific parameters, but the `NLopt.jl` documentation does not have that section. Is it possible to access those parameters from `NLopt.jl`?

---

<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: [September 26, 2021, 11:13am UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/2 "2021-09-26T11:13:26Z")

</div>

You can use `set_optimizer_attribute`

```julia
using JuMP
model = Model(NLopt.Optimizer)
set_optimizer_attribute(model, "algorithm", :LD_MMA)

```

See [https://github.com/JuliaOpt/NLopt.jl#tutorial](https://github.com/JuliaOpt/NLopt.jl#tutorial)

---

<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: [September 26, 2021, 11:18am UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/3 "2021-09-26T11:18:24Z")

</div>

Can it be done without `JuMP`?

---

<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: [September 26, 2021, 12:12pm UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/4 "2021-09-26T12:12:38Z")

</div>

> [@amrods](#):
>
> Can it be done without `JuMP` ?

Yes, there is an `opt.params` property that acts like a dictionary of algorithm attributes, e.g. `opt.params["verbosity"] = 0` as in [this example](https://github.com/JuliaOpt/NLopt.jl/blob/master/test/tutorial.jl).

---

<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: [September 26, 2021, 9:38pm UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/5 "2021-09-26T21:38:45Z")

</div>

Is there a way to look at all configurable parameters (I suppose I can look at the references)? or perhaps it would be useful to have that object already loaded with the default values.

---

<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: [September 27, 2021, 12:33am UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/6 "2021-09-27T00:33:13Z")

</div>

Just search [the algorithms reference](https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/) for `nlopt_set_param`. Currently most algorithms don’t have settable parameters — this feature was only recently added, basically because I needed more control over the CCSA algorithm for one of my projects.

---

<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: [September 27, 2021, 12:54am UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/7 "2021-09-27T00:54:27Z")

</div>

Great! Not to push, but do you have plans to allow for settable parameters for other algorithms?

---

<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: [September 27, 2021, 1:44am UTC](https://discourse.julialang.org/t/how-to-specify-algorithm-specific-parameters-in-nlopt-jl/68765/8 "2021-09-27T01:44:47Z")

</div>

No immediate plans, but a PR would be welcome if there is some parameter you think would be useful to make accessible.
