| Stability | experimental |
|---|---|
| Maintainer | georg@schaathun.net |
| Safe Haskell | None |
AI.GA.Chromosome.Functions
Description
This module provides crossover and mutation functions.
- class Gene d where
- randomGene :: RandMonad m => m d
- class (Chromosome c, Gene d) => ChromosomeGene c d | c -> d where
- mapGeneM :: Monad m => (d -> m d) -> c -> m c
- crossoverMap :: RandMonad m => (d -> d -> m (d, d)) -> c -> c -> m (c, c)
- crossoverScattered :: RandMonad m => c -> c -> m (c, c)
- mutateReplace :: RandMonad m => Double -> c -> m c
- class (ContinuousGene d, ChromosomeGene c d) => ContinuousChromosomeGene c d | c -> d where
- mutateNoise :: RandMonad m => Double -> d -> c -> m c
Documentation
class Gene d where
A Gene is an element of a chromosome.
We need a function to generate a random Gene.
Methods
randomGene :: RandMonad m => m d
class (Chromosome c, Gene d) => ChromosomeGene c d | c -> d where
ChromosomeGene extends Chromosome with further
methods which have to be parameterised on the gene type.
This is used only in the definition and configuration of
crossover and mutation.
Methods
mapGeneM :: Monad m => (d -> m d) -> c -> m c
The mapGeneM function maps a monadic function on each gene.
crossoverMap :: RandMonad m => (d -> d -> m (d, d)) -> c -> c -> m (c, c)
The crossoverMap function does crossover by applying
a random function to each gene pair in a pair of chromosomes.
This is used by the crossoverScattered function.
crossoverScattered :: RandMonad m => c -> c -> m (c, c)
Scattered crossover function. This is the default crossover function in Matlab.
mutateReplace :: RandMonad m => Double -> c -> m c
The mutateReplace function replaces mutated genes with a random
value, independently of the original gene value.
class (ContinuousGene d, ChromosomeGene c d) => ContinuousChromosomeGene c d | c -> d where
Methods
Arguments
| :: RandMonad m | |
| => Double | Mutation probability |
| -> d | Maximum absolute value of noise |
| -> c | Chromosome |
| -> m c | Mutated chromosome in a monad |
Several mutation operations are possible.
The mutateNoise function mutates by adding uniformly
distributed random noise.