I have a complex objective function I am looking to optimize. The optimization problem takes a considerable time to optimize. Fortunately, I do have the gradient and the hessian of the function available.
Is there an optimization package in R that can take all three of these inputs? The class 'optim' does not accept the Hessian. I have scanned the CRAN task page for optimization and nothing pops.
For what it's worth, I am able to perform the optimization in MATLAB using 'fminunc' with the the 'GradObj' and 'Hessian' arguments.
The function optim provides algorithms for general-purpose optimisations and the documentation is perfectly reasonable, but I remember that it took me a little while to get my head around how to pass data and parameters to optim.
nlminb() takes a function, objective, and finds values for the parameters of this function at which the objective function acheives its minimum value. Unlike optimize(), nlminb() can be used to optimize functions with mutiple arguments.
I think the package trust
which does trust region optimization will do the trick. From the documentation of trust
, you see that
This function carries out a minimization or maximization of a function using a trust region algorithm... (it accepts) an R function that computes value, gradient, and Hessian of the function to be minimized or maximized and returns them as a list with components value, gradient, and hessian.
In fact, I think it uses the same algorithm used by fminunc
.
By default
fminunc
chooses the large-scale algorithm if you supply the gradient in fun and set GradObj to 'on' using optimset. This algorithm is a subspace trust-region method and is based on the interior-reflective Newton method described in [2] and [3]. Each iteration involves the approximate solution of a large linear system using the method of preconditioned conjugate gradients (PCG). See Large Scale fminunc Algorithm, Trust-Region Methods for Nonlinear Minimization and Preconditioned Conjugate Gradient Method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With