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

Parameterized optimization problem #386

Open
qsh-zh opened this issue Mar 28, 2021 · 1 comment
Open

Parameterized optimization problem #386

qsh-zh opened this issue Mar 28, 2021 · 1 comment

Comments

@qsh-zh
Copy link

qsh-zh commented Mar 28, 2021

I am new to the excellent library. I go through the manual and wonder what is the best practice for parameterized optimization problems?

As the example in tutorial. Different choice of the parameters a,b will result in difficult optimum. I need to implement a method whose input is the set of parameters and output is the optimum corresponding to those parameters.

The first idea that comes to my mind is instantiating nlopt.opt repeatedly. However, it seems very expensive. Is there a possibility that I create an instance of nlopt.opt once and get different optimums by call solver with different probelm parameters.

@kilasuelika
Copy link

I thought what you need is the extra parameter void * data such as

double myfunc(unsigned n, const double *x, double *grad, void *my_func_data)

The my_func_data is used to pass extra data. Then you can just loop over your parameter sets. You can use a fixed pointer. But each time you reset the address which the pointer stores. And rerun the solver to get results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants