pub struct Neat<T: Gene> { /* private fields */ }Expand description
Neat struct that takes care of evolving the population based on the fitness scores
Implementations§
Source§impl<T: Gene> Neat<T>
impl<T: Gene> Neat<T>
Sourcepub fn new(
inputs: usize,
outputs: usize,
size: usize,
mutation_rate: f64,
) -> Self
pub fn new( inputs: usize, outputs: usize, size: usize, mutation_rate: f64, ) -> Self
Creates a new population
Sourcepub fn calculate_fitness(
&self,
calculate: impl Fn(&T, bool) -> f64,
) -> (Vec<f64>, f64)
pub fn calculate_fitness( &self, calculate: impl Fn(&T, bool) -> f64, ) -> (Vec<f64>, f64)
Evaluates all the genomes based on the fitness function and returns all the scores and the total score
Sourcepub fn next_generation(&mut self, scores: &[f64], total_score: f64)
pub fn next_generation(&mut self, scores: &[f64], total_score: f64)
Takes care of speciation, selection and mutation and creates the new population
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Neat<T>
impl<T> RefUnwindSafe for Neat<T>where
T: RefUnwindSafe,
impl<T> Send for Neat<T>where
T: Send,
impl<T> Sync for Neat<T>where
T: Sync,
impl<T> Unpin for Neat<T>where
T: Unpin,
impl<T> UnwindSafe for Neat<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more