#[non_exhaustive]pub struct Evaluation {
pub value: f64,
pub violation: f64,
}Expand description
What a model gives for one candidate under constraints: its value, and by how much it breaks the constraints, zero if it keeps them all.
Candidates are ranked by K. Deb’s feasibility rules (“An efficient constraint handling method for genetic algorithms”, Computer Methods in Applied Mechanics and Engineering 186(2–4), 311–338 (2000), https://doi.org/10.1016/S0045-7825(99)00389-8, §3): a candidate that keeps every constraint beats one that doesn’t; of two that keep them, the smaller value wins; of two that don’t, the smaller violation wins (here ties in violation go to the smaller value). No penalty weight is needed, as values and violations are never compared with each other. The rules rank, and CMA-ES uses only ranks.
A candidate the model can’t evaluate (a flight that fails) is value and violation both
+∞: it ranks behind every other. Both serialize +∞ as none, a JSON null.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.value: f64The model’s value.
violation: f64The total violation, Σ max(0, gⱼ) over constraints written gⱼ ≤ 0: zero if the
candidate keeps them all.
Implementations§
Source§impl Evaluation
impl Evaluation
Sourcepub const fn failed() -> Self
pub const fn failed() -> Self
A candidate the model can’t evaluate: value and violation both +∞, behind every other.
Sourcepub fn constrained(value: f64, constraints: &[f64]) -> Self
pub fn constrained(value: f64, constraints: &[f64]) -> Self
A value under constraints gⱼ(x) ≤ 0, given as the numbers gⱼ: the violation is
Σ max(0, gⱼ), Deb’s (2000) overall violation. Deb divides each constraint by a constant
so that they count alike (a margin in calibers and a speed in m/s, say); do the same before
passing them in. A NaN gⱼ gives a NaN violation, which cmaes::Run::tell_constrained
refuses.
Sourcepub fn is_feasible(&self) -> bool
pub fn is_feasible(&self) -> bool
Whether the candidate keeps every constraint.
Sourcepub fn rank(&self, other: &Self) -> Ordering
pub fn rank(&self, other: &Self) -> Ordering
Deb’s rules as an ordering: Less if self ranks ahead of
other. Violation first, with −0 equal to 0, then value by f64::total_cmp
(CMA-ES’s own ranking of plain values).
Trait Implementations§
Source§impl Clone for Evaluation
impl Clone for Evaluation
Source§fn clone(&self) -> Evaluation
fn clone(&self) -> Evaluation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Evaluation
Source§impl Debug for Evaluation
impl Debug for Evaluation
Source§impl<'de> Deserialize<'de> for Evaluation
impl<'de> Deserialize<'de> for Evaluation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Evaluation
impl PartialEq for Evaluation
Source§fn eq(&self, other: &Evaluation) -> bool
fn eq(&self, other: &Evaluation) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Evaluation
impl Serialize for Evaluation
impl StructuralPartialEq for Evaluation
Auto Trait Implementations§
impl Freeze for Evaluation
impl RefUnwindSafe for Evaluation
impl Send for Evaluation
impl Sync for Evaluation
impl Unpin for Evaluation
impl UnsafeUnpin for Evaluation
impl UnwindSafe for Evaluation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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