···
+
from statistics import stdev
def compute_area(file, time):
···
objectives.append(int(match.group(1)))
+
match = re.match(r"%\stime elapsed:\s(\d+\.\d+)\ss", line)
+
times.append(float(match.group(1)))
+
if len(times) == len(objectives):
assert len(objectives) > 0
assert len(objectives) + 1 == len(times)
for i in range(len(objectives)):
+
area += (times[i + 1] - times[i]) * objectives[i]
+
for config in ["original", "restart"]:
+
for root, dirs, files in os.walk(folder + "/" + config):
+
if name.endswith(".sol"):
+
components = name[:-(4)].split(".")
+
if len(components) > 1:
+
assert len(components) == 2
+
if data not in statistics:
+
statistics[data] = dict()
+
if config not in statistics[data]:
+
statistics[data][config] = []
+
with open(os.path.join(root, name)) as f:
+
contents = f.readlines()
+
match = re.search(r"%%%mzn-stat: nodes=(\d+)", line)
+
nodes = int(match.group(1))
+
match = re.search(r"%%%mzn-stat: solveTime=(\d+\.\d+)", line)
+
solvetime = float(match.group(1))
+
match = re.search(r"%%%mzn-stat: restarts=(\d+)", line)
+
restarts = int(match.group(1))
+
for line in contents[::-1]:
+
match = re.match(r"%%%mzn-stat: objective=(-?\d+)", line)
+
objective = int(match.group(1))
+
area = compute_area(contents, solvetime)
+
statistics[data][config].append(
+
for config in ["original", "restart"]:
+
stats = statistics[data][config]
+
for i in range(1, len(stats)):
+
cumulative = tuple(map(sum, zip(cumulative, stats[i])))
+
avg = tuple([x / len(stats) for x in cumulative])
+
dev = stdev([x[1] for x in stats]) if len(stats) > 1 else 0
+
# (avg area, avg objective, stdev objective)
+
statistics[data][config] = (avg[0], avg[1], dev)
+
\\begin{tabular}{l|rr|rr|rr}
+
& \multicolumn{2}{c|}{Chuffed} & \multicolumn{2}{c|}{Chuffed Restart} \\\\
+
Instance & $\intobj$ & $\minobj$ & $\intobj$ & $\minobj$ \\\\
+
sorted_instances = sorted(instances)
+
for data in sorted_instances:
+
print(f"{data}", end="")
+
for config in ["original", "restart"]:
+
f" & {int(statistics[data][config][0] / 1000) }k & {int(statistics[data][config][1])}",
+
if statistics[data][config][2] != 0:
+
int(statistics[data][config][2] / statistics[data][config][1] * 100),
+
# int(statistics[data][config][2]),
+
print("\n\\bottomrule\n\end{tabular}")