Passed
Push — master ( cae141...df25fa )
by Simon
01:36
created

powells_method.sphere_function()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
import numpy as np
2
3
from hyperactive import Hyperactive
4
from hyperactive.optimizers import PowellsMethod
5
6
7
def sphere_function(para):
8
    x = para["x"]
9
    y = para["y"]
10
11
    return -(x * x + y * y)
12
13
14
search_space = {
15
    "x": list(np.arange(-10, 10, 0.1)),
16
    "y": list(np.arange(-10, 10, 0.1)),
17
}
18
19
opt = PowellsMethod(
20
    iters_p_dim=20,
21
)
22
23
hyper = Hyperactive()
24
hyper.add_search(sphere_function, search_space, n_iter=1500, optimizer=opt)
25
hyper.run()
26