3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-07 18:05:21 +00:00

make sorting of soft constraints the same across implementations of std::sort

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-07-25 11:32:35 -07:00
parent e6df7b73aa
commit 8a0d79251e
2 changed files with 8 additions and 2 deletions

View file

@ -435,7 +435,9 @@ public:
maxres& mr;
compare_asm(maxres& mr):mr(mr) {}
bool operator()(expr* a, expr* b) const {
return mr.get_weight(a) > mr.get_weight(b);
rational w1 = mr.get_weight(a);
rational w2 = mr.get_weight(b);
return w1 > w2 || (w1 == w2 && a->get_id() > b->get_id());
}
};

View file

@ -2991,7 +2991,7 @@ namespace sat {
init_use_lists();
remove_unused_defs();
set_non_external();
//if (get_config().m_elim_vars && !s().get_config().m_incremental && !s().tracking_assumptions()) elim_pure();
elim_pure();
for (unsigned sz = m_constraints.size(), i = 0; i < sz; ++i) subsumption(*m_constraints[i]);
for (unsigned sz = m_learned.size(), i = 0; i < sz; ++i) subsumption(*m_learned[i]);
unit_strengthen();
@ -3563,6 +3563,7 @@ namespace sat {
}
void ba_solver::remove_unused_defs() {
if (incremental_mode()) return;
// remove constraints where indicator literal isn't used.
for (constraint* cp : m_constraints) {
constraint& c = *cp;
@ -3634,6 +3635,9 @@ namespace sat {
}
unsigned ba_solver::elim_pure() {
if (!get_config().m_elim_vars || incremental_mode()) {
return 0;
}
// eliminate pure literals
unsigned pure_literals = 0;
for (unsigned v = 0; v < s().num_vars(); ++v) {