Skip to content

Commit 4bf4857

Browse files
committed
added optimization param
1 parent fedaf9a commit 4bf4857

2 files changed

Lines changed: 31 additions & 30 deletions

File tree

sample_script.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""This is a sample script to run eisd with our local data."""
22
import numpy as np
3-
np.random.seed(90)
3+
np.random.seed(91)
44
import os
55

66
from eisd.utils import meta_data
@@ -19,7 +19,7 @@
1919
# - all: optimize on all experimental observables together
2020
# - single: optimize on individual experimental observable
2121
# - dual: optimize on pairs of experimental observables
22-
run_mode = 'dual'
22+
run_mode = 'all'
2323

2424
# read files
2525
filenames = meta_data(data_path)
@@ -28,34 +28,31 @@
2828

2929
# run_mode: all
3030
if run_mode == 'all':
31-
abs_output = "newrun/unfolded/all"
31+
abs_output = "newrun/unfolded/all_unoptimized"
3232
if not os.path.exists(abs_output):
3333
os.makedirs(abs_output)
3434

35-
output_file = os.path.join(abs_output, 'drksh3_folded_trades_all.txt')
36-
main(exp_data, bc_data, epochs=250, mode='all', output_file=output_file, verbose=True)
35+
# main(exp_data, bc_data, epochs=1000, mode='all', optimization=True, output_dir=abs_output, verbose=False)
36+
main(exp_data, bc_data, epochs=1000, mode='all', optimization=False, output_dir=abs_output, verbose=False)
3737

3838
# run_mode: dual
3939
elif run_mode == 'dual':
40-
abs_output = "newrun/unfolded/dual_mode"
41-
if not os.path.exists(abs_output):
42-
os.makedirs(abs_output)
43-
4440
# pairs = make_pairs()
4541
# pairs = [['saxs', 'jc'],['cs', 'jc'], ['fret', 'jc'],['jc', 'noe'],['jc', 'pre'],['jc', 'rdc'],['jc', 'rh']]
4642
pairs = [['saxs', 'noe'], ['cs', 'noe'], ['cs', 'pre'], ['cs', 'rdc'],['fret', 'noe'], ['noe', 'pre'], ['noe', 'rdc']]
47-
for pair in pairs[4:]:
48-
output_file = os.path.join(abs_output, "drksh3_unfolded_trades_%s_%s.txt"%(pair[0], pair[1]))
49-
main(exp_data, bc_data, epochs=1000, mode=pair, output_file=output_file, verbose=False)
43+
for pair in pairs:
44+
abs_output = "temp/unfolded/dual_mode/%s_%s"%(pair[0], pair[1])
45+
if not os.path.exists(abs_output):
46+
os.makedirs(abs_output)
47+
main(exp_data, bc_data, epochs=1000, mode=pair, output_dir=abs_output, verbose=False)
5048

5149
# run_mode: single
5250
elif run_mode == 'single':
53-
abs_output = "newrun/unfolded/single_mode"
54-
if not os.path.exists(abs_output):
55-
os.makedirs(abs_output)
56-
5751
# single_modes = ['saxs', 'cs', 'fret', 'jc', 'noe', 'pre', 'rdc', 'rh']
5852
single_modes = ['jc']
5953
for mode in single_modes:
60-
output_file = os.path.join(abs_output, "drksh3_unfolded_trades_%s.txt"%mode)
61-
main(exp_data, bc_data, epochs=1000, mode=mode, output_file=output_file, verbose=True)
54+
abs_output = "newrun/unfolded/single_mode/%s"%mode
55+
if not os.path.exists(abs_output):
56+
os.makedirs(abs_output)
57+
58+
main(exp_data, bc_data, epochs=1000, mode=mode, output_dir=abs_output, verbose=True)

script/eisdshell

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ parser.add_argument(
4949
required=True,
5050
help="The path to the output directory. It will be created if it doesn't exist.")
5151

52+
parser.add_argument(
53+
'-opt',
54+
"--optimization",
55+
type=bool,
56+
required=False,
57+
default=True,
58+
help="True if the optimization is required. The value is True by default.")
5259

5360

5461
# define arguments
@@ -58,7 +65,10 @@ run_mode = args.mode
5865
structure = args.structure
5966
epochs = args.epochs
6067
abs_output = args.output
68+
optimization = args.optimization
6169

70+
if not os.path.exists(abs_output):
71+
os.makedirs(abs_output)
6272

6373
# read data and structure files
6474
filenames = meta_data(data_path)
@@ -67,27 +77,21 @@ bc_data = read_data(filenames[structure], mode=structure)
6777

6878
# all
6979
if run_mode == 'all':
70-
if not os.path.exists(abs_output):
71-
os.makedirs(abs_output)
7280

73-
output_file = os.path.join(abs_output, '%s_%s.txt'%(structure, run_mode))
74-
main(exp_data, bc_data, epochs=epochs, mode='all', output_file=output_file, verbose=True)
81+
output_dir = os.path.join(abs_output, '%s_%s'%(structure, run_mode))
82+
main(exp_data, bc_data, epochs=epochs, mode='all', optimization=optimization, output_dir=output_dir, verbose=True)
7583

7684
# dual mode
7785
elif run_mode == 'dual':
78-
if not os.path.exists(abs_output):
79-
os.makedirs(abs_output)
8086

8187
pairs = make_pairs()
8288
for pair in pairs:
83-
output_file = os.path.join(abs_output, "%s_%s_%s_%s.txt"%(structure, run_mode, pair[0], pair[1]))
84-
main(exp_data, bc_data, epochs=epochs, mode=pair, output_file=output_file, verbose=True)
89+
output_dir = os.path.join(abs_output, "%s_%s_%s_%s"%(structure, run_mode, pair[0], pair[1]))
90+
main(exp_data, bc_data, epochs=epochs, mode=pair, output_dir=output_dir, verbose=True)
8591

8692
# single mode
8793
elif run_mode == 'single':
88-
if not os.path.exists(abs_output):
89-
os.makedirs(abs_output)
9094

9195
for mode in ['saxs', 'cs', 'fret', 'jc', 'noe', 'pre', 'rdc', 'rh']:
92-
output_file = os.path.join(abs_output, "%s_%s_%s.txt"%(structure, run_mode, mode))
93-
main(exp_data, bc_data, epochs=epochs, mode=mode, output_file=output_file, verbose=True)
96+
output_dir = os.path.join(abs_output, "%s_%s_%s"%(structure, run_mode, mode))
97+
main(exp_data, bc_data, epochs=epochs, mode=mode, output_dir=output_dir, verbose=True)

0 commit comments

Comments
 (0)