Пример #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
Пример #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
 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.")