Exemple #1
0
    def run_minisat(self):
        child = subprocess.Popen(["minisat", self.CNF_fname, "results.txt"],
                                 stdout=subprocess.PIPE)
        child.wait()
        # 10 is SAT, 20 is UNSAT
        if child.returncode == 20:
            os.remove("results.txt")
            return None

        if child.returncode != 10:
            print("(minisat) unknown retcode: ", child.returncode)
            exit(0)

        #print "minisat done"
        t = my_utils.read_lines_from_file("results.txt")[1].split(" ")
        # remove last "variable", which is 0
        assert t[-1] == '0'
        t = t[:-1]
        # there was a time whan $t$ list was returned as solution!
        # now it's dict
        solution = {}
        for i in t:
            if i.startswith("-"):
                solution[-int(i)] = False
            else:
                solution[int(i)] = True

        os.remove("results.txt")

        return solution
Exemple #2
0
def run_minisat(CNF_fname):
    child = subprocess.Popen(["minisat", CNF_fname, "results.txt"],
                             stdout=subprocess.PIPE)
    child.wait()
    # 10 is SAT, 20 is UNSAT
    if child.returncode == 20:
        os.remove("results.txt")
        return None

    if child.returncode != 10:
        print("(minisat) unknown retcode: ", child.returncode)
        exit(0)

    solution = my_utils.read_lines_from_file("results.txt")[1].split(" ")
    os.remove("results.txt")

    return solution
    def run_minisat (self):
        child = subprocess.Popen(["minisat", self.CNF_fname, "results.txt"], stdout=subprocess.PIPE)
        child.wait()
        # 10 is SAT, 20 is UNSAT
        if child.returncode==20:
            os.remove ("results.txt")
            return None

        if child.returncode!=10:
            print ("(minisat) unknown retcode: ", child.returncode)
            exit(0)

        solution=my_utils.read_lines_from_file("results.txt")[1].split(" ")
        # remove last "variable", which is 0
        assert solution[-1]=='0'
        solution=solution[:-1]
        os.remove ("results.txt")

        return solution