From 40e09d68bef089a50a92f29fc9002a50bb9ccbf5 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 24 Apr 2024 21:02:16 +0200 Subject: [PATCH] Cargo fmt --- examples/jssp/problem/crossover.rs | 12 ++---------- src/ga.rs | 4 +--- src/ga/operators/crossover/impls/fixed_point.rs | 1 - src/ga/operators/crossover/impls/multi_point.rs | 1 - src/ga/operators/crossover/impls/ppx.rs | 1 - src/ga/operators/crossover/impls/two_point.rs | 3 +-- .../crossover/impls/uniform_parameterized.rs | 1 - 7 files changed, 4 insertions(+), 19 deletions(-) diff --git a/examples/jssp/problem/crossover.rs b/examples/jssp/problem/crossover.rs index 27d4c45..de23a3b 100644 --- a/examples/jssp/problem/crossover.rs +++ b/examples/jssp/problem/crossover.rs @@ -53,11 +53,7 @@ impl JsspCrossover { } impl CrossoverOperator for JsspCrossover { - fn apply( - &mut self, - metadata: &GAMetadata, - selected: &[&JsspIndividual], - ) -> Vec { + fn apply(&mut self, metadata: &GAMetadata, selected: &[&JsspIndividual]) -> Vec { assert!(selected.len() & 1 == 0); let mut output = Vec::with_capacity(selected.len()); @@ -90,11 +86,7 @@ impl NoopCrossover { } impl CrossoverOperator for NoopCrossover { - fn apply( - &mut self, - metadata: &GAMetadata, - selected: &[&JsspIndividual], - ) -> Vec { + fn apply(&mut self, metadata: &GAMetadata, selected: &[&JsspIndividual]) -> Vec { assert!(selected.len() & 1 == 0); let mut output = Vec::with_capacity(selected.len()); diff --git a/src/ga.rs b/src/ga.rs index 63a512b..11c7a49 100644 --- a/src/ga.rs +++ b/src/ga.rs @@ -319,9 +319,7 @@ where // FIXME: Do not assume that population size is an even number. self.timer.start(); - let mut children = self.config - .crossover_operator - .apply(&self.metadata, &mating_pool); + let mut children = self.config.crossover_operator.apply(&self.metadata, &mating_pool); self.metadata.crossover_dur = Some(self.timer.elapsed()); self.timer.start(); diff --git a/src/ga/operators/crossover/impls/fixed_point.rs b/src/ga/operators/crossover/impls/fixed_point.rs index 8c998dc..db550c8 100644 --- a/src/ga/operators/crossover/impls/fixed_point.rs +++ b/src/ga/operators/crossover/impls/fixed_point.rs @@ -56,7 +56,6 @@ impl FixedPoint { (child_1, child_2) } - } impl CrossoverOperator for FixedPoint diff --git a/src/ga/operators/crossover/impls/multi_point.rs b/src/ga/operators/crossover/impls/multi_point.rs index 8ce192f..843c622 100644 --- a/src/ga/operators/crossover/impls/multi_point.rs +++ b/src/ga/operators/crossover/impls/multi_point.rs @@ -116,7 +116,6 @@ impl MultiPoint { (IndividualT::from(child_1_ch), IndividualT::from(child_2_ch)) } - } impl CrossoverOperator for MultiPoint diff --git a/src/ga/operators/crossover/impls/ppx.rs b/src/ga/operators/crossover/impls/ppx.rs index 889232b..8e6c47e 100644 --- a/src/ga/operators/crossover/impls/ppx.rs +++ b/src/ga/operators/crossover/impls/ppx.rs @@ -136,7 +136,6 @@ impl Ppx { (child_1, child_2) } - } impl CrossoverOperator for Ppx diff --git a/src/ga/operators/crossover/impls/two_point.rs b/src/ga/operators/crossover/impls/two_point.rs index a3407f1..d486d77 100644 --- a/src/ga/operators/crossover/impls/two_point.rs +++ b/src/ga/operators/crossover/impls/two_point.rs @@ -37,8 +37,7 @@ impl TwoPoint { } } -impl TwoPoint -{ +impl TwoPoint { /// Returns a tuple of children /// /// It works by randomly selecting two cutpoints splitting parents chromosomes in three parts. diff --git a/src/ga/operators/crossover/impls/uniform_parameterized.rs b/src/ga/operators/crossover/impls/uniform_parameterized.rs index c2d1a0d..065404e 100644 --- a/src/ga/operators/crossover/impls/uniform_parameterized.rs +++ b/src/ga/operators/crossover/impls/uniform_parameterized.rs @@ -122,4 +122,3 @@ where output } } -