Total Complexity | 12 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Represents swarm.""" |
||
7 | class Swarm(object): |
||
8 | """Class which represent swarm.""" |
||
9 | def __init__(self, process, stages, number_of_particles): |
||
10 | self.stages = stages |
||
11 | self.process = process |
||
12 | self.number_of_particles = number_of_particles |
||
13 | self.particles = [Particle(stages, self.process) for i in |
||
14 | range(number_of_particles)] |
||
15 | self.best_particle_quality = np.inf |
||
16 | self.best_particle = self.particles[0] |
||
17 | |||
18 | def initialize(self): |
||
19 | """Initialize all particles in swarm.""" |
||
20 | for particle in self.particles: |
||
21 | particle.initialize() |
||
22 | |||
23 | def do_single_iteration(self): |
||
24 | """Iterate one time.""" |
||
25 | for particle in self.particles: |
||
26 | particle.update_values() |
||
27 | self._update_best_particle() |
||
28 | self._update_velocieties() |
||
29 | for particle in self.particles: |
||
30 | particle.move() |
||
31 | |||
32 | def _update_best_particle(self): |
||
33 | for particle in self.particles: |
||
34 | if particle.best_quality < self.best_particle_quality: |
||
35 | self.best_particle = particle |
||
36 | self.best_particle_quality = particle.best_quality |
||
37 | |||
38 | def _update_velocieties(self): |
||
39 | for particle in self.particles: |
||
40 | particle.update_velocieties(self.best_particle) |
||
41 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.