-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (39 loc) · 2.04 KB
/
main.py
File metadata and controls
53 lines (39 loc) · 2.04 KB
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
import subprocess
import sys
from generateImg import generateImage
def main():
if len(sys.argv) < 3:
print("Error : ")
print(" - first argument : instance size")
print(" - second argument : number of instance wanted")
exit(-1)
instance_size = int(sys.argv[1])
number_instance = int(sys.argv[2])
generateInstances(instance_size, number_instance)
generateFootprint(instance_size, number_instance)
print("All footprints pictures are generated in folder footprints/")
def generateInstances(instance_size, number):
bash_command = "QAPGenerators/doInstances.sh " + str(instance_size) + " " + str(number)
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
process.wait()
def generateFootprint(instance_size, number):
binary = "random_walk/build/randomWalk"
seed = "1"
walk_length = "500"
for i in range(number):
instance_file_rl = "instances/qap_rl_" + str(instance_size) + "_" + str(i) + ".dat"
output_file_rl = "random_walk/data/footprint_rl_" + str(instance_size) + "_" + str(i) + ".dat"
bash_command = str(binary) + " " + str(instance_file_rl) + " " + str(seed) + " " + str(walk_length) + " " + str(
output_file_rl)
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
process.wait()
instance_file_uni = "instances/qap_uni_" + str(instance_size) + "_" + str(i) + ".dat"
output_file_uni = "random_walk/data/footprint_uni_" + str(instance_size) + "_" + str(i) + ".dat"
bash_command_uni = str(binary) + " " + str(instance_file_uni) + " " + str(seed) + " " + str(
walk_length) + " " + str(output_file_uni)
process_uni = subprocess.Popen(bash_command_uni.split(), stdout=subprocess.PIPE)
process_uni.wait()
generateImage(output_file_uni, "footprints/fp_uni_" + str(instance_size) + "_" + str(i) + ".png")
generateImage(output_file_rl, "footprints/fp_rl_" + str(instance_size) + "_" + str(i) + ".png")
if __name__ == '__main__':
main()