Completed
Pull Request — master (#21)
by Grega
01:03
created

Sphere   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 5 2
A __init__() 0 3 1
A function() 0 9 3
1
"""Implementation of Sphere function."""
2
3
__all__ = ['Sphere']
4
5
6
class Sphere(object):
7
8
    def __init__(self, Lower=-100, Upper=100):
9
        self.Lower = Lower
10
        self.Upper = Upper
11
12
    @classmethod
13
    def function(cls):
14
        def evaluate(D, sol):
15
            val = 0.0
16
            for i in range(D):
17
                val = val + sol[i] * sol[i]
18
            return val
19
20
        return evaluate
21