Files
Optim_Metaheuristique/mopso.py
2026-01-12 18:46:32 +01:00

38 lines
1.3 KiB
Python

from .particle import Particle
class MOPSO():
def __init__(self, n, t, w, c1, c2, a_max, surrogate=False):
# Constants
self.n = n # Number of particles
self.t = t # Number of iterations
self.w = w # Inertia (for exploration)
self.c1 = c1 # Individual trust
self.c2 = c2 # Social trust
self.a_max = a_max # Archive size
self.surrogate = surrogate # Using AI calculation
self.particles = [] # Particles of the simulation
# Fonctions objectifs
# Limites variables de decision
def iterate(self):
nb_iter = 0
if not self.surrogate:
while nb_iter < self.t:
nb_iter += 1
# Selection of a leader
# Updating velocity and positions
# Checking boundaries
# Evaluating particles
# Update the archive
# Checking for best positions
else:
while nb_iter < self.t:
nb_iter += 1
# Selection of a leader
# Updating velocity and positions
# Checking boundaries
# Evaluating particles
# Update the archive
# Checking for best positions