Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

algorithm-specific parameters structure empty #201

Closed
gvnwst opened this issue Jul 19, 2023 · 2 comments
Closed

algorithm-specific parameters structure empty #201

gvnwst opened this issue Jul 19, 2023 · 2 comments

Comments

@gvnwst
Copy link

gvnwst commented Jul 19, 2023

When defining an Opt object using, for example, the MMA algorithm the parameters structure is empty. I would think the correct behavior is to populate with the default values for each parameter available to that algorithm.

using NLopt 
opt = Opt(:LD_MMA, 10)
opt.params

> NLopt.OptParams()

Additionally querying for example haskey(opt.params, "inner_maxeval") returns false. Since this calls the C function nlopt_has_param I'd expect it to return true because the MMA algorithm supports the inner_maxeval parameter (according to the relevant PR). I can imagine this is extra confusing without knowing the available parameters ahead of time. Is there a list of internal parameters for each algorithm? I didn't see it in the NLopt generic documentation.

Setting some value with setindex!(opt.params, <value>, <parameter name>) works and populates the dict, but allows any string as a parameter name -- not just those which would be allowed by that algorithm.

Related to this, what is the purpose for requiring a default value to be passed to get()? I find it confusing that the "default value" passed as an argument is returned. How can you use that function to query the current value?

@stevengj
Copy link
Collaborator

stevengj commented Jul 19, 2023

NLopt doesn't currently export a global list of the algorithms and any parameters that they allow and their defaults. The only way to check optional parameters for a given algorithm is currently to look up that algorithm in the NLopt manual.

So this would need to be changed in the underlying C library first.

(get allows a default value in order to conform to the generic AbstractDict interface.)

@odow
Copy link
Member

odow commented Aug 19, 2024

Closing because this isn't possible to achieve in NLopt.jl. We can revisit if a future version of NLopt supports this.

It will also work by default if the C library starts reporting nlopt_has_param as true for the default parameters, so we probably don't even need to do anything here.

@odow odow closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants