def initialize_pop(self):
        """Generates initial population with random positions and speeds."""
        self.population = self.toolbox.swarm(n=self._params['popsize'])
        if self._params['neighbours']:
            for i in range(len(self.population)):
                self.population[i].ident = i
                self.population[i].neighbours = list(
                    set(
                        [(i - x) % len(self.population)
                         for x in range(1, self._params['neighbours'] + 1)] +
                        [i] +
                        [(i + x) % len(self.population)
                         for x in range(1, self._params['neighbours'] + 1)]
                    ))
        else:
            for i in range(len(self.population)):
                self.population[i].ident = i
                self.population[i].neighbours = [
                    x for x in range(len(self.population))]
        self.assign_fitnesses(self.population)
        for part in self.population:
            part.best = creator.Particle(part)
            part.best.fitness.values = part.fitness.values
Generates initial population with random positions and speeds.