Struct darwin_rs::population_builder::PopulationBuilder [] [src]

pub struct PopulationBuilder<T: Individual> {
    // some fields omitted
}

This is a helper struct in order to build (configure) a valid population. See builder pattern: https://en.wikipedia.org/wiki/Builder_pattern

Methods

impl<T: Individual> PopulationBuilder<T>
[src]

This implementation contains all the helper method to build (configure) a valid population

fn new() -> PopulationBuilder<T>

Start with this method, it must always be called as the first one. It creates a default population with some dummy (but invalid) values.

fn individuals(self, individuals: u32) -> PopulationBuilder<T>

Sets the number of individuals and creates the population, must be >= 3

fn increasing_mutation_rate(self) -> PopulationBuilder<T>

Configures the mutation rates (number of mutation runs) for all the individuals in the population: 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) -> PopulationBuilder<T>

Configures the mutation rates (number of mutation runs) for all the individuals in the population: 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>) -> PopulationBuilder<T>

Configures the mutation rates (number of mutation runs) for all the individuals in the population: This allows to specify an arbitrary mutation scheme for each individual. The number of rates must be equal to the number of individuals.

fn reset_limit_start(self, reset_limit_start: u32) -> PopulationBuilder<T>

Configures the reset limit for the population. If reset_limit_end is greater than zero then a reset counter is increased each iteration. If that counter is greater than the limit, all individuals will be resetted, the limit will be increased by 1000 and the counter is set back to zero. Default value for reset_limit_start is 1000.

fn reset_limit_end(self, reset_limit_end: u32) -> PopulationBuilder<T>

Configures the end value for the reset_limit. If the reset_limit >= reset_limit_end then the reset_limit will be resetted to the start value reset_limit_start. Default value for reset_limit_end is 100000. If reset_limit_end == 0 then the reset limit feature will be disabled.

fn reset_limit_increment(self, reset_limit_increment: u32) -> PopulationBuilder<T>

Configure the increment for the reset_limit. If the reset_limit is reached, its value is incrementet by the amount of reset_limit_increment

fn set_id(self, id: u32) -> PopulationBuilder<T>

Set the population id. Currently this is only used for statistics

fn finalize(self) -> Result<T>

This checks the configuration of the simulation and returns an PopError or Ok if no PopErrors where found.