-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy path_repeat_lamcts.py
More file actions
46 lines (38 loc) · 1.78 KB
/
_repeat_lamcts.py
File metadata and controls
46 lines (38 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Repeat the following paper for `LAMCTS`:
Wang, L., Fonseca, R. and Tian, Y., 2020.
Learning search space partition for black-box optimization using monte carlo tree search.
Advances in Neural Information Processing Systems, 33, pp.19511-19522.
https://arxiv.org/abs/2007.00708 (an updated version)
https://proceedings.neurips.cc/paper/2020/hash/e2ce14e81dba66dbff9cbc35ecfdb704-Abstract.html
(the original version)
Luckily our Python code could still repeat the data reported in the updated Pyton code *well*.
Therefore, we argue that its repeatability could be **well-documented**.
"""
import time
import numpy as np
from pypop7.optimizers.bo.lamcts import LAMCTS as Solver
class Levy(object):
def __init__(self, ndim):
self.ndim = ndim
def __call__(self, x):
w = 1.0 + (x - 1.0)/4.0
y = np.sin(np.pi*w[0])**2 + np.sum((w[1:self.ndim - 1] - 1.0)**2 * (
1.0 + 10.0*np.sin(np.pi*w[1:self.ndim - 1] + 1.0)**2)) + (
w[self.ndim - 1] - 1.0)**2 * (1.0 + np.sin(2.0*np.pi*w[self.ndim - 1])**2)
return y
if __name__ == '__main__':
start_run = time.time()
ndim_problem = 100
problem = {'fitness_function': Levy(ndim_problem),
'ndim_problem': ndim_problem,
'lower_boundary': -10.0*np.ones((ndim_problem,)),
'upper_boundary': 10.0*np.ones((ndim_problem,))}
options = {'seed_rng': 4,
'verbose': 1,
'saving_fitness': 10,
'max_function_evaluations': 15000}
solver = Solver(problem, options)
results = solver.optimize()
print(results)
print('*** Runtime: {:7.5e}'.format(time.time() - start_run))
# n_function_evaluations 15000: best_so_far_y 49.066