From 89528a184e9d9e5ad29ebede3668ea6e7d7988c2 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Thu, 17 Jun 2021 17:23:34 +1000 Subject: [PATCH] Adjust analysis scripts for Python and solver versions --- analyse_chuffed.py | 13 +++++++------ analyse_gecode.py | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/analyse_chuffed.py b/analyse_chuffed.py index 711f3b4..cda80c8 100755 --- a/analyse_chuffed.py +++ b/analyse_chuffed.py @@ -24,15 +24,15 @@ def compute_area(file, time): for line in contents: # match = re.match(r'%\sinit_area\s=\s(\d+)', line) # if match: - # objectives.append(int(match[1])) + # objectives.append(int(match.group(1))) # continue match = re.match(r"objective\s=\s(\d+)", line) if match: - objectives.append(int(match[1])) + objectives.append(int(match.group(1))) continue match = re.match(r"%\stime elapsed:\s(\d+)\sms", line) if match: - times.append(int(match[1])) + times.append(int(match.group(1))) continue times.append(time) @@ -57,14 +57,15 @@ for root, dirs, files in os.walk(folder): contents = f.readlines() statistics = {} + print(contents) for line in contents: # Nodes - match = re.search(r"nodes:\s+(\d+)", line) + match = re.search(r"nodes=(\d+)", line) if match: statistics["nodes"] = int(match.group(1)) continue # Solve time - match = re.search(r"search time:\s+(\d+\.\d+)\s*seconds", line) + match = re.search(r"solveTime=(\d+\.\d+)", line) if match: statistics["search_time"] = int(float(match.group(1)) * 1000) continue @@ -78,7 +79,7 @@ for root, dirs, files in os.walk(folder): # Best objective match = re.match(r"objective\s=\s(\d+)", line) if match: - statistics["objective"] = int(match[1]) + statistics["objective"] = int(match.group(1)) break # Area area = compute_area(contents, statistics["search_time"]) diff --git a/analyse_gecode.py b/analyse_gecode.py index 462bfcd..0a7b730 100755 --- a/analyse_gecode.py +++ b/analyse_gecode.py @@ -28,15 +28,15 @@ def compute_area(file): # continue match = re.match(r"objective\s=\s(\d+)", line) if match: - objectives.append(int(match[1])) + objectives.append(int(match.group(1))) continue - match = re.match(r"%\stime elapsed:\s(\d+)\sms", line) + match = re.match(r"%\stime elapsed:\s(\d\.\d+)\ss", line) if match: - times.append(int(match[1])) + times.append(float(match.group(1))) continue - match = re.search(r"solvetime:.*\((\d+).(\d+)\s+ms\)", line) + match = re.search(r"solveTime=(\d+(.\d+)?)", line) if match: - times.append(int(match.group(1))) + times.append(float(match.group(1))) continue assert len(objectives) > 0 @@ -47,7 +47,7 @@ def compute_area(file): return int(area) -foler = sys.argv[1] +folder = sys.argv[1] statistics = {} for root, dirs, files in os.walk(folder): for name in files: @@ -66,7 +66,7 @@ for root, dirs, files in os.walk(folder): # Best objective match = re.match(r"objective\s=\s(\d+)", line) if match: - objective = int(match[1]) + objective = int(match.group(1)) break nodes = -1 @@ -79,12 +79,12 @@ for root, dirs, files in os.walk(folder): nodes = int(match.group(1)) continue # Solve time - match = re.search(r"solvetime:.*\((\d+).(\d+)\s+ms\)", line) + match = re.search(r"solveTime=(\d+(.\d+)?)", line) if match: - solvetime = int(match.group(1)) + solvetime = float(match.group(1)) continue # Restarts - match = re.search(r"restarts:\s+(\d+)", line) + match = re.search(r"restarts=(\d+)", line) if match: restarts = int(match.group(1)) continue