-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Genetic algorithm library
--
-- This package provides a framework for working with genetic algorithms.
-- A genetic algorithm is an evolutionary technique, inspired by
-- biological evolution, to evolve entities that perform as good as
-- possible in terms of a predefined criterion (the scoring function).
-- Note: lower scores are assumed to indicate better entities. The GA
-- module provides a type class for defining entities and the functions
-- that are required by the genetic algorithm. Checkpointing in between
-- generations is available, as is automatic restoring from the last
-- available checkpoint.
@package GA
@version 0.1
-- | GA, a Haskell library for working with genetic algoritms
--
-- Aug. 2011, by Kenneth Hoste
--
-- version: 0.1
module GA
-- | Type class for entities that represent a candidate solution.
--
-- Three parameters:
--
--
-- - data structure representing an entity (a)
-- - data used to score an entity, e.g. a list of numbers (b)
-- - some kind of pool used to generate random entities, e.g. a Hoogle
-- database (c)
--
class (Eq a, Read a, Show a, ShowEntity a) => Entity a b c | a -> b, a -> c
genRandom :: Entity a b c => c -> Int -> a
crossover :: Entity a b c => c -> Float -> Int -> a -> a -> Maybe a
mutation :: Entity a b c => c -> Float -> Int -> a -> Maybe a
score :: Entity a b c => a -> b -> Double
-- | Configuration for genetic algorithm.
data GAConfig
GAConfig :: Int -> Int -> Int -> Float -> Float -> Float -> Float -> Bool -> GAConfig
-- | population size
popSize :: GAConfig -> Int
-- | size of archive (best entities so far)
archiveSize :: GAConfig -> Int
-- | maximum number of generations to evolve
maxGenerations :: GAConfig -> Int
-- | fraction of entities generated by crossover (tip: >= 0.80)
crossoverRate :: GAConfig -> Float
-- | fraction of entities generated by mutation (tip: <= 0.20)
mutationRate :: GAConfig -> Float
-- | parameter for crossover (semantics depend on actual crossover
-- operator)
crossoverParam :: GAConfig -> Float
-- | parameter for mutation (semantics depend on actual mutation operator)
mutationParam :: GAConfig -> Float
-- | enable/disable built-in checkpointing mechanism
withCheckpointing :: GAConfig -> Bool
-- | Type class for pretty printing an entity instead of just using the
-- default show implementation.
class ShowEntity a
showEntity :: ShowEntity a => a -> String
-- | Do the evolution!
evolve :: Entity a b c => StdGen -> GAConfig -> c -> b -> IO a