| Safe Haskell | None |
|---|
AI.GA.Population.List
Description
This module provides a simple implementation of
a Population using lists.
- type ListPop c = [c]
- solveIOL :: (MonadIO m, SplittableRandMonad g m, Chromosome c) => Chan (ListPop c) -> Config c (ListPop c) g -> Int -> Int -> Int -> m c
- solveListPop :: Chromosome c => Handle -> Config c (ListPop c) TFGen -> Int -> Int -> Int -> IO c
- augSort :: Ord b => [(a, b)] -> [(a, b)]
- rankWeight :: [(c, Double)] -> [(c, Double)]
- applyCrossover :: PopulationTypeX c p g m => p -> ReaderT (Config c p g) m p
- applyMutation :: PopulationTypeX c p g m => p -> ReaderT (Config c p g) m p
Documentation
type ListPop c = [c]
The population is simply a list of chromosomes.
The chromosome can be any instance of the Chromosome class.
Arguments
| :: (MonadIO m, SplittableRandMonad g m, Chromosome c) | |
| => Chan (ListPop c) | Channel for logging |
| -> Config c (ListPop c) g | Configuration of the GA |
| -> Int | Chromosome length |
| -> Int | Population size |
| -> Int | Number of generations |
| -> m c | Best chromosome |
The solveIO takes the configuration as an input parameter
and solves the GA to return the best chromosome.
This is simply a wrapper around the solveIOinner function.
Arguments
| :: Chromosome c | |
| => Handle | File handle for log output |
| -> Config c (ListPop c) TFGen | Configuration of the GA |
| -> Int | Chromosome length |
| -> Int | Population size |
| -> Int | Number of generations |
| -> IO c | Best chromosome |
The solveListPop function integrates does much of the
setup, including calling ioThread before calling solveIO.
Thus it is a simpler and more high-level alternative for the user.
It uses the TFGen pseudo-random generator, which is the only
known satisfactory alternative.
rankWeight :: [(c, Double)] -> [(c, Double)]
applyCrossover :: PopulationTypeX c p g m => p -> ReaderT (Config c p g) m p
applyMutation :: PopulationTypeX c p g m => p -> ReaderT (Config c p g) m p