use super::ParetoCrowdingDistanceQuality;
pub trait Dominance {
fn dominates(&self, other: &Self) -> bool;
}
impl Dominance for f64 {
fn dominates(&self, other: &Self) -> bool {
self > other
}
}
impl Dominance for ParetoCrowdingDistanceQuality {
fn dominates(&self, other: &Self) -> bool {
if self.objectives.is_empty()
|| other.objectives.is_empty()
|| self.objectives.len() != other.objectives.len()
{
return false;
}
let mut strictly_better_in_any = false;
for (&a, &b) in self.objectives.iter().zip(other.objectives.iter()) {
if a > b {
return false;
}
if a < b {
strictly_better_in_any = true;
}
}
strictly_better_in_any
}
}