Problem-definition function

Problem definition

Problem definition

Define a problem for ManifoldOptim to solve.

Details

A problem definition contains an objective function ff and a gradient function gg. The gradient gg is computed as if ff is defined on a Euclidean space. If gg is not specified it will be computed numerically, which is potentially much slower.

The easiest way to define a problem is completely in R. Example 1 below illustrates how to construct a problem using a given ff and gg. Example 2 constructs the same problem without providing gg. The Rcpp Module framework (Eddelbuettel, 2013) creates underlying C++ objects necessary to invoke the ROPTLIB library.

The performance of solving an RProblem may be too slow for some applications; here, the C++ optimizer calls R functions, which requires some overhead. A faster alternative is to code your problem in C++ directly, and allow it to be manipulated in R. An example is provided in this package, under tests/brockett/cpp_standalone/. Example 3 below shows how to instantiate this problem.

Package authors may want to use ManifoldOptim within a package to solve a problem written in C++. In this case, the author would probably not want to use sourceCpp, but instead have the problem compiled when the package was installed. An example is provided within this package; tests/brockett/cpp_pkg/driver.R instantiates the problem defined in:

src/ManifoldOptim/BrockettProblem.cpp.

Examples

## Not run: # --- Example 1: Define a problem in R --- f <- function(x) { ... } g <- function(x) { ... } mod <- Module("ManifoldOptim_module", PACKAGE = "ManifoldOptim") prob <- new(mod$RProblem, f, g) # --- Example 2: Define a problem in R without specifying gradient --- f <- function(x) { ... } mod <- Module("ManifoldOptim_module", PACKAGE = "ManifoldOptim") prob <- new(mod$RProblem, f) # --- Example 3: Instantiate a problem written in C++ --- p <- 5; n <- 150 B <- matrix(rnorm(n*n), nrow=n) B <- B + t(B) # force symmetric D <- diag(p:1, p) Rcpp::sourceCpp("brockett_problem.cpp") prob <- new(BrockettProblem, B, D) ## End(Not run)

References

Dirk Eddelbuettel. Seamless R and C++ Integration with Rcpp, Chapter 7: Modules, pages 83-102. Springer New York, New York, NY, 2013.

Wen Huang, P.A. Absil, K.A. Gallivan, Paul Hand (2016a). "ROPTLIB: an object-oriented C++ library for optimization on Riemannian manifolds." Technical Report FSU16-14, Florida State University.

S. Martin, A. Raim, W. Huang, and K. Adragni (2020). "ManifoldOptim: An R Interface to the ROPTLIB Library for Riemannian Manifold Optimization." Journal of Statistical Software, 93(1):1-32.

  • Maintainer: Sean R. Martin
  • License: GPL (>= 2)
  • Last published: 2021-12-15

Useful links