From 0f45e3a74f3174211c347c4abb20ff48306ed8c0 Mon Sep 17 00:00:00 2001 From: "Hohmann, Nikolas" Date: Fri, 2 Feb 2024 16:26:45 +0100 Subject: [PATCH 1/3] resolve bug that prevents two equally seeded reference direction calculations (energy reduction method) to produce the same output --- pymoo/util/ref_dirs/energy.py | 3 ++- pymoo/util/ref_dirs/reduction.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymoo/util/ref_dirs/energy.py b/pymoo/util/ref_dirs/energy.py index 0b77dd7cc..bf53827e9 100644 --- a/pymoo/util/ref_dirs/energy.py +++ b/pymoo/util/ref_dirs/energy.py @@ -157,7 +157,8 @@ def _do(self): X = ReductionBasedReferenceDirectionFactory(self.n_dim, self.n_points, kmeans=True, - lexsort=False) \ + lexsort=False, + seed=self.seed) \ .do() elif self.sampling == "construction": diff --git a/pymoo/util/ref_dirs/reduction.py b/pymoo/util/ref_dirs/reduction.py index fbb0d4bc8..bdb1bd700 100644 --- a/pymoo/util/ref_dirs/reduction.py +++ b/pymoo/util/ref_dirs/reduction.py @@ -62,7 +62,8 @@ def __init__(self, self.n_points = n_points def _do(self): - rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, unit_simplex_mapping=self.sampling) + rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, unit_simplex_mapping=self.sampling, + seed=self.seed) def h(n): return get_partition_closest_to_points(n, self.n_dim) From 18e38d85139ce9b60eb21057c5adb5b958c6af71 Mon Sep 17 00:00:00 2001 From: "Hohmann, Nikolas" Date: Fri, 2 Feb 2024 16:38:22 +0100 Subject: [PATCH 2/3] normalize F before calculating extreme points --- pymoo/algorithms/moo/nsga3.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pymoo/algorithms/moo/nsga3.py b/pymoo/algorithms/moo/nsga3.py index b17ce8df0..c1e0e5124 100644 --- a/pymoo/algorithms/moo/nsga3.py +++ b/pymoo/algorithms/moo/nsga3.py @@ -312,8 +312,11 @@ def get_extreme_points_c(F, ideal_point, extreme_points=None): __F = _F - ideal_point __F[__F < 1e-3] = 0 + # normalize __F + __F_norm = (__F - np.min(__F, axis=0)) / (np.max(__F, axis=0) - np.min(__F, axis=0)) + # update the extreme points for the normalization having the highest asf value each - F_asf = np.max(__F * weights[:, None, :], axis=2) + F_asf = np.max(__F_norm * weights[:, None, :], axis=2) I = np.argmin(F_asf, axis=1) extreme_points = _F[I, :] From 7b7cdf653030b8209c844f89a7653dcb421c44ac Mon Sep 17 00:00:00 2001 From: "Hohmann, Nikolas" Date: Fri, 2 Feb 2024 16:54:10 +0100 Subject: [PATCH 3/3] Revert "resolve bug that prevents two equally seeded reference direction calculations (energy reduction method) to produce the same output" This reverts commit 0f45e3a74f3174211c347c4abb20ff48306ed8c0. revert commit --- pymoo/util/ref_dirs/energy.py | 3 +-- pymoo/util/ref_dirs/reduction.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pymoo/util/ref_dirs/energy.py b/pymoo/util/ref_dirs/energy.py index bf53827e9..0b77dd7cc 100644 --- a/pymoo/util/ref_dirs/energy.py +++ b/pymoo/util/ref_dirs/energy.py @@ -157,8 +157,7 @@ def _do(self): X = ReductionBasedReferenceDirectionFactory(self.n_dim, self.n_points, kmeans=True, - lexsort=False, - seed=self.seed) \ + lexsort=False) \ .do() elif self.sampling == "construction": diff --git a/pymoo/util/ref_dirs/reduction.py b/pymoo/util/ref_dirs/reduction.py index bdb1bd700..fbb0d4bc8 100644 --- a/pymoo/util/ref_dirs/reduction.py +++ b/pymoo/util/ref_dirs/reduction.py @@ -62,8 +62,7 @@ def __init__(self, self.n_points = n_points def _do(self): - rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, unit_simplex_mapping=self.sampling, - seed=self.seed) + rnd = sample_on_unit_simplex(self.n_sample_points, self.n_dim, unit_simplex_mapping=self.sampling) def h(n): return get_partition_closest_to_points(n, self.n_dim)