pub struct GaConfig {
pub population_size: usize,
pub max_generations: u32,
pub crossover_rate: f64,
pub mutation_rate: f64,
pub elite_count: usize,
pub tournament_size: usize,
pub time_limit: Option<Duration>,
pub target_fitness: Option<f64>,
pub stagnation_limit: Option<u32>,
}Expand description
Configuration for the genetic algorithm.
Fields§
§population_size: usizePopulation size.
max_generations: u32Maximum number of generations.
crossover_rate: f64Crossover rate (0.0 - 1.0).
mutation_rate: f64Mutation rate (0.0 - 1.0).
elite_count: usizeNumber of elite individuals to preserve each generation.
tournament_size: usizeTournament size for selection.
time_limit: Option<Duration>Maximum time limit (None = unlimited).
target_fitness: Option<f64>Target fitness to stop early (None = run all generations).
stagnation_limit: Option<u32>Stagnation generations before early stop.
Implementations§
Source§impl GaConfig
impl GaConfig
Sourcepub fn with_population_size(self, size: usize) -> Self
pub fn with_population_size(self, size: usize) -> Self
Sets the population size.
Sourcepub fn with_max_generations(self, gen: u32) -> Self
pub fn with_max_generations(self, gen: u32) -> Self
Sets the maximum generations.
Sourcepub fn with_crossover_rate(self, rate: f64) -> Self
pub fn with_crossover_rate(self, rate: f64) -> Self
Sets the crossover rate.
Sourcepub fn with_mutation_rate(self, rate: f64) -> Self
pub fn with_mutation_rate(self, rate: f64) -> Self
Sets the mutation rate.
Sourcepub fn with_elite_count(self, count: usize) -> Self
pub fn with_elite_count(self, count: usize) -> Self
Sets the elite count.
Sourcepub fn with_time_limit(self, duration: Duration) -> Self
pub fn with_time_limit(self, duration: Duration) -> Self
Sets the time limit.
Sourcepub fn with_target_fitness(self, fitness: f64) -> Self
pub fn with_target_fitness(self, fitness: f64) -> Self
Sets the target fitness.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GaConfig
impl RefUnwindSafe for GaConfig
impl Send for GaConfig
impl Sync for GaConfig
impl Unpin for GaConfig
impl UnwindSafe for GaConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.