Passed
Push — master ( f1efe4...304ef3 )
by Simon
01:35
created

direct_algorithm.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
from gradient_free_optimizers import DirectAlgorithm
3
4
5
def sphere_function(para):
6
    x = para["x"]
7
    y = para["y"]
8
9
    return -(x * x + y * y)
10
11
12
search_space = {
13
    "x": np.arange(-10, 10, 0.1),
14
    "y": np.arange(-10, 10, 0.1),
15
}
16
17
opt = DirectAlgorithm(search_space)
18
opt.search(sphere_function, n_iter=300)
19