-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch.py
74 lines (71 loc) · 1.98 KB
/
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
63
64
65
66
67
68
69
70
71
72
73
74
import os
import json
import subprocess
python_ver = "python3.11"
rep_seeds = [0, 1, 2]
default_config = {
"name": "default",
"prey": [500, 500],
"toxicity": [0.9, 0.0],
"predator": 100,
"genes": 10,
"generations": 1000,
"mutation_rate": 0.05,
"mutation_scale": 0.05,
"initial_scale": 0.1,
"seed": 0,
"cmap": "rainbow",
}
configs = [default_config | c for c in json.loads(open("./batch-config.json").read())]
for config in configs:
for s in rep_seeds:
config["seed"] = s
print(config)
if (
os.path.exists(
os.path.join("fig", config["name"] + f"_S{s}", "Population.mp4")
)
and os.path.exists(
os.path.join("fig", config["name"] + f"_S{s}", "Distance.mp4")
)
and not config.get("force", False)
):
print("Output directory exists, skipping")
continue
subprocess.call(
[
python_ver,
"simulate.py",
"-P",
*map(str, config["prey"]),
"-T",
*map(str, config["toxicity"]),
"-H",
str(config["predator"]),
"-G",
str(config["genes"]),
"-N",
str(config["generations"]),
"-R",
str(config["mutation_rate"]),
"-K",
str(config["mutation_scale"]),
"-I",
str(config["initial_scale"]),
"-S",
str(config["seed"]),
"-C",
config["cmap"],
"-O",
os.path.join("fig", config["name"] + f"_S{s}"),
]
)
subprocess.call(
[
python_ver,
"post-process.py",
"-F",
"-D",
os.path.join("fig", config["name"] + f"_S{s}"),
]
)