Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genetic-rs update #11

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ max-index = []


[dependencies]
genetic-rs = "0.2.1"
genetic-rs = "0.3"
rand = "0.8.5"
rayon = { version = "1.8.1", optional = true }
6 changes: 3 additions & 3 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl RandomlyMutable for AgentDNA {
impl Prunable for AgentDNA {}

impl DivisionReproduction for AgentDNA {
fn spawn_child(&self, rng: &mut impl Rng) -> Self {
fn divide(&self, rng: &mut impl Rng) -> Self {
let mut child = self.clone();
child.mutate(self.network.mutation_rate, rng);
child
Expand Down Expand Up @@ -112,7 +112,7 @@ fn main() {
sim.next_generation();
}

let fits: Vec<_> = sim.entities.iter().map(fitness).collect();
let fits: Vec<_> = sim.genomes.iter().map(fitness).collect();

let maxfit = fits
.iter()
Expand All @@ -130,7 +130,7 @@ fn main() {
sim.next_generation();
}

let fits: Vec<_> = sim.entities.iter().map(fitness).collect();
let fits: Vec<_> = sim.genomes.iter().map(fitness).collect();

let maxfit = fits
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<const I: usize, const O: usize> RandomlyMutable for NeuralNetworkTopology<I
}

impl<const I: usize, const O: usize> DivisionReproduction for NeuralNetworkTopology<I, O> {
fn spawn_child(&self, rng: &mut impl rand::Rng) -> Self {
fn divide(&self, rng: &mut impl rand::Rng) -> Self {
let mut child = self.clone();
child.mutate(self.mutation_rate, rng);
child
Expand All @@ -213,7 +213,7 @@ impl<const I: usize, const O: usize> DivisionReproduction for NeuralNetworkTopol

#[cfg(feature = "crossover")]
impl CrossoverReproduction for NeuralNetworkTopology {
fn spawn_child(&self, other: &Self, rng: &mut impl Rng) -> Self {
fn crossover(&self, other: &Self, rng: &mut impl Rng) -> Self {
todo!();
}
}
Expand Down