def update_pop(self):
        """Assigns fitnesses to particles that are within bounds."""
        valid_particles = []
        invalid_particles = []
        for part in self.population:
            if any(x > 1 or x < -1 for x in part):
                invalid_particles.append(part)
            else:
                valid_particles.append(part)
        self._params['model_count'] += len(valid_particles)
        for part in valid_particles:
            self.update_particle(part)
        self.assign_fitnesses(valid_particles)
        for part in valid_particles:
            if part.fitness > part.best.fitness:
                part.best = creator.Particle(part)
                part.best.fitness = part.fitness
        for part in invalid_particles:
            self.update_particle(part)
        self.population[:] = valid_particles + invalid_particles
        self.population.sort(key=lambda x: x.ident)