Beispiel #1
0
 private void testCC(int numLits, int rhs, int expected, final FormulaFactory f) {
   final Variable[] problemLits = new Variable[numLits];
   for (int i = 0; i < numLits; i++) problemLits[i] = f.variable("v" + i);
   final SATSolver solver = MiniSat.miniSat(f);
   solver.add(f.cc(CType.GE, rhs, problemLits));
   if (expected != 0) Assert.assertEquals(Tristate.TRUE, solver.sat());
   else Assert.assertEquals(Tristate.FALSE, solver.sat());
   final List<Assignment> models =
       solver.enumerateAllModels(problemLits, new NumberOfModelsHandler(12000));
   Assert.assertEquals(expected, models.size());
   for (final Assignment model : models) Assert.assertTrue(model.positiveLiterals().size() >= rhs);
 }
Beispiel #2
0
 @Override
 public UNSATCore computeMUS(
     List<Proposition> propositions, final FormulaFactory f, final MUSConfig config) {
   final List<Proposition> mus = new ArrayList<>(propositions.size());
   final List<SolverState> solverStates = new ArrayList<>(propositions.size());
   final MiniSat solver = MiniSat.miniSat(f);
   for (final Proposition proposition : propositions) {
     solverStates.add(solver.saveState());
     solver.add(proposition);
   }
   if (solver.sat() != Tristate.FALSE)
     throw new IllegalArgumentException("Cannot compute a MUS for a satisfiable formula set.");
   for (int i = solverStates.size() - 1; i >= 0; i--) {
     solver.loadState(solverStates.get(i));
     for (final Proposition prop : mus) solver.add(prop);
     if (solver.sat() == Tristate.TRUE) mus.add(propositions.get(i));
   }
   return new UNSATCore(mus, true);
 }