Esempio n. 1
0
    def solve(self, assumptions=None):
        if assumptions is not None:
            cnf = []
            for a in assumptions:
                cnf += self.cnfizer.convert(a)

            missing = []
            for clause in cnf:
                if len(clause) == 1:
                    v = self._get_pico_lit(next(iter(clause)))
                    picosat.picosat_assume(self.pico, v)
                else:
                    missing.append(clause)

            if len(missing) > 0:
                self.push()
                self._add_cnf_assertion(missing)
                self.pending_pop = True

        res = picosat.picosat_sat(self.pico, -1)
        if res == picosat.PICOSAT_SATISFIABLE:
            self.latest_model = self.get_model()
            return True
        else:
            self.latest_model = None
            return False
Esempio n. 2
0
    def solve(self, assumptions=None):
        if assumptions is not None:
            cnf = []
            for a in assumptions:
                cnf += self.cnfizer.convert(a)

            missing = []
            for clause in cnf:
                if len(clause) == 1:
                    v = self._get_pico_lit(next(iter(clause)))
                    picosat.picosat_assume(self.pico, v)
                else:
                    missing.append(clause)

            if len(missing) > 0:
                self.push()
                self._add_cnf_assertion(missing)
                self.pending_pop = True

        res = picosat.picosat_sat(self.pico, -1)
        if res == picosat.PICOSAT_SATISFIABLE:
            self.latest_model = self.get_model()
            return True
        else:
            self.latest_model = None
            return False
Esempio n. 3
0
    def solve(self, assumptions=None):
        if assumptions is not None:
            self.push()
            self.add_assertion(self.mgr.And(assumptions))
            self.pending_pop = True

        res = picosat.picosat_sat(self.pico, -1)
        if res == picosat.PICOSAT_SATISFIABLE:
            self.latest_model = self.get_model()
            return True
        else:
            self.latest_model = None
            return False
 def solve(self, *ls):
     "Check satisfiability under the given assumptions."
     t1 = time.time()
     for l in ls:
         picosat.picosat_assume(self.p, l)
     r = picosat.picosat_sat(self.p, self.decision_limit)
     t2 = time.time()
     if r == picosat.PICOSAT_SATISFIABLE:
         self.last_sat_result = True
         return True
     elif r == picosat.PICOSAT_UNSATISFIABLE:
         self.last_sat_result = False
         return False
     else:
         self.last_sat_result = None
         raise TimeoutError("Picosat returned unknown.")
Esempio n. 5
0
import picosat

with open("/tmp/log", "w") as fout:
    p = picosat.picosat_init()
    picosat.picosat_set_verbosity(p, 100)
    f = picosat.picosat_set_output(p, fout)
    picosat.picosat_measure_all_calls(p)
    picosat.picosat_inc_max_var(p)
    picosat.picosat_add(p, 1)
    picosat.picosat_add(p, -1)
    picosat.picosat_add(p, 0)
    assert picosat.picosat_sat(p, -1) == picosat.PICOSAT_SATISFIABLE
    picosat.picosat_message(p, 0, "End")
    picosat.picosat_flushout(f)
    picosat.picosat_reset(p)
print("Done.")