parga-0.5.0.0: A parallel implementation of genetic algorithms.
This package provides both parallel and sequential implementations of genetic algorithms. It is still under development and a tutorial will be provided later.
The package offers two chromosome models:
- repsentation as lists of Double in AI.GA.Chromosome.List
- repsentation as unboxed vectors of Double in AI.GA.Chromosome.Unboxed
It also offers two population models:
- repsentation as lists of Double in AI.GA.Population.List
- repsentation as Repa arrays in AI.GA.Parallel
The list based implementations are intended primarily as educational. The implementation is documented in detail, using literate Haskell with LaTeX, to explain how the GA operates.
The recommended setup is two use unboxed vectors for the chromosomes and Repa arrays for the population. Operations on the Repa arrays are parallellised, taking advantage of multi-core machines.
At present only floating point genes are supported.
The first step to set up a GA is to define a cost function,
cost :: UChromosome -> Double assuming that the Unboxed
Vector chromosome model is used.
The second step is to choose crossover and mutation functions, and define the Chromosome Configuration A reasonable choice is to use
chromcfg = ChromosomeConfig crossoverHybrid (mutateReplace p)
where p is the mutation probability.
Then we need to make the GA configuration, like this
cfg = Config {
cConfig = chromcfg,
cost = cost,
keep = k,
elite = n
}
where n is the number of best chromosomes not subject to mutation
and k is the number of chromosomes to keep from one generation
to the next. The chromosomes kept are also the ones eligible to
breed. If k is zero, no chromosomes are preserved and every
chromosome is elligible to breed.
Now the solver can be run as follows
winner = solveParallel h cfg clen psize ngen
where h is a file handle for log output, clen is the
chromosome length, psize is the population size and
ngen is the number of generations to run.
Modules
- AI
- AI.ConfigConfiguration of GA and Chromosome Model
- AI.GASequential implementation of Genetic Algorithms
- AI.GA.ChromosomeClass definitions for the chromosome model
- AI.GA.Chromosome.FunctionsCrossover and Mutation Functions
- AI.GA.Chromosome.ListChromosome representation using lists
- AI.GA.Chromosome.UnboxedChromosome representation using unboxed vectors
- AI.GA.ParallelParallel implementation of Genetic Algorithms
- Population
- Test
- AI.GA.ChromosomeClass definitions for the chromosome model
- AI.RandomConvenience functions for pseudo-random numbers