-
Notifications
You must be signed in to change notification settings - Fork 0
/
optimal_experiments_BO_decorrerlated_1.py
86 lines (70 loc) · 2.45 KB
/
optimal_experiments_BO_decorrerlated_1.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
from src.utils import experiment_runner, load_file, bayes_optimal_runner
from tqdm.auto import tqdm
import numpy as np
import matplotlib.pyplot as plt
from tqdm.auto import tqdm
import src.fpeqs as fpe
from src.fpeqs_BO import var_func_BO, var_hat_func_BO_num_double_noise,var_hat_func_BO_num_decorrelated_noise
if __name__ == "__main__":
percentage, delta_small, delta_large = 0.3, 0.1, 5.0
deltas_large = [0.5, 1.0, 5.0, 10.0]
b = 0.0
percentages = [0.05, 0.1, 0.3]
dl = 5.0
p = 0.1
experiments_settings = {
"alpha_min": 0.01,
"alpha_max": 100,
"alpha_pts": 10,
"delta_small": delta_small,
"delta_large": dl,
"percentage": p,
"beta": b,
"experiment_type": "BO",
}
alpha = []
errors = []
ls = [5.0, 10.0]
for dl in tqdm(ls):
while True:
m = 0.89 * np.random.random() + 0.1
q = 0.89 * np.random.random() + 0.1
sigma = 0.89 * np.random.random() + 0.1
if np.square(m) < q + delta_small * q and np.square(m) < q + dl * q:
initial_condition = [m, q, sigma]
break
alphas_double, (errors_double,) = fpe.different_alpha_observables_fpeqs(
var_func_BO,
var_hat_func_BO_num_decorrelated_noise,
alpha_1=0.01,
alpha_2=100,
n_alpha_points=32,
initial_cond=initial_condition,
var_hat_kwargs={
"delta_small": delta_small,
"delta_large": dl,
"percentage": p,
"beta": 0.0,
},
)
alpha.append(alphas_double)
errors.append(errors_double)
# for exp_dict in tqdm(experiments_settings):
# experiment_runner(**exp_dict)
file_names = ["./BOGE epsilon 0.1 delta1 0.1 delta2 {}.npz".format(dl) for dl in ls]
for a, e, p in zip(alpha, errors, ls):
plt.plot(a, e, label="DL {}".format(p))
for dl, fn, exp_dict in zip(deltas_large, file_names, experiments_settings):
dat = np.load(fn, mmap_mode="r")
al = dat["alphas"]
err = dat["errors"]
plt.scatter(al, err, label="AMP DL {}".format(dl))
# a, e = load_file(**exp_dict)
# plt.plot(a, e, label="BO DL {}".format(dl))
plt.xscale("log")
plt.yscale("log")
plt.ylabel("gen. error")
plt.xlabel(r"$\alpha$")
plt.legend()
plt.grid()
plt.show()