genetic-rs
A small crate for quickstarting genetic algorithm projects.
How to Use
note: if you are interested in implementing NEAT with this, try out the neat crate
Features
First off, this crate comes with the builtin
and genrand
features by default. If you want to add the builtin crossover reproduction extension, you can do so by adding the crossover
feature. If you want it to be parallelized, you can add the rayon
feature. If you want your crossover to be speciated, you can add the speciation
feature.
Once you have eveything imported as you wish, you can define your genome and impl the required traits:
// clone is currently a required derive for pruning nextgens.
// required in all of the builtin functions as requirements of `DivsionReproduction` and `CrossoverReproduction`
// required for `division_pruning_nextgen`.
// required for the builtin pruning algorithms.
// helper trait that allows us to use `Vec::gen_random` for the initial population.
Once you have a struct, you must create your fitness function:
Once you have your reward function, you can create a GeneticSim
object to manage and control the evolutionary steps:
That is the minimal code for a working pruning-based genetic algorithm. You can read the docs or check the examples for more complicated systems.
License
This project falls under the MIT
license.