genetic-rs
A small framework for managing genetic algorithms.
Features
First off, this crate comes with the builtin, genrand, crossover, knockout, and speciation features by default. If you want the simulation to be parallelized (which is most usecases), add the rayon feature. There are also some convenient macros with the derive feature.
Ecosystem
This framework was created with a high degree of modularity in mind, allowing other crates to contribute to the ecosystem. Here's a list of some good crates:
- neat - Handles complex reproduction and prediction logic for the NEAT algorithm, allowing you to create AI simulations with ease. It also functions as a pretty good example for the more complex usecases of the crate's traits.
- genetic-rs-extras - A companion crate with quality-of-life improvements and utility features.
If you have a genetic-rs-based crate and you'd like it to be featured here, submit a PR or discussion post and I'll consider it.
How to Use
Here's a simple genetic algorithm:
use *;
// `Mitosis` can be derived if both `Clone` and `RandomlyMutable` are present.
// required in all of the builtin Repopulators as requirements of `Mitosis` and `Crossover`
// allows us to use `Vec::gen_random` for the initial population. note that with the `rayon` feature, we can also use `Vec::par_gen_random`.
That is the minimal code for a working genetic algorithm with just the derive feature (+ defaults). You can read the docs or check the examples for more complicated systems. I highly recommend looking into crossover reproduction, as it tends to produce better results than mitosis.
License
This project falls under the MIT license.