3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 19:35:50 +00:00

cleanup cancelation logic

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-12-11 12:35:35 -08:00
parent 4e155887b2
commit 61dbb6168e
37 changed files with 93 additions and 198 deletions

View file

@ -647,8 +647,8 @@ private:
};
hilbert_basis::hilbert_basis():
m_cancel(false),
hilbert_basis::hilbert_basis(reslimit& lim):
m_limit(lim),
m_use_support(true),
m_use_ordered_support(true),
m_use_ordered_subsumption(true)
@ -804,7 +804,7 @@ void hilbert_basis::add_unit_vector(unsigned i, numeral const& e) {
lbool hilbert_basis::saturate() {
init_basis();
m_current_ineq = 0;
while (!m_cancel && m_current_ineq < m_ineqs.size()) {
while (checkpoint() && m_current_ineq < m_ineqs.size()) {
select_inequality();
stopwatch sw;
sw.start();
@ -823,7 +823,7 @@ lbool hilbert_basis::saturate() {
}
++m_current_ineq;
}
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
return l_true;
@ -853,7 +853,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
// resolve passive into active
offset_t j = alloc_vector();
while (!m_passive->empty()) {
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
offset_t idx = m_passive->pop();
@ -862,7 +862,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
recycle(idx);
continue;
}
for (unsigned i = 0; !m_cancel && i < m_active.size(); ++i) {
for (unsigned i = 0; checkpoint() && i < m_active.size(); ++i) {
if ((!m_use_support || support.contains(m_active[i].m_offset)) && can_resolve(idx, m_active[i], true)) {
resolve(idx, m_active[i], j);
if (add_goal(j)) {
@ -942,7 +942,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
TRACE("hilbert_basis", display(tout););
// resolve passive into active
offset_t idx = alloc_vector();
while (!m_cancel && !m_passive2->empty()) {
while (checkpoint() && !m_passive2->empty()) {
offset_t sos, pas;
TRACE("hilbert_basis", display(tout); );
unsigned offset = m_passive2->pop(sos, pas);
@ -967,7 +967,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
}
idx = alloc_vector();
}
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
@ -1112,6 +1112,10 @@ hilbert_basis::offset_t hilbert_basis::alloc_vector() {
}
}
bool hilbert_basis::checkpoint() {
return m_limit.inc();
}
bool hilbert_basis::add_goal(offset_t idx) {
TRACE("hilbert_basis", display(tout, idx););
values v = vec(idx);

View file

@ -32,6 +32,7 @@ Revision History:
#include "lbool.h"
#include "statistics.h"
#include "checked_int64.h"
#include "rlimit.h"
typedef vector<rational> rational_vector;
@ -85,6 +86,7 @@ class hilbert_basis {
numeral const* operator()() const { return m_values; }
};
reslimit& m_limit;
vector<num_vector> m_ineqs; // set of asserted inequalities
svector<bool> m_iseq; // inequalities that are equalities
num_vector m_store; // store of vectors
@ -95,7 +97,6 @@ class hilbert_basis {
svector<offset_t> m_zero; // zeros
passive* m_passive; // passive set
passive2* m_passive2; // passive set
volatile bool m_cancel;
stats m_stats;
index* m_index; // index of generated vectors
unsigned_vector m_ints; // indices that can be both positive and negative
@ -105,6 +106,7 @@ class hilbert_basis {
bool m_use_ordered_support; // parameter: (commutativity) resolve in order
bool m_use_ordered_subsumption; // parameter
class iterator {
hilbert_basis const& hb;
unsigned m_idx;
@ -138,6 +140,8 @@ class hilbert_basis {
bool can_resolve(offset_t i, offset_t j, bool check_sign) const;
sign_t get_sign(offset_t idx) const;
bool add_goal(offset_t idx);
bool checkpoint();
offset_t alloc_vector();
void resolve(offset_t i, offset_t j, offset_t r);
iterator begin() const { return iterator(*this,0); }
@ -154,7 +158,7 @@ class hilbert_basis {
public:
hilbert_basis();
hilbert_basis(reslimit& rl);
~hilbert_basis();
void reset();
@ -188,8 +192,6 @@ public:
unsigned get_num_ineqs() const { return m_ineqs.size(); }
void get_ge(unsigned i, rational_vector& v, rational& b, bool& is_eq);
void set_cancel(bool f) { m_cancel = f; }
void display(std::ostream& out) const;
void collect_statistics(statistics& st) const;