astamm / nloptr

nloptr provides an R interface to NLopt, a free/open-source library for nonlinear optimization providing a common interface to a number of different optimization routines which can handle nonlinear constraints and lower and upper bounds for the controls.
https://astamm.github.io/nloptr/
Other
103 stars 36 forks source link

Add functions for setting parameter bounds #145

Closed mkbwang closed 9 months ago

mkbwang commented 9 months ago

Hello, I want to use the nlopt_set_lower_bound and nlopt_set_lower_bounds1 function for setting parameter bounds according to the NLOPT references. Unfortunately the src/nlopt.c seem to be outdated and only contains nlopt_set_lower_bounds. Can you update the C library? FYI, I am developing an R package, and my Rcpp codes rely on the C library imported from your package (see this example)

jyypma commented 9 months ago

I'm not sure what you're trying to accomplish and what doesn't work, but given that you're mentioning the Rcpp example, I'm guessing that you want to call NLopt functions from cpp code. The function nlopt_set_lower_bounds1 is exported from inst/include/nloptrAPI.h, so you should be able to call the function from your cpp code.

mkbwang commented 9 months ago

Thanks for letting me know! I wasn't able to use the nlopt_set_lower_bound API which sets the bound of one parameter given an index. Never mind, I can get around this with the other two functions that you provide.