Struct darwin_rs::SimulationBuilder
[−]
[src]
pub struct SimulationBuilder<T: Individual + Send + Sync> { // some fields omitted }
This is a helper struct in order to build (configure) a valid simulation. See builder pattern: https://en.wikipedia.org/wiki/Builder_pattern
Methods
impl<T: Individual + Send + Sync> SimulationBuilder<T>
[src]
This implementation contains all the helper method to build (configure) a valid simulation
fn new() -> SimulationBuilder<T>
Start with this method, it must always be called as the first one. It creates a default simulation with some dummy (but invalid) values.
fn iterations(self, iterations: u32) -> SimulationBuilder<T>
Set the total number of iterations for the simulation and thus sets the simulation type to EndIteration
.
(Only usefull in combination with EndIteration
).
fn factor(self, factor: f64) -> SimulationBuilder<T>
Set the improvement factor stop criteria for the simulation and thus sets the simulation type to EndFactor
.
(Only usefull in combination with EndFactor
).
fn fittness(self, fittness: f64) -> SimulationBuilder<T>
Set the minimum fittness stop criteria for the simulation and thus sets the simulation type to EndFittness
.
(Only usefull in combination with EndFactor
).
fn individuals(self, individuals: u32) -> SimulationBuilder<T>
Sets the number of individuals and creates the population, must be >= 3
fn threads(self, threads: usize) -> SimulationBuilder<T>
Sets the number of threads in order to speed up the simulation.
fn output_new_fittest(self, output_new_fittest: bool) -> SimulationBuilder<T>
Sets a flag if the simulation should write a message whenever a new fittest individual is found.
fn increasing_mutation_rate(self) -> SimulationBuilder<T>
Configures the mutation rates (number of mutation runs) for all the individuals in the sumulation: The first individual will mutate once, the second will mutate twice, the nth individual will Mutate n-times per iteration.
fn increasing_exp_mutation_rate(self, base: f64) -> SimulationBuilder<T>
Configures the mutation rates (number of mutation runs) for all the individuals in the sumulation:
Instead of a linear growing mutation rate like in the increasing_mutation_rate
function above
this sets an exponention mutation rate for all the individuals.
The first individual will mutate base1 times, the second will mutate base2 times, and nth
will mutate basen times per iteration.
fn mutation_rate(self, mutation_rate: Vec<u32>) -> SimulationBuilder<T>
Configures the mutation rates (number of mutation runs) for all the individuals in the sumulation: This allows to specify an arbitrary mutation scheme for each individual. The number of rates must be equal to the number of individuals.
fn finalize(self) -> BuilderResult<T>
This checks the configuration of the simulation and returns an error or Ok if no errors where found.