Skip to content

[BUG]: BBOA evolve function #237

@Tryphonpatta

Description

@Tryphonpatta

Description of the bug

        pp = epoch / self.epoch
        ## Pedal marking behaviour
        pop_new = []
        for idx in range(0, self.pop_size):
            if pp <= epoch/3:         <= this is where the errors occur
                pos_new = self.pop[idx].solution + (-pp * self.generator.random(self.problem.n_dims) * self.pop[idx].solution)
            elif epoch/3 < pp <= 2*epoch/3:     <= this is where the errors occur
                qq = pp * self.generator.random(self.problem.n_dims)
                pos_new = self.pop[idx].solution + (qq * (self.g_best.solution - self.generator.integers(1, 3) * self.g_worst.solution))
            else:
                ww = 2 * pp * np.pi * self.generator.random(self.problem.n_dims)
                pos_new = self.pop[idx].solution + (ww*self.g_best.solution - np.abs(self.pop[idx].solution)) - (ww*self.g_worst.solution - np.abs(self.pop[idx].solution))
            pos_new = self.correct_solution(pos_new)
            agent = self.generate_empty_agent(pos_new)
            pop_new.append(agent)
            if self.mode not in self.AVAILABLE_MODES:
                agent.target = self.get_target(pos_new)
                self.pop[idx] = self.get_better_agent(agent, self.pop[idx], self.problem.minmax)

It should be something like this

    for idx in range(0, self.pop_size):
            if pp <= 1/3:          # Gait while walking
                pos_new = self.pop[idx].solution + (-pp * self.generator.random(self.problem.n_dims) * self.pop[idx].solution)
                print("Case 1")
            elif 1/3 < pp <= 2/3:     # Careful Stepping
                qq = pp * self.generator.random(self.problem.n_dims)
                pos_new = self.pop[idx].solution + (qq * (self.g_best.solution - self.generator.integers(1, 3) * self.g_worst.solution))
                print("Case 2")
            else:
                ww = 2 * pp * np.pi * self.generator.random(self.problem.n_dims)
                pos_new = self.pop[idx].solution + (ww*self.g_best.solution - np.abs(self.pop[idx].solution)) - (ww*self.g_worst.solution - np.abs(self.pop[idx].solution))
                print("Case 3")

Steps To Reproduce

  1. Go to mealpy/bio_based/BBOA.py
  2. at lines 68,70

Additional Information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions