A genetic algorithm implementation in Rust.
rustup
https://rustup.rs/Cargo.toml
file from: https://crates.io/crates/watchmakerGenetic
trait for your search problem:
rust
pub trait Genetic<G> {
fn initialize(&mut self) -> G;
fn evaluate(&mut self, genome: &G) -> f64;
fn crossover(&mut self, lhs: &G, rhs: &G) -> G;
fn mutate(&mut self, original: &G) -> G;
}
Example:
```rusttype MyGenome = String;
pub struct MySearchProblem { random: Random, }
impl MySearchProblem { pub fn new(random: Random) -> Self { Self { random } } }
impl Genetic
fn evaluate(&mut self, genome: &MyGenome) -> f64 {
unimplemented!();
}
fn crossover(&mut self, lhs: &MyGenome, rhs: &MyGenome) -> MyGenome {
unimplemented!();
}
fn mutate(&mut self, original: &MyGenome) -> MyGenome {
unimplemented!();
}
}
See `WSGenome` and `WSGenetic` for a fully implemented, working example that finds a target string.
* Call the `solver` method:
rust
pub fn search
cargo test
or cargo build
See the examples
folder.
Note major version increment with each major release. API changes will not be backwards compatible between major releases.
[ ] v3.x.x
Fourth published version
Will take contributions, bug fixes from this point on.
[ ] v2.x.x
Third published version (beta quality)
Unsupported
[ ] v1.x.x
Second published version (beta quality)
Unsupported
[x] v0.1.0
First published version (beta quality)
Not accepting pull requests yet :) See roadmap.
MIT permissive license. See LICENSE for full license details.