Struct Simulation

Source
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>

Source

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).

Source

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

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V