28 const unsigned max_size =
GET_OPTION (reordermaxsize);
29 LOG (
"limiting weight computation to maximum clause size %u", max_size);
34 for (
unsigned size = 2;
size <= max_size;
size++) {
35 LOG (
"score table[%u] = %g", size, weight);
36 table[
size] = weight, weight /= 2.0;
41 const signed char *
const values =
solver->values;
42 const clause *last = kissat_last_irredundant_clause (
solver);
51 int continue_with_next_clause = 0;
53 const signed char value = values[
lit];
55 continue_with_next_clause = 1;
58 if (!
value && size < max_size && ++size == max_size)
61 if(continue_with_next_clause) {
64 const double weight = table[
size];
66 weights[
lit] += weight;
71 double weight = table[2];
74 const unsigned idx =
IDX (
lit);
84 const unsigned other_idx =
IDX (other);
87 weights[
lit] += weight;
88 weights[other] += weight;
96 double pos = weights[
lit], neg = weights[not_lit];
97 double max_pos_neg =
MAX (
pos, neg);
98 double min_pos_neg =
MIN (
pos, neg);
99 double scaled_min_pos_neg = 2 * min_pos_neg;
100 double weight = max_pos_neg + scaled_min_pos_neg;
101 LOG (
"computed weight %g "
102 "= %g + %g = max (%g, %g) + 2 * min (%g, %g) of %s",
103 weight, max_pos_neg, scaled_min_pos_neg,
pos, neg,
pos, neg,
105 weights[idx] = weight;
110static bool less_focused_order (
unsigned a,
unsigned b,
links *
links,
112 double u = weights[a], v = weights[b];
121static bool less_stable_order (
unsigned a,
unsigned b,
heap *
scores,
123 double u = weights[a], v = weights[b];
128 double s = kissat_get_heap_score (
scores, a);
129 double t = kissat_get_heap_score (
scores, b);
137#define LESS_FOCUSED_ORDER(A, B) less_focused_order (A, B, links, weights)
139#define LESS_STABLE_ORDER(A, B) less_stable_order (A, B, scores, weights)
141static void sort_active_variables_by_weight (
kissat *
solver,
154 LOG (
"reordered %s with weight %g score %g", LOGVAR (idx),
155 weights[idx], kissat_get_heap_score (
scores, idx));
163 LOG (
"reordered %s with weight %g stamp %u", LOGVAR (idx),
170 INC (reordered_focused);
172 double *weights = compute_weights (
solver);
174 sort_active_variables_by_weight (
solver, &sorted, weights);
176 for (
all_stack (
unsigned, idx, sorted)) {
178 kissat_move_to_front (
solver, idx);
184 INC (reordered_stable);
186 double *weights = compute_weights (
solver);
189 sort_active_variables_by_weight (
solver, &sorted, weights);
194 const double old_score = kissat_get_heap_score (
scores, idx);
195 const double weight = weights[idx];
196 const double new_score = old_score + weight;
197 LOG (
"updating score of %s to %g = %g (old score) + %g (weight)",
198 LOGVAR (idx), new_score, old_score, weight);
210 "reorder limit %" PRIu64
" hit a after %" PRIu64
211 " conflicts in %s mode ",
213 solver->stable ?
"stable" :
"focused");
219 "reordered decisions in %s search mode",
220 solver->stable ?
"stable" :
"focused");
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void * kissat_nalloc(kissat *solver, size_t n, size_t size)
void * kissat_calloc(kissat *solver, size_t n, size_t size)
void kissat_dealloc(kissat *solver, void *ptr, size_t n, size_t size)
void kissat_rescale_scores(kissat *solver)
#define all_stack(T, E, S)
ABC_NAMESPACE_IMPL_START typedef signed char value
#define all_variables(IDX)
#define all_literals(LIT)
#define UPDATE_CONFLICT_LIMIT(NAME, COUNT, SCALE_COUNT_FUNCTION, SCALE_DELTA)
#define all_literals_in_clause(LIT, C)
#define KISSAT_assert(ignore)
#define SORT_STACK(TYPE, S, LESS)
#define kissat_phase(...)
#define LESS_FOCUSED_ORDER(A, B)
#define LESS_STABLE_ORDER(A, B)
void kissat_reorder(kissat *solver)
ABC_NAMESPACE_IMPL_START bool kissat_reordering(kissat *solver)
#define all_binary_blocking_watches(WATCH, WATCHES)