pub struct Simulation<'a, T: SimulatingWorld> { /* private fields */ }
Expand description
Main struct that handles the learning logic.
Implementations§
Source§impl<'a, T: SimulatingWorld> Simulation<'a, T>
impl<'a, T: SimulatingWorld> Simulation<'a, T>
Sourcepub fn new(
population_size: usize,
neurons_per_layer: &[usize],
randomizer: &'a mut dyn RandomProvider,
mutation_probability: Option<f64>,
) -> Result<Simulation<'a, T>, String>
pub fn new( population_size: usize, neurons_per_layer: &[usize], randomizer: &'a mut dyn RandomProvider, mutation_probability: Option<f64>, ) -> Result<Simulation<'a, T>, String>
Creates new simulation struct.
mutation_probability
is represented as float number from range [0.0, 1.0)
.
Sourcepub fn run_with_parents(
&mut self,
finish: Finish,
parents: [Specimen; 2],
) -> Result<[Specimen; 2], String>
pub fn run_with_parents( &mut self, finish: Finish, parents: [Specimen; 2], ) -> Result<[Specimen; 2], String>
Runs the learning round by using the specified specimen as parents for new generation.
Use this function if you already have some trained networks (represented
by Specimen
) and would like to use them as a base
for further learning
Sourcepub fn run(&mut self, finish: Finish) -> Result<[Specimen; 2], String>
pub fn run(&mut self, finish: Finish) -> Result<[Specimen; 2], String>
Runs the learning round.
Returns two best specimen from the most recent generation. These specimen
might be used to resume training by using run_with_parents
.
Sourcepub fn get_number_of_iterations(&self) -> usize
pub fn get_number_of_iterations(&self) -> usize
Returns number of iterations used in recent learning session.
Auto Trait Implementations§
impl<'a, T> Freeze for Simulation<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for Simulation<'a, T>
impl<'a, T> !Send for Simulation<'a, T>
impl<'a, T> !Sync for Simulation<'a, T>
impl<'a, T> Unpin for Simulation<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for Simulation<'a, T>
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