Search code examples
rautomatic-differentiation

Optimization issue, Nonlinear: automatic analytical Jacobian/Hessian from objective and constraints in R?


In R, is it possible to find the Jacobian/Hessian/sparsity pattern analytically when you provide just the objective function and constraints for an optimization problem?

AMPL does this, and from what I hear even MATLAB can do this, but I don't know if you need Knitro for this.

However, all the optimization tools for R (such as nloptr) seem to require me to enter the gradient and Hessian myself, which is very difficult since I am working with a complex model.


Solution

  • What you are looking for is called automatic differentiation. Sadly, it looks like to me it is not available in R.

    There were attempts 5 years ago to implement it but my short investigation indicates that these attempts died out.

    There is a fairly recent R package (Automatic Differentiation Model Builder) but it is unclear to me how to use it, or how to apply this to your situation. (I don't use R myself, that's why I don't know.)