Package kodkod.engine.satlab

Examples of kodkod.engine.satlab.SATSolver


   * @param translation the translation
   * @param stats translation / solving stats
   * @return the result of solving an unsat formula.
   */
  private static Solution unsat(Translation translation, Statistics stats) {
    final SATSolver cnf = translation.cnf();
    final TranslationLog log = translation.log();
    if (cnf instanceof SATProver && log != null) {
      return Solution.unsatisfiable(stats, new ResolutionBasedProof((SATProver) cnf, log));
    } else { // can free memory
      final Solution sol = Solution.unsatisfiable(stats, null);
      cnf.free();
      return sol;
    }
  }
View Full Code Here


     * the  current solution from the set of possible solutions
     * @return current solution
     */
    private Solution nonTrivialSolution() {
      try {
        final SATSolver cnf = translation.cnf();
        options.reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses());
        final long startSolve = System.currentTimeMillis();
        final boolean isSat = cnf.solve();
        final long endSolve = System.currentTimeMillis();

        final Statistics stats = new Statistics(translation, translTime, endSolve - startSolve);
        if (isSat) {
          // extract the current solution; can't use the sat(..) method because it frees the sat solver
          final Solution sol = Solution.satisfiable(stats, padInstance(translation.interpret(), bounds));
          // add the negation of the current model to the solver
          final int primary = translation.numPrimaryVariables();
          final int[] notModel = new int[primary];
          for(int i = 1; i <= primary; i++) {
            notModel[i-1] = cnf.valueOf(i) ? -i : i;
          }
          cnf.addClause(notModel);
          return sol;
        } else {
          formula = null; bounds = null; // unsat, no more solutions, free up some space
          return unsat(translation, stats);
        }
View Full Code Here

   * @return Translation constructed from a SAT solver initialized with the CNF translation
   * of the given circuit, the provided arguments, this.bounds, and this.log
   */
  private Translation toCNF(BooleanFormula circuit, int primaryVars, Map<Relation,IntSet> varUsage) { 
    options.reporter().translatingToCNF(circuit);
    final SATSolver cnf = Bool2CNFTranslator.translate((BooleanFormula)circuit, options.solver(), primaryVars);
    return new Translation(cnf, bounds, varUsage, primaryVars, log);
  }
View Full Code Here

   * allocated during translation from FOL to boolean.
   * @return a SATSolver instance returned by the given factory and initialized
   * to contain the CNF translation of the given circuit.
   */
  static SATSolver translate(BooleanFormula circuit, SATFactory factory, int numPrimaryVariables) {
    final SATSolver solver = factory.instance();
    final Bool2CNFTranslator translator = new Bool2CNFTranslator(solver, numPrimaryVariables, circuit);
//    System.out.println("--------------transls2-------------");
    if (circuit.op()==Operator.AND) {
      for(BooleanFormula input : circuit) {
//        System.out.println(input);
//        solver.addClause(input.accept(translator,null));
        input.accept(translator, null);
      }
      for(BooleanFormula input : circuit) {
        translator.unaryClause[0] = input.label();
        solver.addClause(translator.unaryClause);
      }
    } else {
      solver.addClause(circuit.accept(translator,null));
    }
    return solver;
  }
View Full Code Here

    try {   
   
      final Translation translation = Translator.translate(formula, bounds, options);
      final long endTransl = System.currentTimeMillis();

      final SATSolver cnf = translation.cnf();
     
      options.reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses());
      final long startSolve = System.currentTimeMillis();
      final boolean isSat = cnf.solve();
      final long endSolve = System.currentTimeMillis();

      final Statistics stats = new Statistics(translation, endTransl - startTransl, endSolve - startSolve);
      return isSat ? sat(bounds, translation, stats) : unsat(translation, stats);
     
View Full Code Here

TOP

Related Classes of kodkod.engine.satlab.SATSolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.