Completed
Pull Request — master (#43)
by Wojtek
09:32
created

OptimizationController

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 25

3 Methods

Rating   Name   Duplication   Size   Complexity  
B should_continue() 0 9 5
A WholeGroupPso.__init__() 0 3 1
A WholeGroupPso.optimize() 0 7 2
1
"""Contains WholeGroupPso class."""
2
3
from grortir.main.pso.swarm import Swarm
4
from main.model.core.optimization_status import OptimizationStatus
0 ignored issues
show
Bug introduced by
The name model does not seem to exist in module main.
Loading history...
Configuration introduced by
The import main.model.core.optimization_status could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
5
6
7
class OptimizationController(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...
8
    @staticmethod
9
    def should_continue(stages):
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...
10
        for stage in stages:
11
            if OptimizationStatus.failed == stage.optimization_status:
12
                return False
13
        for stage in stages:
14
            if OptimizationStatus.success != stage.optimization_status:
15
                return True
16
        return False
17
18
    class WholeGroupPso(object):
19
        """Optimize whole group."""
20
21
        def __init__(self, process):
22
            self.process = process
23
            self.number_of_particles = 40
24
25
        def optimize(self, ordered_stages_to_optimize):
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...
26
            swarm = Swarm(self.process, ordered_stages_to_optimize,
27
                          self.number_of_particles)
28
            swarm.initialize()
29
            while OptimizationController.should_continue(
30
                    ordered_stages_to_optimize):
31
                swarm.do_single_iteration()
32