pub struct Score { /* private fields */ }Expand description
A Score is a value that can be used to compare the fitness of two individuals and represents
the ‘fitness’ of an individual within the genetic algorithm.
The Score can be a single value or multiple values, depending on the problem being solved.
For ease of use the Score struct provides methods
to convert the score to a single value, an integer, a string, or a vector of f32 values.
Note: The reason it is a Vec is for multi-objective optimization problems. This allows for multiple fitness values to be returned from the fitness function.
Implementations§
Source§impl Score
impl Score
pub fn from_vec(values: Vec<f32>) -> Self
pub fn is_multi_objective(&self) -> bool
pub fn objective(&self, idx: usize) -> Option<&f32>
pub fn as_slice(&self) -> &[f32]
pub fn as_f32(&self) -> f32
pub fn as_f64(&self) -> f64
pub fn as_i32(&self) -> i32
pub fn as_string(&self) -> String
pub fn as_usize(&self) -> usize
pub fn iter(&self) -> impl Iterator<Item = &f32> + '_
pub fn len(&self) -> usize
Trait Implementations§
Source§impl PartialOrd for Score
impl PartialOrd for Score
impl StructuralPartialEq for Score
Auto Trait Implementations§
impl Freeze for Score
impl RefUnwindSafe for Score
impl Send for Score
impl Sync for Score
impl Unpin for Score
impl UnsafeUnpin for Score
impl UnwindSafe for Score
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