convex_function   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A convex_function() 0 3 1
1
import numpy as np
2
from gradient_free_optimizers import HillClimbingOptimizer
3
4
5
def convex_function(pos_new):
6
    score = -(pos_new["x1"] * pos_new["x1"] + pos_new["x2"] * pos_new["x2"])
7
    return score
8
9
10
search_space = {
11
    "x1": np.arange(-100, 101, 0.1),
12
    "x2": np.arange(-100, 101, 0.1),
13
}
14
15
opt = HillClimbingOptimizer(search_space)
16
opt.search(convex_function, n_iter=300000)
17