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

Schwefel.evaluate()   A

Complexity

Conditions 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
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