1 | import numpy as np |
||
2 | from hyperactive import Hyperactive |
||
3 | |||
4 | |||
5 | View Code Duplication | def ackley_function(para): |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
6 | x, y = para["x"], para["y"] |
||
7 | |||
8 | loss = ( |
||
9 | -20 * np.exp(-0.2 * np.sqrt(0.5 * (x * x + y * y))) |
||
10 | - np.exp(0.5 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y))) |
||
11 | + np.exp(1) |
||
12 | + 20 |
||
13 | ) |
||
14 | |||
15 | return -loss |
||
16 | |||
17 | |||
18 | search_space = { |
||
19 | "x": list(np.arange(-10, 10, 0.01)), |
||
20 | "y": list(np.arange(-10, 10, 0.01)), |
||
21 | } |
||
22 | |||
23 | |||
24 | hyper = Hyperactive(verbosity=False) |
||
25 | hyper.add_search(ackley_function, search_space, n_iter=30) |
||
26 | hyper.run() |
||
27 |