Skip to content

Commit

Permalink
Fix bug t = self.epoch in MPA optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
thieu1995 committed Jan 3, 2024
1 parent b628476 commit b7d106f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mealpy/swarm_based/MPA.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,17 @@ def evolve(self, epoch):
epoch (int): The current iteration
"""
CF = (1 - epoch/self.epoch)**(2 * epoch/self.epoch)
# RL = self.get_levy_flight_step(beta=1.5, multiplier=0.05, size=(self.pop_size, self.problem.n_dims), case=-1)
RL = self.get_levy_flight_step(beta=1.5, multiplier=0.05, size=(self.pop_size, self.problem.n_dims), case=-1)
RB = self.generator.standard_normal((self.pop_size, self.problem.n_dims))
per1 = self.generator.permutation(self.pop_size)
per2 = self.generator.permutation(self.pop_size)
pop_new = []
for idx in range(0, self.pop_size):
R = self.generator.random(self.problem.n_dims)
t = self.epoch
if t < self.epoch / 3: # Phase 1 (Eq.12)
if epoch < self.epoch / 3: # Phase 1 (Eq.12)
step_size = RB[idx] * (self.g_best.solution - RB[idx] * self.pop[idx].solution)
pos_new = self.pop[idx].solution + self.P * R * step_size
elif self.epoch / 3 < t < 2*self.epoch / 3: # Phase 2 (Eqs. 13 & 14)
elif self.epoch / 3 < epoch < 2*self.epoch / 3: # Phase 2 (Eqs. 13 & 14)
if idx > self.pop_size / 2:
step_size = RB[idx] * (RB[idx] * self.g_best.solution - self.pop[idx].solution)
pos_new = self.g_best.solution + self.P * CF * step_size
Expand Down

0 comments on commit b7d106f

Please sign in to comment.