示例#1
0
/*
 * Bounded search: search until the conflict bound is reached
 * or until the problem is solved.
 * - reduce_threshold: number of learned clauses above which reduce_clause_database is called
 * - r_factor = increment factor for reduce threshold
 */
static void sat_search(smt_core_t *core, uint32_t conflict_bound, uint32_t *reduce_threshold, double r_factor) {
  uint64_t max_conflicts;
  uint32_t r_threshold;
  literal_t l;

  assert(smt_status(core) == STATUS_SEARCHING || smt_status(core) == STATUS_INTERRUPTED);

  max_conflicts = num_conflicts(core) + conflict_bound;
  r_threshold = *reduce_threshold;

  smt_process(core);
  while (smt_status(core) == STATUS_SEARCHING && num_conflicts(core) <= max_conflicts) {
    // reduce heuristic
    if (num_learned_clauses(core) >= r_threshold) {
      reduce_clause_database(core);
      r_threshold = (uint32_t) (r_threshold * r_factor);
    }

    // decision
    l = select_unassigned_literal(core);
    if (l == null_literal) {
      // all variables assigned: the problem is satisfiable
      end_search_sat(core);
      break;
    }
    // propagation
    decide_literal(core, l);
    smt_process(core);
  }

  *reduce_threshold = r_threshold;
}
示例#2
0
/*
 * Full header: includes the learned clauses
 */
static void dimacs_print_full_header(FILE *f, smt_core_t *core) {
  uint32_t num_clauses;

  num_clauses = num_empty_clauses(core) + num_unit_clauses(core) + num_binary_clauses(core) +
    num_prob_clauses(core) + num_learned_clauses(core) + 1;

  fprintf(f, "p cnf %"PRIu32" %"PRIu32"\n", core->nvars, num_clauses);
}
示例#3
0
/*
 * Print some statistic data + header if requested (on stdout)
 */
static void show_progress(smt_core_t *core,
			  uint32_t restart_threshold, uint32_t reduce_threshold, bool show_header) {

  if (show_header) {
    printf("---------------------------------------------------------------------------------\n");
    printf("|     Thresholds    |  Binary   |      Original     |          Learned          |\n");
    printf("|   Conf.      Del. |  Clauses  |   Clauses   Lits. |   Clauses  Lits. Lits/Cl. |\n");
    printf("---------------------------------------------------------------------------------\n");
  }

  printf("| %7"PRIu32"  %8"PRIu32" |  %8"PRIu32" | %8"PRIu32" %8"PRIu64" | %8"PRIu32" %8"PRIu64" %7.1f |\n",
	 restart_threshold, reduce_threshold,
	 num_binary_clauses(core),
	 num_prob_clauses(core), num_prob_literals(core),
	 num_learned_clauses(core), num_learned_literals(core),
	 ((double) num_learned_literals(core)/num_learned_clauses(core)));
  fflush(stdout);
}