-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy path_repeat_shade.py
More file actions
73 lines (65 loc) · 3.02 KB
/
_repeat_shade.py
File metadata and controls
73 lines (65 loc) · 3.02 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Repeat the following paper for `SHADE`:
Tanabe, R. and Fukunaga, A., 2013, June.
Success-history based parameter adaptation for differential evolution.
In IEEE Congress on Evolutionary Computation (pp. 71-78). IEEE.
https://ieeexplore.ieee.org/document/6557555
Luckily our Python code could repeat the data reported in the original paper *well*.
Therefore, we argue that its repeatability could be **well-documented**.
"""
import numpy as np
from pypop7.benchmarks.base_functions import sphere, ellipsoid, cigar, discus
from pypop7.optimizers.de.shade import SHADE
if __name__ == '__main__':
ndim_problem = 30
problem = {'fitness_function': sphere,
'ndim_problem': ndim_problem,
'lower_boundary': -100*np.ones((ndim_problem,)),
'upper_boundary': 100*np.ones((ndim_problem,))}
options = {'max_function_evaluations': ndim_problem*10000,
'n_individuals': 100,
'seed_rng': 0, # undefined in the original paper
'fitness_threshold': 1e-8}
shade = SHADE(problem, options)
results = shade.optimize()
print(results)
print(results['best_so_far_y'])
# 8.957042714361382e-09 vs 0.00e+00 (from the original paper)
problem = {'fitness_function': ellipsoid,
'ndim_problem': ndim_problem,
'lower_boundary': -100*np.ones((ndim_problem,)),
'upper_boundary': 100*np.ones((ndim_problem,))}
options = {'max_function_evaluations': ndim_problem*10000,
'n_individuals': 100,
'seed_rng': 0, # undefined in the original paper
'fitness_threshold': 1e-8}
shade = SHADE(problem, options)
results = shade.optimize()
print(results)
print(results['best_so_far_y'])
# 9.642985936066791e-09 vs 9.00e+03 (from the original paper)
problem = {'fitness_function': cigar,
'ndim_problem': ndim_problem,
'lower_boundary': -100*np.ones((ndim_problem,)),
'upper_boundary': 100*np.ones((ndim_problem,))}
options = {'max_function_evaluations': ndim_problem*10000,
'n_individuals': 100,
'seed_rng': 0, # undefined in the original paper
'fitness_threshold': 1e-8}
shade = SHADE(problem, options)
results = shade.optimize()
print(results)
print(results['best_so_far_y'])
# 8.657677766913165e-09 vs 4.02e+01 (from the original paper)
problem = {'fitness_function': discus,
'ndim_problem': ndim_problem,
'lower_boundary': -100*np.ones((ndim_problem,)),
'upper_boundary': 100*np.ones((ndim_problem,))}
options = {'max_function_evaluations': ndim_problem*10000,
'n_individuals': 100,
'seed_rng': 0, # undefined in the original paper
'fitness_threshold': 1e-8}
shade = SHADE(problem, options)
results = shade.optimize()
print(results)
print(results['best_so_far_y'])
# 9.982659193421452e-09 vs 1.92e-04 (from the original paper)