From 904011dd5f3b054052c745fb157aeaa752d7fa1f Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 19 Apr 2016 18:55:20 +0200 Subject: [PATCH 1/1] Add some cool versuchung --- cool.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 cool.py diff --git a/cool.py b/cool.py new file mode 100644 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) -- 2.39.5