Passed
Push — master ( 90fac4...b39ade )
by Grega
51s
created

Rastrigin.function()   A

Complexity

Conditions 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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

1 Method

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