Struct oxigen::GeneticExecution
source · pub struct GeneticExecution<T, Ind: Genotype<T>> { /* private fields */ }
Expand description
Struct that defines a genetic algorithm execution.
Implementations§
source§impl<T, Ind: Genotype<T>> GeneticExecution<T, Ind>
impl<T, Ind: Genotype<T>> GeneticExecution<T, Ind>
sourcepub fn population_size(self, new_pop_size: usize) -> Self
pub fn population_size(self, new_pop_size: usize) -> Self
Sets the population size.
sourcepub fn population(self, new_pop: Vec<(Box<Ind>, Option<Fitness>)>) -> Self
pub fn population(self, new_pop: Vec<(Box<Ind>, Option<Fitness>)>) -> Self
Sets the initial population individuals. If lower individuals than population_size are received, the rest of population will be generated randomly.
sourcepub fn genotype_size(self, new_size: Ind::ProblemSize) -> Self
pub fn genotype_size(self, new_size: Ind::ProblemSize) -> Self
Sets the genotype size.
sourcepub fn mutation_rate(self, new_mut: Box<dyn MutationRate>) -> Self
pub fn mutation_rate(self, new_mut: Box<dyn MutationRate>) -> Self
Sets the mutation rate.
sourcepub fn selection_rate(self, new_sel_rate: Box<dyn SelectionRate>) -> Self
pub fn selection_rate(self, new_sel_rate: Box<dyn SelectionRate>) -> Self
Sets the number of tournament stages whose individuals are selected for crossover.
sourcepub fn select_function(self, new_sel: Box<dyn Selection>) -> Self
pub fn select_function(self, new_sel: Box<dyn Selection>) -> Self
Sets the selection function of the genetic algorithm.
sourcepub fn age_function(self, new_age: Box<dyn Age>) -> Self
pub fn age_function(self, new_age: Box<dyn Age>) -> Self
Sets the age function of the genetic algorithm.
sourcepub fn crossover_function(self, new_cross: Box<dyn Crossover<T, Ind>>) -> Self
pub fn crossover_function(self, new_cross: Box<dyn Crossover<T, Ind>>) -> Self
Sets the crossover function of the genetic algorithm.
sourcepub fn survival_pressure_function(
self,
new_surv: Box<dyn SurvivalPressure<T, Ind>>
) -> Self
pub fn survival_pressure_function(
self,
new_surv: Box<dyn SurvivalPressure<T, Ind>>
) -> Self
Sets the survival pressure function of the genetic algorithm.
sourcepub fn stop_criterion(self, new_crit: Box<dyn StopCriterion>) -> Self
pub fn stop_criterion(self, new_crit: Box<dyn StopCriterion>) -> Self
Sets the stop criterion of the genetic algorithm.
sourcepub fn cache_fitness(self, new_cache: bool) -> Self
pub fn cache_fitness(self, new_cache: bool) -> Self
Sets the cache fitness flag.
sourcepub fn progress_log(self, generations: u64, log_file: File) -> Self
pub fn progress_log(self, generations: u64, log_file: File) -> Self
Sets the progress log.
sourcepub fn population_log(self, generations: u64, log_file: File) -> Self
pub fn population_log(self, generations: u64, log_file: File) -> Self
Sets the progress log.
sourcepub fn run(self) -> (Vec<Box<Ind>>, u64, f64, Vec<(Box<Ind>, Option<Fitness>)>)
pub fn run(self) -> (Vec<Box<Ind>>, u64, f64, Vec<(Box<Ind>, Option<Fitness>)>)
Run the genetic algorithm executiion until the stop_criterion
is satisfied.
Returns
- A vector with the individuals of the population that are solution of the problem.
- The number of generations run.
- The average progress in the last generations.
- The entire population in the last generation (useful for resuming the execution).