Skip to content

optim with gradient

4 messages · Adrian Trapletti, Göran Broström, Martin Maechler

#
If the only goal is to improve speed, then you should consider to do the full optimization within C/Fortran, i.e., to implement the errfunc and the gradient in C and to call optim through the API (a new feature of the upcoming version 1.5.0 as Brian told me). This may increase speed - I just make a rough guess now - by a factor 100.

best
Adrian


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 21 Mar 2002, Adrian Trapletti wrote:
[...]
I can hardly wait! I already make the heavy calculations in Fortran, so it 
should be easy to implement. Is the feature in R-devel now?
And documented?  

Thanks,

G?ran

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
GB> On Thu, 21 Mar 2002, Adrian Trapletti wrote: [...]
    >> If the only goal is to improve speed, then you should
    >> consider to do the full optimization within C/Fortran,
    >> i.e., to implement the errfunc and the gradient in C and
    >> to call optim through the API (a new feature of the
    >> upcoming version 1.5.0 as Brian told me). This may
    >> increase speed - I just make a rough guess now - by a
    >> factor 100.

    GB> I can hardly wait! I already make the heavy calculations
    GB> in Fortran, so it should be easy to implement. Is the
    GB> feature in R-devel now?  And documented?

2 x yes; 
actually for several weeks now  (thanks to Brian, of course).  

(Apart from the source code,) the documentation is in
the ``Writing Extensions for R'' Manual the latest R-devel
version of which is usually available from
	http://stat.ethz.ch/R-alpha/R-devel/doc/html/

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
G?ran Brostr?m wrote:

            
I am not sure what you mean by doing the heavy calculations in Fortran. But I

guess the errfunc (and gradient) are defined in R and itself call Fortran
code using .Fortran()? That?s already more performant, but also then you
should avoid that optim calls an R function. It completely "destroys" the
performance.
Yes.
I don?t know. Ask Brian. But I think it should be pretty easy to figure out
how to call optim and how optim calls your functions from the header file.

Adrian



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._