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

WholeGroupPso.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
"""Contains WholeGroupPso class."""
2
3
from grortir.main.pso.swarm import Swarm
4
from grortir.main.model.core.optimization_status import OptimizationStatus
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
19
class WholeGroupPso(object):
20
    """Optimize whole group."""
21
22
    def __init__(self, process, number_of_particles):
23
        self.process = process
24
        self.number_of_particles = number_of_particles
25
26
    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...
27
        swarm = Swarm(self.process, ordered_stages_to_optimize,
28
                      self.number_of_particles)
29
        swarm.initialize()
30
        while OptimizationController.should_continue(
31
                ordered_stages_to_optimize):
32
            swarm.do_single_iteration()
33