Struct Score

Source
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

Source

pub fn from_vec(values: Vec<f32>) -> Self

Source

pub fn as_f32(&self) -> f32

Source

pub fn as_i32(&self) -> i32

Source

pub fn as_string(&self) -> String

Source

pub fn as_usize(&self) -> usize

Source

pub fn iter(&self) -> impl Iterator<Item = &f32> + '_

Trait Implementations§

Source§

impl Add<f32> for Score

Source§

type Output = Score

The resulting type after applying the + operator.
Source§

fn add(self, other: f32) -> Self

Performs the + operation. Read more
Source§

impl Add for Score

Source§

type Output = Score

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl AsRef<[f32]> for Score

Source§

fn as_ref(&self) -> &[f32]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Score

Source§

fn clone(&self) -> Score

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Score

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Score

Source§

fn default() -> Score

Returns the “default value” for a type. Read more
Source§

impl Div<f32> for Score

Source§

type Output = Score

The resulting type after applying the / operator.
Source§

fn div(self, other: f32) -> Self

Performs the / operation. Read more
Source§

impl Div for Score

Source§

type Output = Score

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl From<&str> for Score

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Score

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<&str>> for Score

Source§

fn from(value: Vec<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for Score

Source§

fn from(value: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Score

Source§

fn from(value: Vec<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for Score

Source§

fn from(value: Vec<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<i32>> for Score

Source§

fn from(value: Vec<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<i64>> for Score

Source§

fn from(value: Vec<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<usize>> for Score

Source§

fn from(value: Vec<usize>) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Score

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Score

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Score

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Score

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Score

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for Score

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Index<usize> for Score

Source§

type Output = f32

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Into<Vec<f32>> for Score

Source§

fn into(self) -> Vec<f32>

Converts this type into the (usually inferred) input type.
Source§

impl Mul<Score> for f32

Source§

type Output = Score

The resulting type after applying the * operator.
Source§

fn mul(self, other: Score) -> Score

Performs the * operation. Read more
Source§

impl Mul<f32> for Score

Source§

type Output = Score

The resulting type after applying the * operator.
Source§

fn mul(self, other: f32) -> Self

Performs the * operation. Read more
Source§

impl Mul for Score

Source§

type Output = Score

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl PartialEq for Score

Source§

fn eq(&self, other: &Score) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Score

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<f32> for Score

Source§

type Output = Score

The resulting type after applying the - operator.
Source§

fn sub(self, other: f32) -> Self

Performs the - operation. Read more
Source§

impl Sub for Score

Source§

type Output = Score

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl<'a> Sum<&'a Score> for Score

Source§

fn sum<I: Iterator<Item = &'a Score>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for Score

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

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 UnwindSafe for Score

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V