This is a loose Elixir port of the genetic algorithm shown by Daniel Shiffmann on his online tutorial.
Original project (Shakespeare)
Install a working Elixir environement.
Run iex -S mix
in the terminal (no sugar shell, sorry).
Query the genetic algorithm with Genetics.guess/3
.
guess/3
arguments are :
- enigma:
string
orcharlist
representing the targetted string to guess, defaults to the Shakespeare sentence (To be or not...) ; - population_size:
integer
representing the size of the population used by the algorithm, defaults to 500 ; - mutation_rate:
float
representing the probability of a mutation occuring after reproduction (0 <= n <= 1), defaults to 1%.
Currently not much of the code is documented. I've tried to do domain driven design (any feedback welcomed).
In iex
, you can run h Genetics.guess
.
The benchmark uses bmark.
Install it by entering mix deps.get
Customize your benchmark by either editing the file bmark/evolution_bmark.ex
or by adding a new file ending in _bmark.ex
in the bmark
directory.
Results appear in ms in the results
folder.