MOPSO refactor (2/2)

This commit is contained in:
KuMiShi
2026-01-17 15:32:53 +01:00
parent 54d2303fb9
commit 1dcd04cf85
2 changed files with 25 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ class MOPSO():
# Evaluating particles
self.particles[i].evaluate(self.f_weights, self.prices, self.socs, self.socs_req, self.times)
self.particles[i].update_best()
# Update the archive
self.update_archive()
@@ -94,7 +95,11 @@ class MOPSO():
# True if a dominates b, else false
def dominates(a:Particle, b:Particle):
dominates = False
dominates = (a.f_current[0] >= b.f_current[0]) and (a.f_current[1] >= b.f_current[1]) and (a.f_current[2] >= b.f_current[2])
if dominates:
# Not strict superiority yet
dominates = (a.f_current[0] > b.f_current[0]) or (a.f_current[1] > b.f_current[1]) or (a.f_current[2] > b.f_current[2])
return dominates
def update_archive(self):