| Total Complexity | 6 | 
| Total Lines | 27 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
| 1 | """Basic optimizer.""" | ||
| 8 | 1 | class Optimizer(BaseOptimizer): | |
| 9 | """Optimizer is object which optimize process.""" | ||
| 10 | |||
| 11 | 1 | def optimize_process(self): | |
| 12 | 1 | """Optimize process. | |
| 13 | 1 | Raises: | |
| 14 | 1 | AttributeError: When project has incorrect structure. | |
| 15 | |||
| 16 | 1 | Returns: | |
| 17 | bool: True if success, False otherwise.""" | ||
| 18 | 1 | for stage in self.ordered_stages: | |
| 19 | if not self.process.predecessors(stage): | ||
| 20 | 1 | self.run_pso(stage) | |
| 21 | elif len(self.process.predecessors(stage)) == 1: | ||
| 22 | 1 | predecessor = self.process.predecessors(stage)[0] | |
| 23 | stage.input_vector = predecessor.get_output_of_stage() | ||
| 24 | 1 | self.run_pso(stage) | |
| 25 | else: | ||
| 26 |                 raise AttributeError('Incorrect process structure.') | ||
| 27 | |||
| 28 | if stage.optimization_status != OptimizationStatus.success: | ||
| 29 | return False | ||
| 30 | return True | ||
| 31 | 1 | ||
| 32 | 1 | def run_pso(self, stage): | |
| 33 | 1 | """Run pso with predefined parameters.""" | |
| 34 | pso(stage, swarmsize=self.swarm_size) | ||
| 35 |