-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathgraphicate_test.py
53 lines (41 loc) · 1.33 KB
/
graphicate_test.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
#!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np
import csv
import sys, getopt
def main(argv):
# Input test file
inputfile = ''
try:
opts, args = getopt.getopt(argv, "f:", ["file="])
except getopt.GetoptError:
print("test.py -f --file <testfile>")
sys.exit(2)
for opt, arg in opts:
if opt in ("-f", "--file"):
inputfile = arg
reward = []
penalty = []
sReward = []
hReward = []
hPenalty = []
# Retrieve variables from csv
with open(inputfile) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
tmp = row[3].split()
reward.append(float(tmp[1]))
tmp = row[4].split()
penalty.append(float(tmp[1]))
tmp = row[6].split()
sReward.append(float(tmp[1]))
tmp = row[8].split()
hReward.append(float(tmp[1]))
tmp = row[9].split()
hPenalty.append(float(tmp[1]))
assert len(reward) == len(sReward) == len(hReward)
print("No Error agent: {}".format(np.count_nonzero(penalty)))
print("No Error solver: {}".format(len(sReward) - np.count_nonzero(sReward)))
print("No Error heuristic: {}".format(np.count_nonzero(hPenalty)))
if __name__ == "__main__":
main(sys.argv[1:])