From e0d61c0be7b3fad04a1ee359d3387a169b4c181c Mon Sep 17 00:00:00 2001 From: ajnebro Date: Mon, 2 Sep 2024 11:48:27 +0200 Subject: [PATCH] Fix bugs in class OMOPSO --- src/jmetal/algorithm/multiobjective/omopso.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jmetal/algorithm/multiobjective/omopso.py b/src/jmetal/algorithm/multiobjective/omopso.py index 6aa5ec35..e391344f 100644 --- a/src/jmetal/algorithm/multiobjective/omopso.py +++ b/src/jmetal/algorithm/multiobjective/omopso.py @@ -118,7 +118,7 @@ def update_velocity(self, swarm: List[FloatSolution]) -> None: c2 = round(random.uniform(self.c2_min, self.c2_max), 1) w = round(random.uniform(self.weight_min, self.weight_max), 1) - for var in range(swarm[i].number_of_variables): + for var in range(len(swarm[i].variables)): self.speed[i][var] = ( w * self.speed[i][var] + (c1 * r1 * (best_particle.variables[var] - swarm[i].variables[var])) @@ -129,7 +129,7 @@ def update_position(self, swarm: List[FloatSolution]) -> None: for i in range(self.swarm_size): particle = swarm[i] - for j in range(particle.number_of_variables): + for j in range(len(particle.variables)): particle.variables[j] += self.speed[i][j] if particle.variables[j] < self.problem.lower_bound[j]: