-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_batch.py
62 lines (52 loc) · 1.74 KB
/
run_batch.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
"""
Runs multiple GAs on params values
"""
import fnmatch
import os
from datetime import datetime
import generate_models
from Parameters import Parameters
from main import run_ga
import multiprocessing as mp
import argparse
def _apply_fun(x):
# fname, ranseed, novmeth
run_ga(x[0], x[1], x[2])
def main():
data = []
pool = mp.Pool(mp.cpu_count()-1)
start_time = datetime.now()
seeds = [7]
methods = ["multi_log_genotype"]
files = [
# {"name": "input", "sep": ""},
# {"name": "input2", "sep": ""},
# {"name": "irish", "sep": " "},
{"name": "bicinia", "sep": " "},
{"name": "all_irish-notes_and_durations-abc", "sep": " "},
{"name": "all_songs_in_G", "sep": ""}, # generated only for seed = 7
]
# file name and separator
for fl in files:
# seed for random
for rs in seeds:
# # generate input models
# for mkv_thr in [0.75,0.85]:
# for fc_thr in [1.0, 1.2]:
# for fc_n_ctx in [3,4,5]:
# for fc_seg_lvl in [2,3,4]:
# pars = Parameters(mkv_thr, fc_thr, fc_n_ctx, fc_seg_lvl)
# generate_models.create(fl["name"], fl["sep"], rs, pars)
# novelty method for each model
# read models/README
for fn in fnmatch.filter(os.listdir("data/models/"), fl["name"] + "_" + str(rs) + "_*"):
for nov_method in methods:
data.append([fn, rs, nov_method])
#
# # multiprocessing
pool.map(_apply_fun, data)
pool.close()
pool.join()
print("batch time elapsed :", (datetime.now() - start_time).total_seconds(), "sec.")
if __name__ == "__main__":
main()