repulsing_hill_climbing_optimizer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A sphere_function() 0 5 1
1
import numpy as np
2
from gradient_free_optimizers import RepulsingHillClimbingOptimizer
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 = RepulsingHillClimbingOptimizer(
18
    search_space,
19
    epsilon=0.01,
20
    repulsion_factor=10,
21
)
22
opt.search(sphere_function, n_iter=10000)
23