Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iskandr/genepool
Framework for writing evolutionary optimization algorithms in OCaml
https://github.com/iskandr/genepool
Last synced: 2 months ago
JSON representation
Framework for writing evolutionary optimization algorithms in OCaml
- Host: GitHub
- URL: https://github.com/iskandr/genepool
- Owner: iskandr
- Created: 2011-05-08T01:21:16.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-09-19T21:11:49.000Z (over 11 years ago)
- Last Synced: 2023-03-11T07:47:04.258Z (almost 2 years ago)
- Language: OCaml
- Homepage: http://www.rubinsteyn.com/genepool/
- Size: 96.7 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GenePool is a framework for writing evolutionary optimization algorithms in OCaml. This library is not a complete solution but rather is a generic skeleton which takes care of the plumbing and nuisances of optimization. You provide GenePool with functions that give meaning to fitness and reproduction and after a specified number of generation, GenePool returns an array of the best "genomes" it evolved.
The interface to GenePool is extremely simple. It consists of a single function evolve whose type is:
```ocaml
('genome, 'fitness) ga_spec -> ga_params -> 'genome array * 'fitness
```
As you can tell from the signature, GenePool is polymorphic over both the representation of the genome and the type of fitness values. Typically your genome will be an array and fitness will be expressed as either an int or float. However, nothing stops you from using different types if your problem requires them.
The first parameter is a record (of type ga_spec) which encodes how evolution will proceed for your specific problem.```ocaml
(*
GA Specification
-----------------------------------------------------------------------
evaluate - assign a fitness to a genome
mutatate - given a genome, create an altered copy
crossover - given two genomes, combine them
genRandom - produce a random genome from scratch
seed - optional initial seed population
report - optional function to output information
about the best genome of each generation
stop - optional stopping predicate
*)type ('genome, 'fitness) ga_spec = {
evaluate : 'genome -> 'fitness;
mutate : 'genome -> 'genome;
crossover : 'genome * 'genome -> 'genome;
genRandom: unit -> 'genome;
seed: 'genome array option;
report: (int -> 'genome -> 'fitness -> unit) option;
stop: (int > 'genome -> 'fitness -> bool) option
}
```Some parameters (ie, the maximum number of generations, the number of genomes which survive each generations, etc...) are universal across all optimization algorithms. These are provided in another record, whose type is ga_params.
```ocaml
(*
GA Parameters
--------------------------------------------------------------------
nRandom - how many random genomes should we generate at the beginning
nSurvivors - how many genomes survive of each generation
nMutations - # genomes generated by asexual reproduction each generation
nCrossovers - # genomes by sexual reproduction each generation
timeLimit - seconds until algorithm termination
maxGen - maximum number of generations until algorithm termination
*)type ga_params = {
nRandom: int;
nSurvivors: int;
nMutations: int;
nCrossovers: int;
timeLimit:float;
maxGen: int
}```