Skip to content

Commit

Permalink
Decision hint queue (#494)
Browse files Browse the repository at this point in the history
* Fixed typos

* rename int_queue_t size with capacity

* enhanced int_queue

* added queue for next decision

* Clear hint queue on conflict

* Added two queues (top and hint)

* fixed bug

* added solver hints in NRA

* model_interpolation questions

* model_interpolation does not perform request_top_decision

* Remove shortcut variables from the queue

* regression prints execution time

* nra_plugin.c hint only on real solution

* variable selection forces decision on hint

* fix random decision

* trace printing

* changed the gold of a model interpolant

* added option for test issue204.smt2

* Removed ToDo

* avoid dupplication in top_decision_queue

* Revert "regression prints execution time"

This reverts commit aec6c21.

* Update mcsat_decision (fixed aux decision problems) and moved hinted queue reset to pop.

* Added force_decision for top_variables

---------

Co-authored-by: Thomas Hader <[email protected]>
Co-authored-by: Thomas Hader <[email protected]>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent f29c7da commit d62a1fe
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 154 deletions.
2 changes: 1 addition & 1 deletion src/exists_forall/ef_values.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void postprocess_ef_table(ef_table_t *vtable, bool check) {
}
}
}
m = queue.size;
m = queue.capacity;
j = 0;
while(!int_queue_is_empty(&queue)) {
tvalue = int_queue_pop(&queue);
Expand Down
26 changes: 16 additions & 10 deletions src/mcsat/nra/nra_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,18 +860,24 @@ void nra_plugin_process_unit_constraint(nra_plugin_t* nra, trail_token_t* prop,
}
lp_value_destruct(&v);
}
// If the value is implied at zero level, propagate it
if (!nra->ctx->options->model_interpolation && !x_in_conflict && !trail_has_value(nra->ctx->trail, x) && trail_is_at_base_level(nra->ctx->trail)) {
const lp_feasibility_set_t* feasible = feasible_set_db_get(nra->feasible_set_db, x);
if (lp_feasibility_set_is_point(feasible)) {
if (!x_in_conflict && !trail_has_value(nra->ctx->trail, x)) {
const lp_feasibility_set_t *feasible_set = feasible_set_db_get(nra->feasible_set_db, x);
if (lp_feasibility_set_is_point(feasible_set)) {
lp_value_t x_value;
lp_value_construct_none(&x_value);
lp_feasibility_set_pick_value(feasible, &x_value);
lp_feasibility_set_pick_value(feasible_set, &x_value);
if (lp_value_is_rational(&x_value)) {
mcsat_value_t value;
mcsat_value_construct_lp_value(&value, &x_value);
prop->add_at_level(prop, x, &value, nra->ctx->trail->decision_level_base);
mcsat_value_destruct(&value);
if (trail_is_at_base_level(nra->ctx->trail) && !nra->ctx->options->model_interpolation) {
mcsat_value_t value;
mcsat_value_construct_lp_value(&value, &x_value);
prop->add_at_level(prop, x, &value, nra->ctx->trail->decision_level_base);
mcsat_value_destruct(&value);
} else {
if (ctx_trace_enabled(nra->ctx, "nra::propagate")) {
ctx_trace_printf(nra->ctx, "nra: hinting variable = %d\n", x);
}
nra->ctx->hint_next_decision(nra->ctx, x);
}
}
lp_value_destruct(&x_value);
}
Expand Down Expand Up @@ -1069,7 +1075,7 @@ void nra_plugin_propagate(plugin_t* plugin, trail_token_t* prop) {
}

// Propagate
while(trail_is_consistent(trail) && nra->trail_i < trail_size(trail)) {
while (trail_is_consistent(trail) && nra->trail_i < trail_size(trail)) {
// Current trail element
var = trail_at(trail, nra->trail_i);
nra->trail_i ++;
Expand Down
6 changes: 4 additions & 2 deletions src/mcsat/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ struct plugin_context_s {
/** Request a variable to be a top decision variable */
void (*request_top_decision) (plugin_context_t* self, variable_t x);

/** Request a variable to be a next decision variable */
void (*hint_next_decision) (plugin_context_t* self, variable_t x);

};

/** Token to add entries to the trail */
Expand Down Expand Up @@ -334,10 +337,9 @@ void plugin_construct(plugin_t* plugin) {
plugin->pop = NULL;
plugin->build_model = NULL;
plugin->gc_mark = NULL;
plugin->gc_mark_and_clear = NULL;
plugin->gc_mark_and_clear = NULL;
plugin->gc_sweep = NULL;
plugin->set_exception_handler = NULL;
}


#endif /* PLUGIN_H_ */
Loading

0 comments on commit d62a1fe

Please sign in to comment.