| Total Complexity | 4 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | """Implementation of Rastrigin benchmark function.""" |
||
| 7 | class Rastrigin(object): |
||
| 8 | |||
| 9 | def __init__(self, Lower=-100, Upper=100): |
||
| 10 | self.Lower = Lower |
||
| 11 | self.Upper = Upper |
||
| 12 | |||
| 13 | @classmethod |
||
| 14 | def function(cls): |
||
| 15 | def evaluate(D, sol): |
||
| 16 | val = 0.0 |
||
| 17 | |||
| 18 | for i in range(D): |
||
| 19 | val = val + \ |
||
| 20 | math.pow(sol[i], 2) - 10 * math.cos( |
||
| 21 | 2 * math.pi * sol[i]) + 10 |
||
| 22 | |||
| 23 | return val |
||
| 24 | |||
| 25 | return evaluate |
||
| 26 |