Struct Simulation

Source
pub struct Simulation<T: Individual + Send + Sync> {
    pub type_of_simulation: SimulationType,
    pub num_of_threads: usize,
    pub habitat: Vec<Population<T>>,
    pub total_time_in_ms: f64,
    pub simulation_result: SimulationResult<T>,
    pub share_fittest: bool,
    pub num_of_global_fittest: usize,
    pub output_every: u32,
    pub output_every_counter: u32,
    pub share_every: u32,
    pub share_counter: u32,
}
Expand description

The Simulation type. Contains all the information / configuration for the simulation to run. Use the SimulationBuilder in order to create a simulation.

Fields§

§type_of_simulation: SimulationType

How should the simulation stop ?

§num_of_threads: usize

The number of threads to use to speed up calculation.

§habitat: Vec<Population<T>>

All the populations for the simulation. Contains all individuals for the simulation.

§total_time_in_ms: f64

The total run time for the simulation. This will be calculated once the stimulation has finished.

§simulation_result: SimulationResult<T>

The result of the simulation: improvement_factor, original_fitness and a vector of fittest individuals.

§share_fittest: bool

If this feature is enabled, then the most fittest individual of all populations is shared between all the populations.

§num_of_global_fittest: usize

The total number of global fittest individual to keep, default: 10 After each interation the most fittest individual of all populations is determinded. And this individual is copied into a global “high score list” of the whole simulation, if it is better then the highest entry. This number specifies how many of these global individuals should be kept. (i.e. the size of the “high score list”)

§output_every: u32

Do not output every time a new fittest individual is found, only every nth times. n == output_every

§output_every_counter: u32

Counter that will be incremented every iteration. If output_every_counter > output_every then the new fittest individual will be written to the log.

§share_every: u32

Only share the most fittest individual between the populations if the counter reaches this value: share_counter >= share_every.

§share_counter: u32

Counter that will be incremented every iteration. If share_counter >= share_every then the most fittest individual is shared between all the populations.

Implementations§

Source§

impl<T: Individual + Send + Sync + Clone> Simulation<T>

This implements the the functions run, print_fitness and update_results (private) for the struct Simulation.

Source

pub fn run(&mut self)

This actually runs the simulation. Depending on the type of simulation (EndIteration, EndFactor or EndFitness) the iteration loop will check for the stop condition accordingly.

Source

pub fn print_fitness(&self)

This is a helper function that the user can call after the simulation stops in order to see all the fitness values for all the individuals that participated to the overall improvement.

Auto Trait Implementations§

§

impl<T> Freeze for Simulation<T>

§

impl<T> RefUnwindSafe for Simulation<T>
where T: RefUnwindSafe,

§

impl<T> Send for Simulation<T>

§

impl<T> Sync for Simulation<T>

§

impl<T> Unpin for Simulation<T>
where T: Unpin,

§

impl<T> UnwindSafe for Simulation<T>
where T: UnwindSafe,

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.