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

pub struct PopulationBuilder<T: Individual> { /* 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

Maybe use phantom types, see https://github.com/willi-kappler/darwin-rs/issues/9

Methods

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

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

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

Sets the initial population provided inside a vector, length must be >= 3

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.

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.

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.

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.

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.

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

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

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