[R] Combinatorial Optimisation

Adrian Trapletti adrian.trapletti@lmttrading.com
Fri, 25 Oct 2002 09:46:21 +0200


> Date: Thu, 24 Oct 2002 08:58:08 +0200 (CEST)
> From: Detlef Steuer <Detlef.Steuer@unibw-hamburg.de>
> Subject: RE: [R] Combinatorial Optimisation
>
> This thread missed me somehow.
>
> If not mentioned before:
> simulated annealing is implemented in optim().

The current implementation of simulated annealing in optim() has been designed for a continuos parameter space. The next candidate
point in the parameter space is generated from a Gaussian Markov kernel with scale proportional to the actual temperature. However,
it is quite simple to change this for a combinatorial optimization:

in the R source tree, see the file src/main/optim.c, function samin:

What you need to change are the four lines, that are responsible for generating a new candidate point:

for (i = 0; i < n; i++)
  dp[i] = scale * t * norm_rand();  /* random perturbation */
for (i = 0; i < n; i++)
  ptry[i] = p[i] + dp[i];  /* new candidate point */

You could, e.g., replace them by a call to an R function, which randomly selects a new candidate point of a finite set of points.
Hence, to quickly get SA for combinatorial optimization:

Copy and paste samin from optim.c
Change the four lines
Write an R wrapper for this new function

best
Adrian

PS: TO R-DEVEL: What about having this behaviour in optim (default as is, optional a function argument which selects a candidate
point)?

--
Dr. Adrian Trapletti             Phone :             +41 (0) 1 994 5631
Trapletti Statistical Computing  Mobile:             +41 (0)76 370 5631
Wildsbergstrasse 31              Fax   :             +41 (0) 1 994 5631
CH-8610 Uster                    Email :  mailto:a.trapletti@bluewin.ch
Switzerland                      WWW   : http://trapletti.homelinux.com



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._