Total Complexity | 3 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Contain PsoAlgorithm.""" |
||
7 | 1 | class PsoAlgorithm: |
|
8 | """Optimize process with different strategies.""" |
||
9 | |||
10 | 1 | def __init__(self, process, strategy, number_of_particle=40): |
|
11 | 1 | self.process = process |
|
12 | 1 | self.strategy = strategy |
|
13 | 1 | self.process_validator = ProcessValidator() |
|
14 | 1 | self.whole_group_pso = WholeGroupPso(self.process, number_of_particle) |
|
15 | |||
16 | 1 | def run(self): |
|
17 | """Run algorithm.""" |
||
18 | 1 | self.process_validator.validate(self.process) |
|
19 | 1 | self.process.optimizationStatus = OptimizationStatus.in_progress |
|
20 | 1 | number_of_groups = self.strategy.get_actual_numbers_of_groups() |
|
21 | 1 | for current_group_number in range(number_of_groups): |
|
22 | 1 | current_stages = self.strategy.get_items_from_group( |
|
23 | current_group_number) |
||
24 | self.whole_group_pso.optimize(current_stages) |
||
25 |