Skip to content

Commit

Permalink
Add script to generate pkl list
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisyeh96 committed Mar 28, 2024
1 parent a1516a2 commit 9feacb7
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions generate_pkl_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""Creates list of resulting pkl files used in IEEE TSG paper.
Usage:
python generate_pkl_list.py
zip -9 linear_out.zip -@ < pkl_list_linear.txt
zip -9 nonlinear_out.zip -@ < pkl_list_nonlinear.txt
The first command
python generate_pkl_list.py
run this script, which creates two text files, pkl_list_linear.txt and
pkl_list_nonlinear.txt, containing all of the paths to .pkl experiment result
files from the IEEE TSG paper.
The second and third commands
zip -9 linear_out.zip -@ < pkl_list_linear.txt
zip -9 nonlinear_out.zip -@ < pkl_list_nonlinear.txt
creates corresponding zip files of all the .pkl files listed in pkl_list_linear.txt
and pkl_list_nonlinear.txt. The -9 option uses the maximum compression rate.
"""

from glob import glob


# ========== linear simulations ==========

pkl_paths = [
'out/CBCconst_20230809_234150.pkl', # fixed X̂, fixed etahat
'out/CBCconst_δ20_η10_20230810_011115.pkl', # fixed X̂, learned etahat
]

linear_pkl_globs = [
# known eta
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
'out/CBCproj_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',

# default δ=20
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',

# varying δ
'out/CBCproj_δ1_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
'out/CBCproj_δ100_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
'out/CBCproj_δ500_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',

# topology change
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_topochange_2*.pkl',
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_topochange_2*.pkl',
'out/CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_topochange_2*.pkl',
]

for search_path in linear_pkl_globs:
for seed in [8, 9, 10, 11]:
results = glob(search_path.format(seed=seed))
num_results = len(results)
if num_results == 0:
print('did not find', search_path.format(seed=seed))
else:
assert num_results == 1
pkl_paths.append(results[0])

with open('pkl_list_linear.txt', 'w') as f:
f.write('\n'.join(pkl_paths))


# ========== nonlinear simulations ==========

outdir = 'out/nonlinear/'

pkl_paths = [
outdir + 'CBCconst_20230810_130611.pkl', # fixed X̂, fixed etahat
outdir + 'CBCconst_δ20_η10_20230810_130842.pkl', # fixed X̂, learned etahat
]

nonlinear_pkl_globs = [
# default δ=20
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_2*.pkl',
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knowntopo14_2*.pkl',
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',

# varying δ
outdir + 'CBCproj_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
outdir + 'CBCproj_δ1_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
outdir + 'CBCproj_δ100_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',
outdir + 'CBCproj_δ500_η10_noise1.0_perm_norm1.0_seed{seed}_knownlines14_2*.pkl',

# partial control
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_partialctrl_2*.pkl',
outdir + 'CBCproj_δ20_η10_noise1.0_perm_norm1.0_seed{seed}_partialctrl_knownlines14_2*.pkl',
]

for search_path in nonlinear_pkl_globs:
for seed in [8, 9, 10, 11]:
results = glob(search_path.format(seed=seed))
num_results = len(results)
if num_results == 0:
print('did not find', search_path.format(seed=seed))
else:
assert num_results == 1
pkl_paths.append(results[0])


with open('pkl_list_nonlinear.txt', 'w') as f:
f.write('\n'.join(pkl_paths))

0 comments on commit 9feacb7

Please sign in to comment.