hmatrix-gsl-0.18.2.0: Numerical computation

Copyright(c) Matthew Peddie 2015
LicenseGPL
MaintainerAlberto Ruiz
Stabilityprovisional
Safe HaskellNone
LanguageHaskell98

Numeric.GSL.SimulatedAnnealing

Contents

Description

Simulated annealing routines.

https://www.gnu.org/software/gsl/manual/html_node/Simulated-Annealing.html#Simulated-Annealing

Here is a translation of the simple example given in the GSL manual:

import Numeric.GSL.SimulatedAnnealing
import Numeric.LinearAlgebra.HMatrix

main = print $ simanSolve 0 1 exampleParams 15.5 exampleE exampleM exampleS (Just show)

exampleParams = SimulatedAnnealingParams 200 1000 1.0 1.0 0.008 1.003 2.0e-6

exampleE x = exp (-(x - 1)**2) * sin (8 * x)

exampleM x y = abs $ x - y

exampleS rands stepSize current = (rands ! 0) * 2 * stepSize - stepSize + current

The manual states:

    The first example, in one dimensional Cartesian space, sets up an
    energy function which is a damped sine wave; this has many local
    minima, but only one global minimum, somewhere between 1.0 and
    1.5. The initial guess given is 15.5, which is several local minima
    away from the global minimum.

This global minimum is around 1.36.

Synopsis

Searching for minima

simanSolve Source #

Arguments

:: Int

Seed for the random number generator

-> Int

nrand, the number of random Doubles the step function requires

-> SimulatedAnnealingParams

Parameters to configure the solver

-> a

Initial configuration x0

-> (a -> Double)

Energy functional e

-> (a -> a -> Double)

Metric definition m

-> (Vector Double -> Double -> a -> a)

Stepping function step

-> Maybe (a -> String)

Optional printing function

-> a

Best configuration the solver has found

Calling

simanSolve seed nrand params x0 e m step print

performs a simulated annealing search through a given space. So that any configuration type may be used, the space is specified by providing the functions e (the energy functional) and m (the metric definition). x0 is the initial configuration of the system. The simulated annealing steps are generated using the user-provided function step, which should randomly construct a new system configuration.

If Nothing is passed instead of a printing function, no incremental output will be generated. Otherwise, the GSL-formatted output, including the configuration description the user function generates, will be printed to stdout.

Each time the step function is called, it is supplied with a random vector containing nrand Double values, uniformly distributed in [0, 1). It should use these values to generate its new configuration.

Configuring the annealing process

data SimulatedAnnealingParams Source #

SimulatedAnnealingParams is a translation of the gsl_siman_params_t structure documented in the GSL manual, which controls the simulated annealing algorithm.

The annealing process is parameterized by the Boltzmann distribution and the cooling schedule. For more details, see the relevant section of the manual.

Constructors

SimulatedAnnealingParams 

Fields