This repository has been archived by the owner on May 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (46 loc) · 1.66 KB
/
main.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
import os
import argparse
from src import portal
def load_sims(list_file):
"""
Parameters
----------
list_file : str
Returns
-------
dict {str : list of str}
"""
sims = {}
with open(list_file) as f:
sims_list = f.readlines()
for line in sims_list:
if line[0] != '#':
sim_name, *params = line.split()
sims[sim_name] = params
return sims
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--simulation", nargs='+',
help="increase output verbosity", default="all")
args = parser.parse_args()
default_params = {"cat_mouse" : [10, 100, 10],
"cat_mouse_cheese" : [10, 10000, 1000],
"route_choice" : [10, 1000, 100, 10, 20, 30, 40],
"simple_migration" : [10, 10000, 5],
"migration" : [1, 100000, 3],
"wolfpack" : [10, 100, 100],
"wolfpack_reduction" : [10, 20, 20, 50],
"wolfpack_reduction_2" : [10, 20, 20, 2, 4, 50],
"wolfpack_scene": [1000, 0, 100]}
if __name__ == '__main__':
sims = {}
if args.simulation == "all":
list_file = os.path.join(os.path.dirname(__file__), 'src/sims/list.txt')
sims = load_sims(list_file)
elif args.simulation[0] in default_params:
if len(args.simulation[1:]) != len(default_params[args.simulation[0]]):
print("using default parameters...")
sims = {args.simulation[0]: default_params[args.simulation[0]]}
else:
sims = {args.simulation[0]: args.simulation[1:]}
portal.run(sims)