-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshy_shgo.py
More file actions
31 lines (26 loc) · 984 Bytes
/
shy_shgo.py
File metadata and controls
31 lines (26 loc) · 984 Bytes
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
from embarrassingly.shy import Shy, slow_and_pointless
from scipy.optimize import shgo
import matplotlib.pyplot as plt
labels = list()
bounds = [(-0.5, 0.5), (-0.5, 0.5)]
# See https://www.microprediction.com/blog/robust-optimization for explanation
def rround(x,ndigits):
try:
return str(round(x,ndigits=ndigits))
except:
return ''
for t_unit in [None, 0.2, 0.3, 0.4]:
for d_unit in [None, 0.01, 0.02, 0.03]:
SAP = Shy(slow_and_pointless, bounds=bounds, t_unit=t_unit, d_unit=d_unit)
res = shgo(func=SAP, bounds=bounds, n=10, iters=4, options={'minimize_every_iter': False, 'ftol': 0.00001})
plt.plot(SAP.found_tau, SAP.found_y)
plt.xlabel('CPU Time')
plt.ylabel('Minimum')
plt.yscale('log')
plt.pause(0.00001)
label = "$\delta t="+rround(t_unit,4)+'$ $\delta d='+rround(d_unit,3)+'$'
labels.append(label)
plt.legend(labels)
plt.pause(0.00001)
pass
pass