Struct darwin_rs::Simulation
[−]
[src]
pub struct Simulation<T: Individual + Send + Sync> { pub type_of_simulation: SimulationType, pub num_of_individuals: u32, pub num_of_threads: usize, pub improvement_factor: f64, pub original_fitness: f64, pub fittest: IndividualWrapper<T>, pub population: Vec<IndividualWrapper<T>>, pub total_time_in_ms: f64, pub iteration_counter: u32, pub reset_limit: u32, pub reset_counter: u32, pub output_new_fittest: bool, pub pool: Pool, }
The Simulation
type. Contains all the information / configuration for the simulation to run.
Fields
type_of_simulation: SimulationType
How should the simulation stop ?
num_of_individuals: u32
The number of individuals for the whole simulation.
num_of_threads: usize
The number of threads to use to speed up calculation.
improvement_factor: f64
The current improvement factor, that means the ration between the first and the current fitness.
original_fitness: f64
The very first calculated fitness, when the simulation just started.
fittest: IndividualWrapper<T>
The current fittest individual. This will change during the simulation as soon as a new more fittest individual is found
population: Vec<IndividualWrapper<T>>
The population 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.
iteration_counter: u32
The number of current iteration. This changes with every iteration and is used by the
EndIteration
enum.
reset_limit: u32
The amount of iteration to wait until all individuals will be resetted.
reset_counter: u32
The reset counter, if reset_counter >= reset_limit, all the individuals are discarded and the simulation restarts anew with an increased reset_limit. This prevents local minima, but also discards the current fittest individual.
output_new_fittest: bool
A flag that specifies if the sumulation should write a message every time a new most fittest individual is found.
pool: Pool
The thread pool used by the jobsteal
crate
Methods
impl<T: Individual + Send + Sync + Clone> Simulation<T>
[src]
This implements the two functions run
and print_fitness
for the struct Simulation
.
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.
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.