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

The General Reference of NLopt here 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?

You can use set_optimizer_attribute

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

See GitHub - JuliaOpt/NLopt.jl: Package to call the NLopt nonlinear-optimization library from the Julia language

2 Likes

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.

2 Likes

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.

Just search the algorithms reference 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.

2 Likes

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

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