]> git.siccegge.de Git - master/cool-versuchung.git/commitdiff
Add some cool versuchung
authorChristoph Egger <christoph@christoph-egger.org>
Tue, 19 Apr 2016 16:55:20 +0000 (18:55 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Tue, 19 Apr 2016 16:55:20 +0000 (18:55 +0200)
cool.py [new file with mode: 0644]

diff --git a/cool.py b/cool.py
new file mode 100644 (file)
index 0000000..1b96352
--- /dev/null
+++ b/cool.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+from versuchung.experiment import Experiment
+from versuchung.archives import TarArchive, GitArchive
+from versuchung.files import Directory
+from versuchung.execute import shell, CommandFailed
+
+import re
+import os
+
+def natural_key(string_):
+    return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]
+
+class SolverExperiment(Experiment):
+    inputs = { 'formulas' : TarArchive() }
+    outputs = { 'timing' : Directory() }
+
+    def build_solver(self):
+        pass
+
+    def run_solver(self, formula):
+        pass
+    
+    def run(self):
+        print("Building Solver ...")
+        self.build_solver()
+        formulas = sorted(os.listdir(self.inputs.formulas.path), key=natural_key)
+        shell.track(self.outputs.timing.path)
+        for formula in formulas:
+            print("Running for %s ..." % formula)
+            try:
+                self.run_solver(os.path.join(self.inputs.formulas.path, formula))
+            except CommandFailed:
+                break
+
+
+class CoolExperiment(SolverExperiment):
+    inputs = { 'cool' : GitArchive() }
+    outputs = {}
+
+    def __init__(self):
+        CoolExperiment.inputs.update(SolverExperiment.inputs)
+        CoolExperiment.outputs.update(SolverExperiment.outputs)
+        super(CoolExperiment, self).__init__()
+    
+    def build_solver(self):
+        with self.inputs.cool as path:
+            shell("make")
+
+    def run_solver(self, formula):
+        with self.inputs.cool as path:
+            shell("timeout 1001 ./coalg.native sat KD --verbose < %s" % formula)
+            
+                
+            
+if __name__ == "__main__":
+    import sys
+    experiment = CoolExperiment()
+    dirname = experiment(sys.argv)
+
+    print(dirname)