Total Complexity | 3 |
Total Lines | 23 |
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, grouping_strategy, optimization_startegy, |
|
11 | number_of_particle=40): |
||
12 | 1 | self.process = process |
|
13 | 1 | self.grouping_strategy = grouping_strategy |
|
14 | 1 | self.optimization_strategy = optimization_startegy |
|
15 | 1 | self.process_validator = ProcessValidator() |
|
16 | 1 | self.whole_group_pso = WholeGroupPso(self.process, number_of_particle) |
|
17 | |||
18 | 1 | def run(self): |
|
19 | """Run algorithm.""" |
||
20 | 1 | self.process_validator.validate(self.process) |
|
21 | 1 | self.process.optimizationStatus = OptimizationStatus.in_progress |
|
22 | 1 | number_of_groups = self.grouping_strategy.get_actual_numbers_of_groups() |
|
23 | 1 | for current_group_number in range(number_of_groups): |
|
24 | 1 | current_stages = self.grouping_strategy.get_items_from_group( |
|
25 | current_group_number) |
||
26 | 1 | group_optimization_strategy = self.optimization_strategy. \ |
|
27 | get_group_optimization_strategy(current_stages) |
||
28 | 1 | self.whole_group_pso.optimize(current_stages, |
|
29 | group_optimization_strategy) |
||
30 |