hmatrix-gsl-0.19.0.1: Numerical computation

Copyright | (c) Matthew Peddie 2015
License | GPL
Maintainer | Alberto Ruiz
Stability | provisional
Safe Haskell | None
Language | Haskell2010

Numeric.GSL.SimulatedAnnealing

Contents

- Searching for minima
- Configuring the annealing process

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

- simanSolve :: Int -> Int -> SimulatedAnnealingParams -> a -> (a -> Double) -> (a -> a -> Double) -> (Vector Double -> Double -> a -> a) -> Maybe (a -> String) -> a
- data SimulatedAnnealingParams = SimulatedAnnealingParams {
  - n_tries :: CInt
  - iters_fixed_T :: CInt
  - step_size :: Double
  - boltzmann_k :: Double
  - cooling_t_initial :: Double
  - cooling_mu_t :: Double
  - cooling_t_min :: Double
  }

# Searching for minima

simanSolve Source #

Arguments

:: Int | Seed for the random number generator
-> Int | `nrand`, the number of random `Double`s 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

- n_tries :: CInt

  The number of points to try for each step.

- iters_fixed_T :: CInt

  The number of iterations at each temperature

- step_size :: Double

  The maximum step size in the random walk

- boltzmann_k :: Double

  Boltzmann distribution parameter

- cooling_t_initial :: Double

  Initial temperature

- cooling_mu_t :: Double

  Cooling rate parameter

- cooling_t_min :: Double

  Final temperature

#### Instances

Instances details

Storable SimulatedAnnealingParams Source # |

Instance details

Defined in Numeric.GSL.SimulatedAnnealing

Methods

sizeOf :: SimulatedAnnealingParams -> Int Source #

alignment :: SimulatedAnnealingParams -> Int Source #

peekElemOff :: Ptr SimulatedAnnealingParams -> Int -> IO SimulatedAnnealingParams Source #

pokeElemOff :: Ptr SimulatedAnnealingParams -> Int -> SimulatedAnnealingParams -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO SimulatedAnnealingParams Source #

pokeByteOff :: Ptr b -> Int -> SimulatedAnnealingParams -> IO () Source #

peek :: Ptr SimulatedAnnealingParams -> IO SimulatedAnnealingParams Source #

poke :: Ptr SimulatedAnnealingParams -> SimulatedAnnealingParams -> IO () Source #

Read SimulatedAnnealingParams Source # |
Instance details Defined in Numeric.GSL.SimulatedAnnealing Methods readsPrec :: Int -> ReadS SimulatedAnnealingParams Source # readList :: ReadS [SimulatedAnnealingParams] Source # readPrec :: ReadPrec SimulatedAnnealingParams Source # readListPrec :: ReadPrec [SimulatedAnnealingParams] Source #
Show SimulatedAnnealingParams Source # |
Instance details Defined in Numeric.GSL.SimulatedAnnealing Methods showsPrec :: Int -> SimulatedAnnealingParams -> ShowS Source # show :: SimulatedAnnealingParams -> String Source # showList :: [SimulatedAnnealingParams] -> ShowS Source #
Eq SimulatedAnnealingParams Source # |
Instance details Defined in Numeric.GSL.SimulatedAnnealing Methods (==) :: SimulatedAnnealingParams -> SimulatedAnnealingParams -> Bool Source # (/=) :: SimulatedAnnealingParams -> SimulatedAnnealingParams -> Bool Source #