From 5552b823893716ca6ebac4539d5b330235ec82c7 Mon Sep 17 00:00:00 2001 From: franzscheuer Date: Mon, 10 Oct 2022 17:29:55 +0200 Subject: [PATCH] TypeError Fix --- jmetal/operator/crossover.py | 8 ++++---- jmetal/operator/mutation.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jmetal/operator/crossover.py b/jmetal/operator/crossover.py index 880fe867..a44c4511 100644 --- a/jmetal/operator/crossover.py +++ b/jmetal/operator/crossover.py @@ -175,18 +175,18 @@ def execute(self, parents: List[FloatSolution]) -> List[FloatSolution]: rand = random.random() if rand <= (1.0 / alpha): - betaq = pow(rand * alpha, (1.0 / (self.distribution_index + 1.0))) + betaq = pow(abs(rand * alpha), (1.0 / (self.distribution_index + 1.0))) else: - betaq = pow(1.0 / (2.0 - rand * alpha), 1.0 / (self.distribution_index + 1.0)) + betaq = pow(abs(1.0 / (2.0 - rand * alpha)), 1.0 / (self.distribution_index + 1.0)) c1 = 0.5 * (y1 + y2 - betaq * (y2 - y1)) beta = 1.0 + (2.0 * (upper_bound - y2) / (y2 - y1)) alpha = 2.0 - pow(beta, -(self.distribution_index + 1.0)) if rand <= (1.0 / alpha): - betaq = pow((rand * alpha), (1.0 / (self.distribution_index + 1.0))) + betaq = pow(abs(rand * alpha), (1.0 / (self.distribution_index + 1.0))) else: - betaq = pow(1.0 / (2.0 - rand * alpha), 1.0 / (self.distribution_index + 1.0)) + betaq = pow(abs(1.0 / (2.0 - rand * alpha)), 1.0 / (self.distribution_index + 1.0)) c2 = 0.5 * (y1 + y2 + betaq * (y2 - y1)) diff --git a/jmetal/operator/mutation.py b/jmetal/operator/mutation.py index 955af5b3..4eb3c242 100644 --- a/jmetal/operator/mutation.py +++ b/jmetal/operator/mutation.py @@ -74,11 +74,11 @@ def execute(self, solution: FloatSolution) -> FloatSolution: if rnd <= 0.5: xy = 1.0 - delta1 val = 2.0 * rnd + (1.0 - 2.0 * rnd) * (pow(xy, self.distribution_index + 1.0)) - deltaq = pow(val, mut_pow) - 1.0 + deltaq = pow(abs(val), mut_pow) - 1.0 else: xy = 1.0 - delta2 val = 2.0 * (1.0 - rnd) + 2.0 * (rnd - 0.5) * (pow(xy, self.distribution_index + 1.0)) - deltaq = 1.0 - pow(val, mut_pow) + deltaq = 1.0 - pow(abs(val), mut_pow) y += deltaq * (yu - yl) if y < solution.lower_bound[i]: