stevengj / nlopt

library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
Other
1.89k stars 588 forks source link

Clarification on Modifying nlopt.opt Functionality #574

Closed adityab39 closed 2 hours ago

adityab39 commented 3 hours ago

Hello, I am currently working on a project where I am utilizing the nlopt library, specifically the nlopt.opt function, as follows: opt = nlopt.opt(nlopt.LD_MMA, int(ndof)) I understand that the source code for the nlopt library is written in C. I need to make modifications to the behavior of the nlopt.opt function to meet specific requirements for my project. Could you kindly guide me to the specific function or part of the source code in C that corresponds to the nlopt.opt function I am using? Your assistance in pinpointing the relevant file or function would be immensely helpful.

jschueller commented 2 hours ago

that would be the class opt from c++ file src/api/nlopt-in.hpp, from there it calls the different methods from nlopt.h C header

adityab39 commented 44 minutes ago

Thank you for the response. We want to set a few input hyper parameters to fine-tune the step size and momentum components in nloptoptimize in /src/api/optimize.c (refer to lr for learning rate and betas for momentum weights in https://pytorch.org/docs/stable/generated/torch.optim.Adam.html). Can you suggest how we might change the code to improve the optimization performance?

jschueller commented 31 minutes ago

you can look in the documentation for the different parameter accessors in nlopt and if they do not match your needs you can try to look for them in the code and mimic how they are implemented to add your new parameters