-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_gpbo_nonoise.py
More file actions
150 lines (142 loc) · 5.71 KB
/
init_gpbo_nonoise.py
File metadata and controls
150 lines (142 loc) · 5.71 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import signac
import numpy as np
import os
import json
import bo_methods_lib
project = signac.init_project("GPBO_nonoise")
# Set Method and Case Study
gp_pack = "gpflow"
cs_val_list = [1,2,3,10,11,12,13,14,15,17] #See bo_methods_lib/bo_methods_lib/GPBO_Class_fxns.py for more details
meth_val_list = [1,2,3,4,5,6,7] # Conv, Log Conv., Ind., Log Ind., Sparse Grid, Monte Carlo, E[SSE]
# Set Initial Parameters
ep0 = 1 # Set initial ep as an even mix between exploration and exploitation
ep_enum_val = 1 #Set explotation bias to constant value
sep_fact = 1.0 #Set exploration bias init value (alpha) to 1.0
gen_heat_map_data = False #Do not generate heat map data
normalize = True #Standardize data w/ RobustScaler
noise_mean = 0 #Set noise mean to 0
noise_std = None #Set noise std to None (calculated automatically)
noise_std_pct = 0.01
kernel_enum_val = 1 #Set kernel to Matern 5/2
lenscl = None #Set lenscl to None (trainable)
sim_seed = 1 #Set seed for simulator random number generator
initial_seed = 1 # Initial seed for case study random number generator
if isinstance(lenscl, list):
lenscl = json.dumps(lenscl)
outputscl = None #Set outputscl to None (trainable)
retrain_GP = 25 #Retrain GP 25 times per iteration
reoptimize_obj = 25 #Reoptimize objective optimizations 25 times per iteration
get_y_sse = True #Get y_sse during algorithm
gen_y_w_noise = False #Generate y data without noise during algorithm
bo_iters_tot = {1: 50,
2: 75,
3: 75,
10: 50,
11: 50,
12: 50,
13: 50,
14: 50,
15: 50,
16: 50,
17: 50} #Total number of iterations
bo_runs_total = {1: 5,
2: 10,
3: 10,
10: 5,
11: 5,
12: 5,
13: 5,
14: 5,
15: 5,
16: 5,
17: 5,} #Total number of runs (restarts)
runs_per_jobs_max = {1: 2,
2: 1,
3: 1,
10: 1,
11: 1,
12: 1,
13: 1,
14: 1,
15: 1,
16: 1,
17: 1} #Number of runs per job
save_data = False #Do not save extra ei data
ei_tol = 1e-7 #Set EI tolerance to 1e-7
obj_tol = 1e-7 #Set objective tolerance to 1e-7
num_x_datas = {1: 5,
2: 5,
3: 5,
10: 5,
11: 10,
12: 10,
13: 10,
14: 5,
15: 10,
16: 10,
17: 10} #Number of x data points
gen_meth_theta = 1 #Generate parameter sets using LHS
gen_meth_x = 2 #Generate x data using a grid
gen_meth_theta_val = None #Don't generate validation data
num_val_pts = 0 #Number of validation points
num_theta_multiplier = 10 # How many simulation data points to generate is equal to num_theta_multiplier*number of parameters
# Loop over Case Studies
for cs_name_val in cs_val_list:
print("CS",cs_name_val)
bo_iter_tot = bo_iters_tot[cs_name_val]
bo_run_total = bo_runs_total[cs_name_val]
runs_per_job_max = runs_per_jobs_max[cs_name_val]
num_x_data = num_x_datas[cs_name_val]
ep_val_list = [1] #Set explotation bias to constant value
# Loop over methods
for meth_name_val in meth_val_list:
# Loop over number of runs
print("Meth:", meth_name_val)
for bo_run_num in range(1, bo_run_total + 1, runs_per_job_max):
# Note: bo_run_num is the run number of the first run in the job
# If adding the max number of runs to the run number does not exceed the max range, use it
if bo_run_num + runs_per_job_max <= bo_run_total + 1:
runs_per_job = runs_per_job_max
# Otherwise, the number of runs in the job is the difference between the range max and the run number
else:
runs_per_job = bo_run_total + 1 - bo_run_num
#Set seed is different (equal to the run) for each run for a given method and case study
cs_run_seed = int(initial_seed + (bo_run_num - 1))
# Create job parameter dict
sp = {
"cs_name_val": cs_name_val,
"meth_name_val": meth_name_val,
"gp_package": gp_pack,
"ep0": ep0,
"ep_enum_val": ep_enum_val,
"sep_fact": sep_fact,
"normalize": normalize,
"gen_heat_map_data": gen_heat_map_data,
"noise_mean": noise_mean,
"noise_std": noise_std,
"noise_std_pct": noise_std_pct,
"kernel_enum_val": kernel_enum_val,
"lenscl": lenscl,
"outputscl": outputscl,
"retrain_GP": retrain_GP,
"reoptimize_obj": reoptimize_obj,
"bo_iter_tot": bo_iter_tot,
"bo_run_tot": bo_run_total,
"bo_runs_in_job": runs_per_job,
"bo_run_num": bo_run_num,
"save_data": save_data,
"seed": cs_run_seed, #int(initial_seed + 2 * (bo_run_num - 1)),
"sim_seed": sim_seed,
"ei_tol": ei_tol,
"obj_tol": obj_tol,
"num_x_data": num_x_data,
"gen_meth_theta": gen_meth_theta,
"gen_meth_x": gen_meth_x,
"gen_meth_theta_val": gen_meth_theta_val,
"num_theta_multiplier": num_theta_multiplier,
"num_val_pts": num_val_pts,
"get_y_sse": get_y_sse,
"w_noise": gen_y_w_noise
}
# Create jobs for exploration bias study
job = project.open_job(sp).init()