hgalib-0.1: Haskell Genetic Algorithm LibrarySource codeContentsIndex
GA
Description
Genetic Algorithms
Synopsis
data Config c p = Config {
cConfig :: ChromosomeConfig c p
pConfig :: PopulationConfig c p
newPopulation :: p -> GAState c p p
maxFitness :: Maybe Double
maxGeneration :: Maybe Int
currentGeneration :: Int
gen :: StdGen
}
data PopulationConfig c p = PopulationConfig {
bestChromosomePop :: p -> GAState c p c
roulettePop :: p -> GAState c p p
tournamentPop :: p -> GAState c p p
applyCrossoverPop :: p -> GAState c p p
applyMutationPop :: p -> GAState c p p
}
data ChromosomeConfig c p = ChromosomeConfig {
fitness :: c -> Double
mutate :: c -> GAState c p c
cross :: c -> c -> GAState c p (c, c)
}
defaultConfig :: Config c p
type GAState c p = State (Config c p)
bestChromosome :: p -> GAState c p c
gaRand :: Random a => (a, a) -> GAState c p a
run :: p -> GAState c p p
rouletteM :: p -> GAState c p p
mutateM :: p -> GAState c p p
crossM :: p -> GAState c p p
tournamentM :: p -> GAState c p p
isDone :: p -> GAState c p Bool
Documentation
data Config c p Source
Constructors
Config
cConfig :: ChromosomeConfig c pThe config for the chromosome model
pConfig :: PopulationConfig c pThe config for the population model
newPopulation :: p -> GAState c p pThe function that transforms a population into the next generation
maxFitness :: Maybe DoubleThe fitness at which to stop the GA
maxGeneration :: Maybe IntThe generation at which to stop the GA
currentGeneration :: IntThe number of generations elapsed. defaultConfig sets this to 0
gen :: StdGenThe random number generator
data PopulationConfig c p Source
Constructors
PopulationConfig
bestChromosomePop :: p -> GAState c p c
roulettePop :: p -> GAState c p p
tournamentPop :: p -> GAState c p p
applyCrossoverPop :: p -> GAState c p p
applyMutationPop :: p -> GAState c p p
data ChromosomeConfig c p Source
Constructors
ChromosomeConfig
fitness :: c -> DoubleThe fitness function for the chromosome model
mutate :: c -> GAState c p cThe mutation operator for the chromosome model
cross :: c -> c -> GAState c p (c, c)The crossover operator for the chromosome model
defaultConfig :: Config c pSource
defaultConfig acts as a blank slate for genetic algorithms. cConfig, pConfig, gen, and maxFitness or maxGeneration must be defined
type GAState c p = State (Config c p)Source
bestChromosome :: p -> GAState c p cSource
Wrapper function which returns the best chromosome of a population
gaRand :: Random a => (a, a) -> GAState c p aSource
Generates a random number which updating the random number generator for the config
run :: p -> GAState c p pSource
Runs the specified GA config until the termination condition is reached
rouletteM :: p -> GAState c p pSource
A wrapper function for use in newPopulation for roulette selection
mutateM :: p -> GAState c p pSource
A wrapper function for use in newPopulation for mutating the population
crossM :: p -> GAState c p pSource
A wrapper function for use in newPopulation for applying crossover to the population
tournamentM :: p -> GAState c p pSource
A wrapper function for use in newPopulation for tournament selection
isDone :: p -> GAState c p BoolSource
Returns true if the given population satisfies the termination condition for the GA config
Produced by Haddock version 2.4.2