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

PsoAlgorithm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 8 2
A __init__() 0 5 1
1
"""Contain PsoAlgorithm."""
2
from grortir.main.model.core.optimization_status import OptimizationStatus
3
from grortir.main.pso.process_validator import ProcessValidator
4
from grortir.main.pso.whole_group_pso import WholeGroupPso
5
6
7
class PsoAlgorithm:
8
    """Optimize process with different strategies."""
9
10
    def __init__(self, process, strategy, number_of_particle = 40):
0 ignored issues
show
Coding Style introduced by
No space allowed around keyword argument assignment
def __init__(self, process, strategy, number_of_particle = 40):
^
Loading history...
11
        self.process = process
12
        self.strategy = strategy
13
        self.processValidator = ProcessValidator()
0 ignored issues
show
Coding Style Naming introduced by
The name processValidator does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
14
        self.whole_group_pso = WholeGroupPso(self.process, number_of_particle)
15
16
    def run(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...
17
        self.processValidator.validate(self.process)
18
        self.process.optimizationStatus = OptimizationStatus.in_progress
19
        number_of_groups = self.strategy.get_actual_numbers_of_groups()
20
        for current_group_number in range(number_of_groups):
21
            current_stages = self.strategy.get_items_from_group(
22
                current_group_number)
23
            self.whole_group_pso.optimize(current_stages)
24
25