From clausen at econ.upenn.edu  Sat Aug  4 16:02:20 2007
From: clausen at econ.upenn.edu (Andrew Clausen)
Date: Sat, 4 Aug 2007 10:02:20 -0400
Subject: [Rd] Optimization in R
In-Reply-To: <46B4400D.6000908@pburns.seanet.com>
References: <20070804051231.GB3016@econ.upenn.edu>
	<46B4400D.6000908@pburns.seanet.com>
Message-ID: <20070804140220.GB16431@econ.upenn.edu>

Hi Pat,

On Sat, Aug 04, 2007 at 09:59:57AM +0100, Patrick Burns wrote:
> Sounds like a good project.

Thanks :)

> How much extra overhead are you getting from the
> algorithm being in R?

On the Rosenbrock function (which is very quick to evaluate), here are the
system.time() results:

> system.time(bfgs(x0, f, g))
[1] 0.148 0.000 0.149 0.000 0.000
> system.time(optim(x0, f, g, method="BFGS"))
[1] 0.008 0.000 0.008 0.000 0.000

and the function evaluation counts:

> bfgs(x0, f, g)$counts
function gradient 
      95       58 
> optim(x0, f, g, method="BFGS")$counts
function gradient 
     318      100 

So the overhead is clearly much bigger, but still too small to matter for
most (?) applications.

Cheers,
Andrew

PS, my computer is a "Intel(R) Pentium(R) 4 CPU 2.80GHz" with a
1024 KB cache, according to /proc/cpuinfo.



[Rd] Optimization in R
Andrew Clausen