コード例 #1
0
ファイル: sat_api.c プロジェクト: wsw1206/CS264A
//frees the SatState
void sat_state_free(SatState* sat_state) {
	for (c2dSize i = 1; i <= sat_var_count(sat_state); i++) {
		Var* var = sat_index2var(i, sat_state);
		vector_free(&var->mentions);
		vector_free(&var->mentions_lc);
		free(var);
		free(sat_index2literal(i, sat_state));
		free(sat_index2literal(-i, sat_state));
	}
	for (c2dSize i = 1; i <= sat_clause_count(sat_state); i++) {
		Clause* clause = sat_index2clause(i, sat_state);
		vector_free(&clause->lits);
		free(clause);
	}
	vector_free(&sat_state->vars);
	vector_free(&sat_state->plits);
	vector_free(&sat_state->nlits);
	vector_free(&sat_state->kb);
	vector_free(&sat_state->lc);
	vector_free(&sat_state->ds);
	vector_free(&sat_state->il);
	vector_free(&sat_state->q);
	vector_free(&sat_state->s);
	free(sat_state);
}
コード例 #2
0
ファイル: sat_api.c プロジェクト: Lcch/CS264A
void sat_state_debug(SatState* sat_state) {
  printf("%lu %lu\n", sat_state->num_vars, sat_state->num_cnf_clauses);
  for (c2dSize i = 1; i <= sat_state->num_cnf_clauses; i++) {
    printf("Clause %lu: %lu\n", sat_state->cnf_clauses[i]->index, sat_state->cnf_clauses[i]->size);
    for (c2dSize j = 0; j < sat_state->cnf_clauses[i]->size; j++) {
      printf("%ld ", sat_state->cnf_clauses[i]->literals[j]->index);
    }
    printf("\n");
  }

  for (c2dSize i = 1; i <= sat_state->num_vars; i++) {
    Var* var = sat_index2var(i, sat_state);
    printf("Var %lu %lu %lu: \n", i, var->num_clauses, var->dyn_cap);
    for (c2dSize k = 0; k < var->num_clauses; k++) {
      printf("%lu ", var->clauses[k]->index);
    }
    printf("\n");
  }
  printf("\n");
  
  printf("num_decided_literals: %lu\n", sat_state->num_decided_literals);
  for (c2dSize i = 0; i < sat_state->num_decided_literals; i++) {
    printf("%ld ", sat_state->decided_literals[i]->index);
  }
  printf("\n");

  printf("num_implied_literals: %lu\n", sat_state->num_implied_literals);
  for (c2dSize i = 0; i < sat_state->num_implied_literals; i++) {
    printf("%ld ", sat_state->implied_literals[i]->index);
  }
  printf("\n");   
}