Completed
Pull Request — master (#22)
by Grega
03:00
created

Schwefel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A function() 0 15 3
A evaluate() 0 11 2
A __init__() 0 3 1
1
"""Implementation of Schwefel function."""
2
import math
3
4
__all__ = ['Schwefel']
5
6
7
class Schwefel(object):
8
9
    def __init__(self, Lower=-500, Upper=500):
10
        self.Lower = Lower
11
        self.Upper = Upper
12
13
    @classmethod
14
    def function(cls):
15
        def evaluate(D, sol):
16
17
            val = 0.0
18
            val1 = 0.0
19
20
            for i in range(D):
21
                val1 += (sol[i] * math.sin(math.sqrt(abs(sol[i]))))
22
23
            val = 418.9829 * D - val1
24
25
            return val
26
27
        return evaluate
28