Movatterモバイル変換


[0]ホーム

URL:


Dirk Eddelbuettel

RcppNLoptExample: Rcpp example of usingNLopt vianloptr

Build StatusLicenseCRANDownloadsLast Commit

About

NLopt is a very comprehensive library for nonlinear optimization. Thenloptr package byJelmer Ypma has long been providing an excellent R package.

Starting with its 1.2.0 release, thenloptr package now exports its C symbols in a way that makes it accessible to other R packageswithout linking easing the installation across operating systems.

This package illustrates this with an example drawn from theNLopt tutorial.

Example

See the (currently single) filesrc/nlopt.cpp.

How / Why ?

R uses C interfaces. These C interfaces can be exportedbetween packages. So when the usuallibrary(nloptr) happens, we nowalso get a number of C functions registered.

And those are enough to run optimization from C++ as we simplyrely on the C interface provided. Look careful at the example code: the objective function and the constraint functions are C functions, and the body of our example invokes C functions fromNLopt.This just works.

On the other hand, if we tried to use theNLopt C++ interfacewhich brings with it someinterface code we would require linking to that code (which R cannot easily export across packages using its C interface). So C it is.

See Also

This repo builds on, extends, and simplifies an earlierrepo by Julien Chiquet to which I contributed a core part of this setup.

Author

Dirk Eddelbuettel

License

GPL (>= 2)

Initially created: Sat Oct 13 09:10:12 CDT 2018
Last modified: Sat May 30 08:26:36 CDT 2020


[8]ページ先頭

©2009-2025 Movatter.jp