Struct darwin_rs::simulation_builder::SimulationBuilder
[−]
[src]
pub struct SimulationBuilder<T: Individual + Send + Sync> { /* 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
Maybe use phantom types, see https://github.com/willi-kappler/darwin-rs/issues/9
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 fitness(self, fitness: f64) -> SimulationBuilder<T>
Set the minimum fitness stop criteria for the simulation and thus sets the simulation
type to EndFitness
. (Only usefull in combination with EndFactor
).
fn threads(self, threads: usize) -> SimulationBuilder<T>
Sets the number of threads in order to speed up the simulation.
fn add_population(self, population: Population<T>) -> SimulationBuilder<T>
Add a population to the simulation.
fn add_multiple_populations(
self,
multiple_populations: Vec<Population<T>>
) -> SimulationBuilder<T>
self,
multiple_populations: Vec<Population<T>>
) -> SimulationBuilder<T>
Add multiple populations to the simulation.
If this option is enabled (default: off), then the fittest individual of all populations is shared between all populations.
fn num_of_global_fittest(
self,
num_of_global_fittest: usize
) -> SimulationBuilder<T>
self,
num_of_global_fittest: usize
) -> SimulationBuilder<T>
How many global fittest should be kept ? (The size of the "high score list")
fn output_every(self, output_every: u32) -> SimulationBuilder<T>
Do not output every time a new individual is found, only every nth time. n == output_every
If share fittest is enabled and the number share_every of iteration has passed then the fittest individual is shared between all populations
fn finalize(self) -> Result<Simulation<T>>
This checks the configuration of the simulation and returns an error or Ok if no errors where found.