Passed
Push — master ( d03f6d...d5da96 )
by Simon
01:24
created

himmelblau_function_example.himmelblau()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
import numpy as np
2
from hyperactive import Hyperactive
3
4
5
def himmelblau(para, X, y):
6
    """Himmelblau's function"""
7
8
    return -(
9
        (para["x"] ** 2 + para["y"] - 11) ** 2 + (para["x"] + para["y"] ** 2 - 7) ** 2
10
    )
11
12
13
x_range = np.arange(0, 10, 0.1)
14
15
search_config = {himmelblau: {"x": x_range, "y": x_range}}
16
17
opt = Hyperactive(0, 0, memory=None)
18
opt.search(search_config, n_iter=1000000)
19