forked from KuMiShi/Optim_Metaheuristique
MOPSO refactor (2/2)
This commit is contained in:
7
mopso.py
7
mopso.py
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user