Completed
Push — master ( 78c928...7bd38b )
by Grega
10s
created

Schwefel.function()   A

Complexity

Conditions 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285

1 Method

Rating   Name   Duplication   Size   Complexity  
A Schwefel.evaluate() 0 11 2
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