pub struct ColorCount<const N: usize, const NSYMS: usize> {
    pub ncolors: usize,
    pub chromosone_colors: Vec<usize>,
    pub preferences: Vec<Vec<usize>>,
    pub color_names: &'static [&'static str],
    pub weight: f64,
}
Expand description

In a scheduling system, there are various types of shifts like overnight, weekend, holiday, etc. Each employee would like to have a certain number of each type of shift.

This type of fitness function is genericized here by assigning each chromosone location (aka shift) a “color” (aka shift type), and then for each symbol (aka employee), count how many of each color is in the chromosone. The negated absolute difference between each count and corresponding preference is a fitness score. (negated so that 0 is the highest score).

Parameters: chromosone_colors: the color of each locus in a corresponding chromosone preferences: the preferred count each symbol has for each color.

Fields

ncolors: usizechromosone_colors: Vec<usize>preferences: Vec<Vec<usize>>color_names: &'static [&'static str]weight: f64

Implementations

see ColorCount docs

Trait Implementations

not all games take weights into account, but some do. The vector must be [FitnessFunction.nscores] long. Scores with higher weights are worth weight times as much as nominal scores. Note that the value of the score is irrelevant – scores are never compared with scores in a different position, scores are only compared with the same score on a different candidate. The weight signifies how valuable it is that this particular score on one candidate is higher or lower than the same score on a different candidate.

returns a vector of floats where bigger numbers are better. If your fitness function optimizes to 0, remember that 0 is the biggest negative number. NaN is also a valid score, and means that the score cannot be compared and is considered a tie with any other number.

provides an [FitnessFunction.nscores] length human readable name for the scores returned. Optional, but useful for debugging

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.