pub enum SelectionError {
NoValidParents,
InvalidSampleSize {
min_required: usize,
provided: usize,
},
InvalidFitnessForRoulette,
RouletteSelectionFailed,
}Expand description
Errors that can occur during parent selection.
These errors help diagnose configuration or data issues that prevent successful parent selection for breeding operations.
Variants§
NoValidParents
No candidates with fitness values are available for selection.
This occurs when all candidates in the population have None fitness values,
meaning no candidates have been evaluated yet.
Solution: Ensure candidates are evaluated before attempting selection.
InvalidSampleSize
Invalid sample size for tournament selection configuration.
Tournament selection requires sample_size >= tournament_size * 2 because
it runs two separate tournaments (one for each parent in a breeding pair).
InvalidFitnessForRoulette
Roulette selection cannot proceed due to invalid fitness values.
This error occurs when:
- Any candidate has negative fitness (< 0.0)
- All candidates have zero fitness (total fitness = 0.0)
Solutions:
- Ensure all fitness values are non-negative
- Verify that at least some candidates have positive fitness
- Consider fitness normalization if needed
- Switch to tournament selection if fitness scaling is problematic
RouletteSelectionFailed
Internal roulette wheel algorithm failure.
This should not occur under normal conditions and indicates a bug in the roulette selection implementation.
Trait Implementations§
Source§impl Debug for SelectionError
impl Debug for SelectionError
Source§impl Display for SelectionError
impl Display for SelectionError
Source§impl Error for SelectionError
impl Error for SelectionError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<SelectionError> for Error
impl From<SelectionError> for Error
Source§fn from(source: SelectionError) -> Self
fn from(source: SelectionError) -> Self
Auto Trait Implementations§
impl Freeze for SelectionError
impl RefUnwindSafe for SelectionError
impl Send for SelectionError
impl Sync for SelectionError
impl Unpin for SelectionError
impl UnsafeUnpin for SelectionError
impl UnwindSafe for SelectionError
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 more