···
+
from statistics import stdev
+
def compute_area(file):
+
# match = re.match(r'%\sinit_area\s=\s(\d+)', line)
# match = re.match(r'%\sinit_area\s=\s(\d+)', line)
# objectives.append(int(match[1]))
···
objectives.append(int(match.group(1)))
+
match = re.match(r"%\stime elapsed:\s(\d+\.\d+)\ss", line)
times.append(float(match.group(1)))
···
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", "replay"]:
+
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()
+
area = compute_area(contents)
+
for line in contents[::-1]:
+
match = re.match(r"objective\s=\s(\d+)", line)
+
objective = int(match.group(1))
+
match = re.search(r"copies:\s+(\d+)", line)
+
nodes = int(match.group(1))
+
match = re.search(r"solveTime=(\d+(.\d+)?)", line)
+
solvetime = float(match.group(1))
+
match = re.search(r"restarts=(\d+)", line)
+
restarts = int(match.group(1))
+
statistics[data][config].append(
+
for config in ["original", "restart", "replay"]:
+
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|}{Gecode} & \multicolumn{2}{c|}{Gecode Restart} & \multicolumn{2}{c}{Gecode Replay}\\\\
+
Instance & $\intobj$ & $\minobj$ & $\intobj$ & $\minobj$ & $\intobj$ & $\minobj$ \\\\
+
sorted_instances = sorted(instances)
+
for data in sorted_instances:
+
print(f"{data}", end="")
+
for config in ["original", "restart", "replay"]:
+
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}")