ackley_function()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 11
Ratio 91.67 %

Importance

Changes 0
Metric Value
eloc 8
dl 11
loc 12
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
"""Test module for non-verbose output functionality."""
2
3
import numpy as np
4
5
from hyperactive import Hyperactive
6
7
8 View Code Duplication
def ackley_function(para):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9
    """Ackley optimization function for testing."""
10
    x, y = para["x"], para["y"]
11
12
    loss = (
13
        -20 * np.exp(-0.2 * np.sqrt(0.5 * (x * x + y * y)))
14
        - np.exp(0.5 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y)))
15
        + np.exp(1)
16
        + 20
17
    )
18
19
    return -loss
20
21
22
search_space = {
23
    "x": list(np.arange(-10, 10, 0.01)),
24
    "y": list(np.arange(-10, 10, 0.01)),
25
}
26
27
28
hyper = Hyperactive(verbosity=False)
29
hyper.add_search(ackley_function, search_space, n_iter=30, memory=True)
30
hyper.run()
31