pub struct SimulationBuilder<T: Individual + Send + Sync> { /* private fields */ }
Expand description
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
Implementations§
Source§impl<T: Individual + Send + Sync> SimulationBuilder<T>
This implementation contains all the helper method to build (configure) a valid simulation.
impl<T: Individual + Send + Sync> SimulationBuilder<T>
This implementation contains all the helper method to build (configure) a valid simulation.
Sourcepub fn new() -> SimulationBuilder<T>
pub 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.
Sourcepub fn iterations(self, iterations: u32) -> SimulationBuilder<T>
pub 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
).
Sourcepub fn factor(self, factor: f64) -> SimulationBuilder<T>
pub 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
).
Sourcepub fn fitness(self, fitness: f64) -> SimulationBuilder<T>
pub 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
).
Sourcepub fn threads(self, threads: usize) -> SimulationBuilder<T>
pub fn threads(self, threads: usize) -> SimulationBuilder<T>
Sets the number of threads in order to speed up the simulation.
Sourcepub fn add_population(self, population: Population<T>) -> SimulationBuilder<T>
pub fn add_population(self, population: Population<T>) -> SimulationBuilder<T>
Add a population to the simulation.
Sourcepub fn add_multiple_populations(
self,
multiple_populations: Vec<Population<T>>,
) -> SimulationBuilder<T>
pub fn add_multiple_populations( 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.
Sourcepub fn num_of_global_fittest(
self,
num_of_global_fittest: usize,
) -> SimulationBuilder<T>
pub fn num_of_global_fittest( self, num_of_global_fittest: usize, ) -> SimulationBuilder<T>
How many global fittest should be kept ? (The size of the “high score list”)
Sourcepub fn output_every(self, output_every: u32) -> SimulationBuilder<T>
pub 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
Sourcepub fn finalize(self) -> Result<Simulation<T>>
pub fn finalize(self) -> Result<Simulation<T>>
This checks the configuration of the simulation and returns an error or Ok if no errors where found.