Skip to content

Commit bf1b06e

Browse files
committed
add example for direct algorithm
1 parent 080e6d8 commit bf1b06e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import numpy as np
2+
3+
from hyperactive import Hyperactive
4+
from hyperactive.optimizers import DirectAlgorithm
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 = DirectAlgorithm()
20+
21+
22+
hyper = Hyperactive()
23+
hyper.add_search(sphere_function, search_space, n_iter=1500, optimizer=opt)
24+
hyper.run()

0 commit comments

Comments
 (0)