Skip to content

Commit 9feacb7

Browse files
committed
Add script to generate pkl list
1 parent a1516a2 commit 9feacb7

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

generate_pkl_list.py

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
"""Creates list of resulting pkl files used in IEEE TSG paper.
2+
3+
Usage:
4+
python generate_pkl_list.py
5+
zip -9 linear_out.zip -@ < pkl_list_linear.txt
6+
zip -9 nonlinear_out.zip -@ < pkl_list_nonlinear.txt
7+
8+
The first command
9+
python generate_pkl_list.py
10+
run this script, which creates two text files, pkl_list_linear.txt and
11+
pkl_list_nonlinear.txt, containing all of the paths to .pkl experiment result
12+
files from the IEEE TSG paper.
13+
14+
The second and third commands
15+
zip -9 linear_out.zip -@ < pkl_list_linear.txt
16+
zip -9 nonlinear_out.zip -@ < pkl_list_nonlinear.txt
17+
creates corresponding zip files of all the .pkl files listed in pkl_list_linear.txt
18+
and pkl_list_nonlinear.txt. The -9 option uses the maximum compression rate.
19+
"""
20+
21+
from glob import glob
22+
23+
24+
# ========== linear simulations ==========
25+
26+
pkl_paths = [
27+
'out/CBCconst_20230809_234150.pkl', # fixed X̂, fixed etahat
28+
'out/CBCconst_δ20_η10_20230810_011115.pkl', # fixed X̂, learned etahat
29+
]
30+
31+
linear_pkl_globs = [
32+
# known eta
33+
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
34+
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
35+
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
36+
37+
# default δ=20
38+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
39+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
40+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
41+
42+
# varying δ
43+
'out/CBCproj_δ1_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
44+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
45+
'out/CBCproj_δ100_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
46+
'out/CBCproj_δ500_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
47+
48+
# topology change
49+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_topochange_2*.pkl',
50+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_topochange_2*.pkl',
51+
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_topochange_2*.pkl',
52+
]
53+
54+
for search_path in linear_pkl_globs:
55+
for seed in [8, 9, 10, 11]:
56+
results = glob(search_path.format(seed=seed))
57+
num_results = len(results)
58+
if num_results == 0:
59+
print('did not find', search_path.format(seed=seed))
60+
else:
61+
assert num_results == 1
62+
pkl_paths.append(results[0])
63+
64+
with open('pkl_list_linear.txt', 'w') as f:
65+
f.write('\n'.join(pkl_paths))
66+
67+
68+
# ========== nonlinear simulations ==========
69+
70+
outdir = 'out/nonlinear/'
71+
72+
pkl_paths = [
73+
outdir + 'CBCconst_20230810_130611.pkl', # fixed X̂, fixed etahat
74+
outdir + 'CBCconst_δ20_η10_20230810_130842.pkl', # fixed X̂, learned etahat
75+
]
76+
77+
nonlinear_pkl_globs = [
78+
# default δ=20
79+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
80+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
81+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
82+
83+
# varying δ
84+
outdir + 'CBCproj_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
85+
outdir + 'CBCproj_δ1_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
86+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
87+
outdir + 'CBCproj_δ100_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
88+
outdir + 'CBCproj_δ500_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
89+
90+
# partial control
91+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_partialctrl_2*.pkl',
92+
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_partialctrl_knownlines14_2*.pkl',
93+
]
94+
95+
for search_path in nonlinear_pkl_globs:
96+
for seed in [8, 9, 10, 11]:
97+
results = glob(search_path.format(seed=seed))
98+
num_results = len(results)
99+
if num_results == 0:
100+
print('did not find', search_path.format(seed=seed))
101+
else:
102+
assert num_results == 1
103+
pkl_paths.append(results[0])
104+
105+
106+
with open('pkl_list_nonlinear.txt', 'w') as f:
107+
f.write('\n'.join(pkl_paths))

0 commit comments

Comments
 (0)