Skip to content

Commit

Permalink
Fix bugs in class OMOPSO
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnebro committed Sep 2, 2024
1 parent 16e6f99 commit e0d61c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jmetal/algorithm/multiobjective/omopso.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand All @@ -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]:
Expand Down

0 comments on commit e0d61c0

Please sign in to comment.