Skip to content

Commit

Permalink
Apply minor refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Sep 22, 2024
1 parent 5d0940d commit 50287ef
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rosomaxa/src/algorithms/gsom/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
pub fn smooth(&mut self, rebalance_count: usize) {
(0..rebalance_count).for_each(|_| {
let mut data = self.nodes.iter_mut().flat_map(|(_, node)| node.storage.drain(0..)).collect::<Vec<_>>();
data.sort_by(compare_input);
data.sort_unstable_by(compare_input);
data.dedup_by(|a, b| compare_input(a, b) == Ordering::Equal);
data.shuffle(&mut self.random.get_rng());

Expand Down
2 changes: 1 addition & 1 deletion rosomaxa/src/termination/min_variation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ where

result
});
values.sort_by(|(a, _), (b, _)| a.cmp(b));
values.sort_unstable_by(|(a, _), (b, _)| a.cmp(b));
}

if *period > elapsed_time || values.len() < 2 {
Expand Down
2 changes: 1 addition & 1 deletion vrp-core/src/construction/clustering/dbscan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn get_average_costs(problem: &Problem, min_points: usize) -> Vec<Float> {
costs.iter_mut().for_each(|cost| *cost /= problem.fleet.profiles.len() as Float);

// sort all distances in ascending order
costs.sort_by(compare_floats_refs);
costs.sort_unstable_by(compare_floats_refs);
costs.dedup_by(|a, b| compare_floats(*a, *b) == Ordering::Equal);

costs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) fn get_clusters(
}
});

cluster_estimates.sort_by(|(a_job, (_, a_can)), (b_job, (_, b_can))| {
cluster_estimates.sort_unstable_by(|(a_job, (_, a_can)), (b_job, (_, b_can))| {
(config.building.ordering_global_fn)((b_job, b_can), (a_job, a_can))
});

Expand Down
2 changes: 1 addition & 1 deletion vrp-core/src/construction/heuristics/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub fn group_routes_by_proximity(insertion_ctx: &InsertionContext) -> RouteProxi
})
.collect::<Vec<_>>();

route_distances.sort_by(|(_, a_distance), (_, b_distance)| match (a_distance, b_distance) {
route_distances.sort_unstable_by(|(_, a_distance), (_, b_distance)| match (a_distance, b_distance) {
(Some(a_distance), Some(b_distance)) => compare_floats(*a_distance, *b_distance),
(Some(_), None) => Ordering::Less,
_ => Ordering::Greater,
Expand Down
2 changes: 1 addition & 1 deletion vrp-core/src/models/problem/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ fn create_index(
.filter(|j| **j != *job)
.map(|j| (j.clone(), get_cost_between_jobs(profile, avg_costs, transport, job, j)))
.collect();
sorted_job_costs.sort_by(|(_, a), (_, b)| compare_floats_f32_refs(a, b));
sorted_job_costs.sort_unstable_by(|(_, a), (_, b)| compare_floats_f32_refs(a, b));

sorted_job_costs.truncate(MAX_NEIGHBOURS);
sorted_job_costs.shrink_to_fit();
Expand Down

0 comments on commit 50287ef

Please sign in to comment.