···
def compute_area(file, time):
···
# objectives.append(int(match[1]))
28
-
match = re.match(r'objective\s=\s(\d+)', line)
29
+
match = re.match(r"objective\s=\s(\d+)", line)
objectives.append(int(match[1]))
32
-
match = re.match(r'%\stime elapsed:\s(\d+)\sms', line)
33
+
match = re.match(r"%\stime elapsed:\s(\d+)\sms", line)
times.append(int(match[1]))
38
-
assert(len(objectives) > 0)
39
-
assert(len(objectives)+1 == len(times))
39
+
assert len(objectives) > 0
40
+
assert len(objectives) + 1 == len(times)
for i in range(len(objectives)):
42
-
area += ((times[i+1] - times[i])/1000)*objectives[i]
43
+
area += ((times[i + 1] - times[i]) / 1000) * objectives[i]
for root, dirs, files in os.walk(folder):
49
-
if name.endswith('.sol'):
51
+
if name.endswith(".sol"):
match = re.search(r"\.(\d+)\.sol", name)
···
match = re.search(r"nodes:\s+(\d+)", line)
62
-
statistics['nodes'] = int(match.group(1))
64
+
statistics["nodes"] = int(match.group(1))
match = re.search(r"search time:\s+(\d+\.\d+)\s*seconds", line)
67
-
statistics['search_time'] = int(float(match.group(1))*1000)
69
+
statistics["search_time"] = int(float(match.group(1)) * 1000)
match = re.search(r"restart count:\s+(\d+)", line)
72
-
statistics['restarts'] = int(match.group(1))
74
+
statistics["restarts"] = int(match.group(1))
for line in contents[::-1]:
77
-
match = re.match(r'objective\s=\s(\d+)', line)
79
+
match = re.match(r"objective\s=\s(\d+)", line)
79
-
statistics['objective'] = int(match[1])
81
+
statistics["objective"] = int(match[1])
82
-
area = compute_area(contents, statistics['search_time'])
84
+
area = compute_area(contents, statistics["search_time"])
84
-
stats[name[:-(4)].replace(".", ",")] = (area, statistics['objective'], statistics['search_time'], statistics['restarts'], statistics['nodes'])
86
+
stats[name[:-(4)].replace(".", ",")] = (
88
+
statistics["objective"],
89
+
statistics["search_time"],
90
+
statistics["restarts"],
91
+
statistics["nodes"],
sorted_stats = sorted(stats.items())
87
-
a = sorted_stats[0][0][:sorted_stats[0][0].find(",")]
95
+
a = sorted_stats[0][0][: sorted_stats[0][0].find(",")]
for key, val in sorted_stats:
89
-
if key[:key.find(",")] != a:
97
+
if key[: key.find(",")] != a:
91
-
a = key[:key.find(",")]
99
+
a = key[: key.find(",")]
print("%s,%s" % (key, ",".join([v.__str__() for v in val])))