Setup the algorithm for the given problem.
(self, problem, **kwargs)
| 70 | self.random_state = default_random_state(kwargs.get("seed")) |
| 71 | |
| 72 | def _setup(self, problem, **kwargs): |
| 73 | """Setup the algorithm for the given problem.""" |
| 74 | super()._setup(problem, **kwargs) |
| 75 | |
| 76 | # Initialize the external archive |
| 77 | self.archive = MultiObjectiveArchive(max_size=self.archive_size) |
| 78 | |
| 79 | # Compute maximum velocity based on problem bounds |
| 80 | xl, xu = problem.bounds() |
| 81 | self.v_max = self.max_velocity_rate * (xu - xl) |
| 82 | |
| 83 | # Initialize particles, velocities, and personal bests |
| 84 | self.pop = self.sampling.do( |
| 85 | problem, self.pop_size, random_state=self.random_state |
| 86 | ) |
| 87 | self.velocities = self.random_state.uniform( |
| 88 | -self.v_max, self.v_max, (self.pop_size, problem.n_var) |
| 89 | ) |
| 90 | self.pbest = self.pop.copy() # Personal bests |
| 91 | self.pbest_f = np.full( |
| 92 | (self.pop_size, problem.n_obj), np.inf |
| 93 | ) # Initialize with inf |
| 94 | |
| 95 | # Evaluate initial population to set personal best objectives |
| 96 | self.evaluator.eval(self.problem, self.pop) |
| 97 | |
| 98 | def _initialize_infill(self): |
| 99 | """Initialize the population and velocities.""" |
nothing calls this directly
no test coverage detected