Completed
Pull Request — master (#43)
by Wojtek
10:19
created

Result.generate()   A

Complexity

Conditions 4

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.2
cc 4
1
"""Basic grouped optimizer."""
2
3
from grortir.main.model.core.optimization_status import OptimizationStatus
4
5
6
class Result(object):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
7
    def __init__(self, process):
8
        self.process = process
9
        self.summary_result = OptimizationStatus.not_started
10
        self.detailed_result = {}
11
12
    def generate(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
13
        for stage in self.process.nodes():
14
            self.detailed_result[str(stage)] = stage.optimization_status
15
        for stage in self.process.nodes():
16
            if stage.optimization_status != OptimizationStatus.success:
17
                self.summary_result = OptimizationStatus.failed
18
            else:
19
                self.summary_result = OptimizationStatus.success
20
21
22
class GroupedOptimizer:
23
    """Optimizer is object which optimize process."""
24
25
    def __init__(self, process, grouping_strategy, pso):
26
        self.process = process
27
        self.grouping_strategy = grouping_strategy
28
        self.pso = pso
29
        self.result = Result(self.process)
30
31
    def optimize_process(self):
32
        """Optimize process.
33
        Returns:
34
            True if success, False otherwise."""
35
        self.pso.run()
36
        self.result.generate()
37