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