pub struct PopulationBuilder<G, S, C, F, R> { /* private fields */ }Expand description
Builder for a Population
Implementations§
Source§impl<G, S, C, F, R> PopulationBuilder<G, S, C, F, R>where
G: Gene,
S: Selection<G>,
C: Crossover<G>,
F: FnMut(&Chromosome<G>, &[Chromosome<G>]) -> f64,
R: Rng + Default,
impl<G, S, C, F, R> PopulationBuilder<G, S, C, F, R>where
G: Gene,
S: Selection<G>,
C: Crossover<G>,
F: FnMut(&Chromosome<G>, &[Chromosome<G>]) -> f64,
R: Rng + Default,
Sourcepub fn new(population: Option<Vec<Chromosome<G>>>, eval_fn: F) -> Self
pub fn new(population: Option<Vec<Chromosome<G>>>, eval_fn: F) -> Self
Creates a new PopulationBuilder
§Arguments
population- The population to useeval_fn- The evaluation function
§Returns
A new PopulationBuilder
Sourcepub fn with_chromo_size(self, chromo_size: usize) -> Self
pub fn with_chromo_size(self, chromo_size: usize) -> Self
Sourcepub fn with_population_size(self, pop_size: usize) -> Self
pub fn with_population_size(self, pop_size: usize) -> Self
Sourcepub fn with_mutation_rate(self, mutation_rate: f64) -> Self
pub fn with_mutation_rate(self, mutation_rate: f64) -> Self
Sourcepub fn with_elitism(self, elitism: bool) -> Self
pub fn with_elitism(self, elitism: bool) -> Self
Sourcepub fn with_print(self, print: bool) -> Self
pub fn with_print(self, print: bool) -> Self
Sourcepub fn with_selection(self, selection: S) -> Self
pub fn with_selection(self, selection: S) -> Self
Sourcepub fn with_crossover(self, crossover: C) -> Self
pub fn with_crossover(self, crossover: C) -> Self
Sourcepub fn build(self) -> Result<Population<G, S, C, F, R>>
pub fn build(self) -> Result<Population<G, S, C, F, R>>
Builds the Population
§Errors
NeuralError::NoPopSize: If the population size is not setNeuralError::NoChromoSize: If the chromosome size is not setNeuralError::NoMutationRate: If the mutation rate is not set
Trait Implementations§
Auto Trait Implementations§
impl<G, S, C, F, R> Freeze for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> RefUnwindSafe for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> Send for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> Sync for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> Unpin for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> UnsafeUnpin for PopulationBuilder<G, S, C, F, R>
impl<G, S, C, F, R> UnwindSafe for PopulationBuilder<G, S, C, F, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more