GA, a Haskell library for working with genetic algoritms
Aug. 2011, by Kenneth Hoste
version: 0.1
- class (Eq a, Read a, Show a, ShowEntity a) => Entity a b c | a -> b, a -> c where
- data GAConfig = GAConfig {}
- class ShowEntity a where
- showEntity :: a -> String
- evolve :: Entity a b c => StdGen -> GAConfig -> c -> b -> IO a
Documentation
class (Eq a, Read a, Show a, ShowEntity a) => Entity a b c | a -> b, a -> c whereSource
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)
genRandom :: c -> Int -> aSource
Generate a random entity.
crossover :: c -> Float -> Int -> a -> a -> Maybe aSource
Crossover operator: combine two entities into a new entity.
mutation :: c -> Float -> Int -> a -> Maybe aSource
Mutation operator: mutate an entity into a new entity.
score :: a -> b -> DoubleSource
Score an entity (lower is better).
Configuration for genetic algorithm.
GAConfig | |
|
class ShowEntity a whereSource
Type class for pretty printing an entity instead of just using the default show implementation.
showEntity :: a -> StringSource
Show an entity.