[R] Simulated annealing using optim()

otalora at ugr.es otalora at ugr.es
Fri Apr 13 11:56:21 CEST 2007


I'm preparing some code to compute the optimal geometry of stressed
solids. The core of the calculations is the optimization of elastic energy
using the simulated annealing method implemented in the R optim() rutine.
I've defined a function to compute this "energy" scalar (the fn parameter
for optim) and prepared a list with the arrays defining the geometry and
the elastic properties of the solid (par parameter to optim).

Finally, I tried to write my "gr" function to compute new random test
configurations. Here I found a problem: In the simulated annealing
algorithm, changes between succesive iterations during the optimization
must be progressively smaller. The "distance" from the "current"
configuration to the next one to be tested must be somehow proportional to
the "temperature" but I don't see how to acces the value of the
"temperature" from my gr function. Unfortunately, this is not described in
the help page and the examples shown don't need a gr function (in the case
of the "wild" function example) or uses an "temperature" independent
function (in the case of the Traveling salesman problem example).

I had a look at the C source code for optim(), and I confirmed that the
shrinking "temperature" is used by the default Gaussian Markov kernel
(under the name "scale") but I didn't found any clue on how to access this
value from the user defined gr function (probably because of my lack of
knowledge of the R API).

Any idea?

Thanks

                                                         Fermin


 _____                   _         +---------------------------------+
|  ___|__ _ __ _ __ ___ (_)_ __    |    Laboratorio de Estudios      |
| |_ / _ \ '__| '_ ` _ \| | '_ \   |       Cristalográficos          |
|  _|  __/ |  | | | | | | | | | |  +---------------------------------+
|_|  \___|_|  |_| |_| |_|_|_| |_|  | IPBLN, Av. del Conocimiento s/n |
                                   | Campus de la Salud,             |
  ___  _        _                  | 18100 Armilla, Granada, Spain   |
 / _ \| |_ __ _| | ___  _ __ __ _  |                                 |
| | | | __/ _` | |/ _ \| '__/ _` | | Phone: +34 958 181 643          |
| |_| | || (_| | | (_) | | | (_| | | Fax:   +34 958 181 632          |
 \___/ \__\__,_|_|\___/|_|  \__,_| | email: otalora at lec.csic.es      |
                                   +---------------------------------+



More information about the R-help mailing list