diff --git a/rosomaxa/src/algorithms/gsom/network.rs b/rosomaxa/src/algorithms/gsom/network.rs index 70b4a9998..3346e79d7 100644 --- a/rosomaxa/src/algorithms/gsom/network.rs +++ b/rosomaxa/src/algorithms/gsom/network.rs @@ -183,7 +183,7 @@ where /// Returns max unified distance of the network. pub fn max_unified_distance(&self) -> Float { - self.get_nodes().map(|node| node.unified_distance(self, 1)).max_by(|a, b| a.total_cmp(b)).unwrap_or(0.) + self.get_nodes().map(|node| node.unified_distance(self, 1)).max_by(|a, b| a.total_cmp(b)).unwrap_or_default() } /// Trains network on an input. diff --git a/rosomaxa/src/termination/mod.rs b/rosomaxa/src/termination/mod.rs index 98228c566..d6aac0d03 100644 --- a/rosomaxa/src/termination/mod.rs +++ b/rosomaxa/src/termination/mod.rs @@ -66,6 +66,6 @@ where } fn estimate(&self, heuristic_ctx: &Self::Context) -> Float { - self.terminations.iter().map(|t| t.estimate(heuristic_ctx)).max_by(|a, b| a.total_cmp(b)).unwrap_or(0.) + self.terminations.iter().map(|t| t.estimate(heuristic_ctx)).max_by(|a, b| a.total_cmp(b)).unwrap_or_default() } } diff --git a/vrp-core/src/models/goal.rs b/vrp-core/src/models/goal.rs index 3cfff9330..ec337f890 100644 --- a/vrp-core/src/models/goal.rs +++ b/vrp-core/src/models/goal.rs @@ -205,7 +205,13 @@ impl GoalBuilder { let fitness_a = objectives[0].fitness(a); let fitness_b = objectives[0].fitness(b); - fitness_a.total_cmp(&fitness_b) + // NOTE total_cmp distinguishes between positive zero and negative zero while + // logically they are the same in this context + if fitness_a == 0. && fitness_b == 0. { + Ordering::Equal + } else { + fitness_a.total_cmp(&fitness_b) + } }), Arc::new(|objectives, move_ctx| objectives[0].estimate(move_ctx)), vec![objective],