mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
cleanup cancelation logic
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
4e155887b2
commit
61dbb6168e
|
@ -130,12 +130,6 @@ namespace api {
|
||||||
m_context.display_smt2(num_queries, queries, str);
|
m_context.display_smt2(num_queries, queries, str);
|
||||||
return str.str();
|
return str.str();
|
||||||
}
|
}
|
||||||
void cancel() {
|
|
||||||
m_context.cancel();
|
|
||||||
}
|
|
||||||
void reset_cancel() {
|
|
||||||
m_context.reset_cancel();
|
|
||||||
}
|
|
||||||
unsigned get_num_levels(func_decl* pred) {
|
unsigned get_num_levels(func_decl* pred) {
|
||||||
return m_context.get_num_levels(pred);
|
return m_context.get_num_levels(pred);
|
||||||
}
|
}
|
||||||
|
@ -285,13 +279,13 @@ extern "C" {
|
||||||
LOG_Z3_fixedpoint_query(c, d, q);
|
LOG_Z3_fixedpoint_query(c, d, q);
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
lbool r = l_undef;
|
lbool r = l_undef;
|
||||||
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
|
|
||||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||||
unsigned rlimit = to_fixedpoint(d)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
|
unsigned rlimit = to_fixedpoint(d)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
|
||||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
|
||||||
{
|
{
|
||||||
scoped_timer timer(timeout, &eh);
|
|
||||||
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
|
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
|
||||||
|
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
|
||||||
|
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||||
|
scoped_timer timer(timeout, &eh);
|
||||||
try {
|
try {
|
||||||
r = to_fixedpoint_ref(d)->ctx().query(to_expr(q));
|
r = to_fixedpoint_ref(d)->ctx().query(to_expr(q));
|
||||||
}
|
}
|
||||||
|
@ -313,7 +307,7 @@ extern "C" {
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
lbool r = l_undef;
|
lbool r = l_undef;
|
||||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||||
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
|
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
|
||||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||||
{
|
{
|
||||||
scoped_timer timer(timeout, &eh);
|
scoped_timer timer(timeout, &eh);
|
||||||
|
|
|
@ -98,7 +98,6 @@ struct euclidean_solver::imp {
|
||||||
|
|
||||||
numeral_manager * m_manager;
|
numeral_manager * m_manager;
|
||||||
bool m_owns_m;
|
bool m_owns_m;
|
||||||
volatile bool m_cancel;
|
|
||||||
|
|
||||||
equations m_equations;
|
equations m_equations;
|
||||||
equations m_solution;
|
equations m_solution;
|
||||||
|
@ -517,7 +516,6 @@ struct euclidean_solver::imp {
|
||||||
m_var_queue(16, elim_order_lt(m_solved)) {
|
m_var_queue(16, elim_order_lt(m_solved)) {
|
||||||
m_inconsistent = null_eq_idx;
|
m_inconsistent = null_eq_idx;
|
||||||
m_next_justification = 0;
|
m_next_justification = 0;
|
||||||
m_cancel = false;
|
|
||||||
m_next_x = null_var;
|
m_next_x = null_var;
|
||||||
m_next_eq = null_eq_idx;
|
m_next_eq = null_eq_idx;
|
||||||
}
|
}
|
||||||
|
@ -779,9 +777,6 @@ struct euclidean_solver::imp {
|
||||||
del_nums(m_norm_bs_vector);
|
del_nums(m_norm_bs_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_cancel(bool f) {
|
|
||||||
m_cancel = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -842,12 +837,6 @@ void euclidean_solver::normalize(unsigned num, mpz const * as, var const * xs, m
|
||||||
return m_imp->normalize(num, as, xs, c, a_prime, c_prime, js);
|
return m_imp->normalize(num, as, xs, c, a_prime, c_prime, js);
|
||||||
}
|
}
|
||||||
|
|
||||||
void euclidean_solver::set_cancel(bool f) {
|
|
||||||
#pragma omp critical (euclidean_solver)
|
|
||||||
{
|
|
||||||
m_imp->set_cancel(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void euclidean_solver::display(std::ostream & out) const {
|
void euclidean_solver::display(std::ostream & out) const {
|
||||||
m_imp->display(out);
|
m_imp->display(out);
|
||||||
|
|
|
@ -95,10 +95,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void normalize(unsigned num, mpz const * as, var const * xs, mpz const & c, mpz & a_prime, mpz & c_prime, justification_vector & js);
|
void normalize(unsigned num, mpz const * as, var const * xs, mpz const & c, mpz & a_prime, mpz & c_prime, justification_vector & js);
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Set/Reset the cancel flag.
|
|
||||||
*/
|
|
||||||
void set_cancel(bool f);
|
|
||||||
|
|
||||||
void display(std::ostream & out) const;
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -647,8 +647,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
hilbert_basis::hilbert_basis():
|
hilbert_basis::hilbert_basis(reslimit& lim):
|
||||||
m_cancel(false),
|
m_limit(lim),
|
||||||
m_use_support(true),
|
m_use_support(true),
|
||||||
m_use_ordered_support(true),
|
m_use_ordered_support(true),
|
||||||
m_use_ordered_subsumption(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() {
|
lbool hilbert_basis::saturate() {
|
||||||
init_basis();
|
init_basis();
|
||||||
m_current_ineq = 0;
|
m_current_ineq = 0;
|
||||||
while (!m_cancel && m_current_ineq < m_ineqs.size()) {
|
while (checkpoint() && m_current_ineq < m_ineqs.size()) {
|
||||||
select_inequality();
|
select_inequality();
|
||||||
stopwatch sw;
|
stopwatch sw;
|
||||||
sw.start();
|
sw.start();
|
||||||
|
@ -823,7 +823,7 @@ lbool hilbert_basis::saturate() {
|
||||||
}
|
}
|
||||||
++m_current_ineq;
|
++m_current_ineq;
|
||||||
}
|
}
|
||||||
if (m_cancel) {
|
if (!checkpoint()) {
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
return l_true;
|
return l_true;
|
||||||
|
@ -853,7 +853,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
||||||
// resolve passive into active
|
// resolve passive into active
|
||||||
offset_t j = alloc_vector();
|
offset_t j = alloc_vector();
|
||||||
while (!m_passive->empty()) {
|
while (!m_passive->empty()) {
|
||||||
if (m_cancel) {
|
if (!checkpoint()) {
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
offset_t idx = m_passive->pop();
|
offset_t idx = m_passive->pop();
|
||||||
|
@ -862,7 +862,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
|
||||||
recycle(idx);
|
recycle(idx);
|
||||||
continue;
|
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)) {
|
if ((!m_use_support || support.contains(m_active[i].m_offset)) && can_resolve(idx, m_active[i], true)) {
|
||||||
resolve(idx, m_active[i], j);
|
resolve(idx, m_active[i], j);
|
||||||
if (add_goal(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););
|
TRACE("hilbert_basis", display(tout););
|
||||||
// resolve passive into active
|
// resolve passive into active
|
||||||
offset_t idx = alloc_vector();
|
offset_t idx = alloc_vector();
|
||||||
while (!m_cancel && !m_passive2->empty()) {
|
while (checkpoint() && !m_passive2->empty()) {
|
||||||
offset_t sos, pas;
|
offset_t sos, pas;
|
||||||
TRACE("hilbert_basis", display(tout); );
|
TRACE("hilbert_basis", display(tout); );
|
||||||
unsigned offset = m_passive2->pop(sos, pas);
|
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();
|
idx = alloc_vector();
|
||||||
}
|
}
|
||||||
if (m_cancel) {
|
if (!checkpoint()) {
|
||||||
return l_undef;
|
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) {
|
bool hilbert_basis::add_goal(offset_t idx) {
|
||||||
TRACE("hilbert_basis", display(tout, idx););
|
TRACE("hilbert_basis", display(tout, idx););
|
||||||
values v = vec(idx);
|
values v = vec(idx);
|
||||||
|
|
|
@ -32,6 +32,7 @@ Revision History:
|
||||||
#include "lbool.h"
|
#include "lbool.h"
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "checked_int64.h"
|
#include "checked_int64.h"
|
||||||
|
#include "rlimit.h"
|
||||||
|
|
||||||
typedef vector<rational> rational_vector;
|
typedef vector<rational> rational_vector;
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ class hilbert_basis {
|
||||||
numeral const* operator()() const { return m_values; }
|
numeral const* operator()() const { return m_values; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reslimit& m_limit;
|
||||||
vector<num_vector> m_ineqs; // set of asserted inequalities
|
vector<num_vector> m_ineqs; // set of asserted inequalities
|
||||||
svector<bool> m_iseq; // inequalities that are equalities
|
svector<bool> m_iseq; // inequalities that are equalities
|
||||||
num_vector m_store; // store of vectors
|
num_vector m_store; // store of vectors
|
||||||
|
@ -95,7 +97,6 @@ class hilbert_basis {
|
||||||
svector<offset_t> m_zero; // zeros
|
svector<offset_t> m_zero; // zeros
|
||||||
passive* m_passive; // passive set
|
passive* m_passive; // passive set
|
||||||
passive2* m_passive2; // passive set
|
passive2* m_passive2; // passive set
|
||||||
volatile bool m_cancel;
|
|
||||||
stats m_stats;
|
stats m_stats;
|
||||||
index* m_index; // index of generated vectors
|
index* m_index; // index of generated vectors
|
||||||
unsigned_vector m_ints; // indices that can be both positive and negative
|
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_support; // parameter: (commutativity) resolve in order
|
||||||
bool m_use_ordered_subsumption; // parameter
|
bool m_use_ordered_subsumption; // parameter
|
||||||
|
|
||||||
|
|
||||||
class iterator {
|
class iterator {
|
||||||
hilbert_basis const& hb;
|
hilbert_basis const& hb;
|
||||||
unsigned m_idx;
|
unsigned m_idx;
|
||||||
|
@ -138,6 +140,8 @@ class hilbert_basis {
|
||||||
bool can_resolve(offset_t i, offset_t j, bool check_sign) const;
|
bool can_resolve(offset_t i, offset_t j, bool check_sign) const;
|
||||||
sign_t get_sign(offset_t idx) const;
|
sign_t get_sign(offset_t idx) const;
|
||||||
bool add_goal(offset_t idx);
|
bool add_goal(offset_t idx);
|
||||||
|
bool checkpoint();
|
||||||
|
|
||||||
offset_t alloc_vector();
|
offset_t alloc_vector();
|
||||||
void resolve(offset_t i, offset_t j, offset_t r);
|
void resolve(offset_t i, offset_t j, offset_t r);
|
||||||
iterator begin() const { return iterator(*this,0); }
|
iterator begin() const { return iterator(*this,0); }
|
||||||
|
@ -154,7 +158,7 @@ class hilbert_basis {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
hilbert_basis();
|
hilbert_basis(reslimit& rl);
|
||||||
~hilbert_basis();
|
~hilbert_basis();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -188,8 +192,6 @@ public:
|
||||||
unsigned get_num_ineqs() const { return m_ineqs.size(); }
|
unsigned get_num_ineqs() const { return m_ineqs.size(); }
|
||||||
void get_ge(unsigned i, rational_vector& v, rational& b, bool& is_eq);
|
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 display(std::ostream& out) const;
|
||||||
|
|
||||||
void collect_statistics(statistics& st) const;
|
void collect_statistics(statistics& st) const;
|
||||||
|
|
|
@ -92,6 +92,7 @@ namespace simplex {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const var_t null_var;
|
static const var_t null_var;
|
||||||
|
reslimit& m_limit;
|
||||||
mutable manager m;
|
mutable manager m;
|
||||||
mutable eps_manager em;
|
mutable eps_manager em;
|
||||||
mutable matrix M;
|
mutable matrix M;
|
||||||
|
@ -109,10 +110,10 @@ namespace simplex {
|
||||||
stats m_stats;
|
stats m_stats;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
simplex():
|
simplex(reslimit& lim):
|
||||||
|
m_limit(lim),
|
||||||
M(m),
|
M(m),
|
||||||
m_max_iterations(UINT_MAX),
|
m_max_iterations(UINT_MAX),
|
||||||
m_cancel(false),
|
|
||||||
m_to_patch(1024),
|
m_to_patch(1024),
|
||||||
m_bland(false),
|
m_bland(false),
|
||||||
m_blands_rule_threshold(1000) {}
|
m_blands_rule_threshold(1000) {}
|
||||||
|
@ -140,7 +141,6 @@ namespace simplex {
|
||||||
void unset_lower(var_t var);
|
void unset_lower(var_t var);
|
||||||
void unset_upper(var_t var);
|
void unset_upper(var_t var);
|
||||||
void set_value(var_t var, eps_numeral const& b);
|
void set_value(var_t var, eps_numeral const& b);
|
||||||
void set_cancel(bool f) { m_cancel = f; }
|
|
||||||
void set_max_iterations(unsigned n) { m_max_iterations = n; }
|
void set_max_iterations(unsigned n) { m_max_iterations = n; }
|
||||||
void reset();
|
void reset();
|
||||||
lbool make_feasible();
|
lbool make_feasible();
|
||||||
|
|
|
@ -332,7 +332,7 @@ namespace simplex {
|
||||||
SASSERT(well_formed());
|
SASSERT(well_formed());
|
||||||
while ((v = select_var_to_fix()) != null_var) {
|
while ((v = select_var_to_fix()) != null_var) {
|
||||||
TRACE("simplex", display(tout << "v" << v << "\n"););
|
TRACE("simplex", display(tout << "v" << v << "\n"););
|
||||||
if (m_cancel || num_iterations > m_max_iterations) {
|
if (!m_limit.inc() || num_iterations > m_max_iterations) {
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
check_blands_rule(v, num_repeated);
|
check_blands_rule(v, num_repeated);
|
||||||
|
@ -670,7 +670,7 @@ namespace simplex {
|
||||||
bool inc_x_i, inc_x_j;
|
bool inc_x_i, inc_x_j;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (m_cancel) {
|
if (!m_limit.inc()) {
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
select_pivot_primal(v, x_i, x_j, a_ij, inc_x_i, inc_x_j);
|
select_pivot_primal(v, x_i, x_j, a_ij, inc_x_i, inc_x_j);
|
||||||
|
|
|
@ -230,8 +230,7 @@ namespace datalog {
|
||||||
m_enable_bind_variables(true),
|
m_enable_bind_variables(true),
|
||||||
m_last_status(OK),
|
m_last_status(OK),
|
||||||
m_last_answer(m),
|
m_last_answer(m),
|
||||||
m_engine_type(LAST_ENGINE),
|
m_engine_type(LAST_ENGINE) {
|
||||||
m_cancel(false) {
|
|
||||||
re.set_context(this);
|
re.set_context(this);
|
||||||
updt_params(pa);
|
updt_params(pa);
|
||||||
}
|
}
|
||||||
|
@ -751,15 +750,16 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
void context::cancel() {
|
void context::cancel() {
|
||||||
m_cancel = true;
|
m_cancel = true;
|
||||||
m_last_status = CANCELED;
|
m_last_status = CANCELED;
|
||||||
m_transf.cancel();
|
m_transf.cancel();
|
||||||
if (m_engine) m_engine->cancel();
|
if (m_engine) m_engine->cancel();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void context::cleanup() {
|
void context::cleanup() {
|
||||||
m_cancel = false;
|
|
||||||
m_last_status = OK;
|
m_last_status = OK;
|
||||||
if (m_engine) m_engine->cleanup();
|
if (m_engine) m_engine->cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,11 +487,13 @@ namespace datalog {
|
||||||
//
|
//
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
void cancel();
|
bool canceled() {
|
||||||
bool canceled() const { return m_cancel; }
|
if (m.limit().inc()) return true;
|
||||||
|
m_last_status = CANCELED;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void reset_cancel() { cleanup(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief check if query 'q' is satisfied under asserted rules and background.
|
\brief check if query 'q' is satisfied under asserted rules and background.
|
||||||
|
|
|
@ -74,7 +74,6 @@ class hnf::imp {
|
||||||
|
|
||||||
ast_manager& m;
|
ast_manager& m;
|
||||||
bool m_produce_proofs;
|
bool m_produce_proofs;
|
||||||
volatile bool m_cancel;
|
|
||||||
expr_ref_vector m_todo;
|
expr_ref_vector m_todo;
|
||||||
proof_ref_vector m_proofs;
|
proof_ref_vector m_proofs;
|
||||||
expr_ref_vector m_refs;
|
expr_ref_vector m_refs;
|
||||||
|
@ -96,7 +95,6 @@ public:
|
||||||
imp(ast_manager & m):
|
imp(ast_manager & m):
|
||||||
m(m),
|
m(m),
|
||||||
m_produce_proofs(false),
|
m_produce_proofs(false),
|
||||||
m_cancel(false),
|
|
||||||
m_todo(m),
|
m_todo(m),
|
||||||
m_proofs(m),
|
m_proofs(m),
|
||||||
m_refs(m),
|
m_refs(m),
|
||||||
|
@ -156,7 +154,7 @@ public:
|
||||||
m_todo.push_back(n);
|
m_todo.push_back(n);
|
||||||
m_proofs.push_back(p);
|
m_proofs.push_back(p);
|
||||||
m_produce_proofs = p != 0;
|
m_produce_proofs = p != 0;
|
||||||
while (!m_todo.empty() && !m_cancel) {
|
while (!m_todo.empty() && checkpoint()) {
|
||||||
fml = m_todo.back();
|
fml = m_todo.back();
|
||||||
pr = m_proofs.back();
|
pr = m_proofs.back();
|
||||||
m_todo.pop_back();
|
m_todo.pop_back();
|
||||||
|
@ -174,8 +172,8 @@ public:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_cancel(bool f) {
|
bool checkpoint() {
|
||||||
m_cancel = f;
|
return m.limit().inc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_name(symbol const& n) {
|
void set_name(symbol const& n) {
|
||||||
|
@ -192,7 +190,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
m_cancel = false;
|
|
||||||
m_todo.reset();
|
m_todo.reset();
|
||||||
m_proofs.reset();
|
m_proofs.reset();
|
||||||
m_refs.reset();
|
m_refs.reset();
|
||||||
|
@ -524,9 +521,6 @@ void hnf::operator()(expr * n, proof* p, expr_ref_vector & rs, proof_ref_vector&
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hnf::set_cancel(bool f) {
|
|
||||||
m_imp->set_cancel(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hnf::set_name(symbol const& n) {
|
void hnf::set_name(symbol const& n) {
|
||||||
m_imp->set_name(n);
|
m_imp->set_name(n);
|
||||||
|
|
|
@ -43,9 +43,6 @@ class hnf {
|
||||||
proof_ref_vector& ps // [OUT] proofs of rs
|
proof_ref_vector& ps // [OUT] proofs of rs
|
||||||
);
|
);
|
||||||
|
|
||||||
void cancel() { set_cancel(true); }
|
|
||||||
void reset_cancel() { set_cancel(false); }
|
|
||||||
void set_cancel(bool f);
|
|
||||||
void set_name(symbol const& name);
|
void set_name(symbol const& name);
|
||||||
void reset();
|
void reset();
|
||||||
func_decl_ref_vector const& get_fresh_predicates();
|
func_decl_ref_vector const& get_fresh_predicates();
|
||||||
|
|
|
@ -470,7 +470,6 @@ namespace datalog {
|
||||||
ast_manager& m;
|
ast_manager& m;
|
||||||
rule_manager& rm;
|
rule_manager& rm;
|
||||||
bv_util bv;
|
bv_util bv;
|
||||||
volatile bool m_cancel;
|
|
||||||
ptr_vector<expr> m_todo;
|
ptr_vector<expr> m_todo;
|
||||||
ast_mark m_visited1, m_visited2;
|
ast_mark m_visited1, m_visited2;
|
||||||
ddnfs m_ddnfs;
|
ddnfs m_ddnfs;
|
||||||
|
@ -486,7 +485,6 @@ namespace datalog {
|
||||||
m(ctx.get_manager()),
|
m(ctx.get_manager()),
|
||||||
rm(ctx.get_rule_manager()),
|
rm(ctx.get_rule_manager()),
|
||||||
bv(m),
|
bv(m),
|
||||||
m_cancel(false),
|
|
||||||
m_trail(m),
|
m_trail(m),
|
||||||
m_inner_ctx(m, m_ctx.get_register_engine(), m_ctx.get_fparams())
|
m_inner_ctx(m, m_ctx.get_register_engine(), m_ctx.get_fparams())
|
||||||
{
|
{
|
||||||
|
@ -518,15 +516,7 @@ namespace datalog {
|
||||||
// return execute_rules(new_rules);
|
// return execute_rules(new_rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel() {
|
|
||||||
m_cancel = true;
|
|
||||||
m_inner_ctx.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanup() {
|
|
||||||
m_cancel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset_statistics() {
|
void reset_statistics() {
|
||||||
m_stats.reset();
|
m_stats.reset();
|
||||||
}
|
}
|
||||||
|
@ -884,12 +874,6 @@ namespace datalog {
|
||||||
lbool ddnf::query(expr* query) {
|
lbool ddnf::query(expr* query) {
|
||||||
return m_imp->query(query);
|
return m_imp->query(query);
|
||||||
}
|
}
|
||||||
void ddnf::cancel() {
|
|
||||||
m_imp->cancel();
|
|
||||||
}
|
|
||||||
void ddnf::cleanup() {
|
|
||||||
m_imp->cleanup();
|
|
||||||
}
|
|
||||||
void ddnf::reset_statistics() {
|
void ddnf::reset_statistics() {
|
||||||
m_imp->reset_statistics();
|
m_imp->reset_statistics();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ namespace datalog {
|
||||||
ddnf(context& ctx);
|
ddnf(context& ctx);
|
||||||
~ddnf();
|
~ddnf();
|
||||||
virtual lbool query(expr* query);
|
virtual lbool query(expr* query);
|
||||||
virtual void cancel();
|
|
||||||
virtual void cleanup();
|
|
||||||
virtual void reset_statistics();
|
virtual void reset_statistics();
|
||||||
virtual void collect_statistics(statistics& st) const;
|
virtual void collect_statistics(statistics& st) const;
|
||||||
virtual void display_certificate(std::ostream& out) const;
|
virtual void display_certificate(std::ostream& out) const;
|
||||||
|
|
|
@ -230,7 +230,7 @@ public:
|
||||||
set_background(ctx);
|
set_background(ctx);
|
||||||
dlctx.updt_params(m_params);
|
dlctx.updt_params(m_params);
|
||||||
unsigned timeout = m_dl_ctx->get_params().timeout();
|
unsigned timeout = m_dl_ctx->get_params().timeout();
|
||||||
cancel_eh<datalog::context> eh(dlctx);
|
cancel_eh<reslimit> eh(ctx.m().limit());
|
||||||
bool query_exn = false;
|
bool query_exn = false;
|
||||||
lbool status = l_undef;
|
lbool status = l_undef;
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,9 +64,6 @@ class horn_tactic : public tactic {
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_cancel(bool f) {
|
void set_cancel(bool f) {
|
||||||
if (f) {
|
|
||||||
m_ctx.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void normalize(expr_ref& f) {
|
void normalize(expr_ref& f) {
|
||||||
|
|
|
@ -270,8 +270,6 @@ namespace datalog {
|
||||||
|
|
||||||
symbol const& get_name() const { return m_name; }
|
symbol const& get_name() const { return m_name; }
|
||||||
|
|
||||||
virtual void set_cancel(bool f) {}
|
|
||||||
|
|
||||||
relation_manager & get_manager() const { return m_manager; }
|
relation_manager & get_manager() const { return m_manager; }
|
||||||
ast_manager& get_ast_manager() const { return datalog::get_ast_manager_from_rel_manager(m_manager); }
|
ast_manager& get_ast_manager() const { return datalog::get_ast_manager_from_rel_manager(m_manager); }
|
||||||
context& get_context() const { return datalog::get_context_from_rel_manager(m_manager); }
|
context& get_context() const { return datalog::get_context_from_rel_manager(m_manager); }
|
||||||
|
|
|
@ -54,8 +54,6 @@ namespace datalog {
|
||||||
|
|
||||||
virtual table_base * mk_empty(const table_signature & s);
|
virtual table_base * mk_empty(const table_signature & s);
|
||||||
|
|
||||||
virtual void set_cancel(bool f) { m_plugin.set_cancel(f); }
|
|
||||||
|
|
||||||
static table_plugin* mk_sparse(relation_manager& rm);
|
static table_plugin* mk_sparse(relation_manager& rm);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -463,12 +463,6 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void relation_manager::set_cancel(bool f) {
|
|
||||||
for (unsigned i = 0; i < m_relation_plugins.size(); ++i) {
|
|
||||||
m_relation_plugins[i]->set_cancel(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string relation_manager::to_nice_string(const relation_element & el) const {
|
std::string relation_manager::to_nice_string(const relation_element & el) const {
|
||||||
uint64 val;
|
uint64 val;
|
||||||
std::stringstream stm;
|
std::stringstream stm;
|
||||||
|
|
|
@ -225,8 +225,6 @@ namespace datalog {
|
||||||
relation_fact & to);
|
relation_fact & to);
|
||||||
|
|
||||||
|
|
||||||
void set_cancel(bool f);
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
//
|
//
|
||||||
|
|
|
@ -499,7 +499,6 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
|
|
||||||
void karr_relation_plugin::set_cancel(bool f) {
|
void karr_relation_plugin::set_cancel(bool f) {
|
||||||
m_hb.set_cancel(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
relation_base * karr_relation_plugin::mk_empty(const relation_signature & s) {
|
relation_base * karr_relation_plugin::mk_empty(const relation_signature & s) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace datalog {
|
||||||
public:
|
public:
|
||||||
karr_relation_plugin(relation_manager& rm):
|
karr_relation_plugin(relation_manager& rm):
|
||||||
relation_plugin(karr_relation_plugin::get_name(), rm),
|
relation_plugin(karr_relation_plugin::get_name(), rm),
|
||||||
|
m_hb(get_ast_manager().limit()),
|
||||||
a(get_ast_manager())
|
a(get_ast_manager())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -512,9 +512,6 @@ namespace datalog {
|
||||||
get_rmanager().set_predicate_kind(pred, target_kind);
|
get_rmanager().set_predicate_kind(pred, target_kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rel_context::set_cancel(bool f) {
|
|
||||||
get_rmanager().set_cancel(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rel_context::setup_default_relation() {
|
void rel_context::setup_default_relation() {
|
||||||
if (m_context.default_relation() == symbol("doc")) {
|
if (m_context.default_relation() == symbol("doc")) {
|
||||||
|
|
|
@ -51,8 +51,6 @@ namespace datalog {
|
||||||
|
|
||||||
lbool saturate(scoped_query& sq);
|
lbool saturate(scoped_query& sq);
|
||||||
|
|
||||||
void set_cancel(bool f);
|
|
||||||
|
|
||||||
void setup_default_relation();
|
void setup_default_relation();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -82,8 +80,6 @@ namespace datalog {
|
||||||
|
|
||||||
virtual void collect_statistics(statistics& st) const;
|
virtual void collect_statistics(statistics& st) const;
|
||||||
|
|
||||||
virtual void cancel() { set_cancel(true); }
|
|
||||||
virtual void cleanup() { set_cancel(false);}
|
|
||||||
virtual void updt_params();
|
virtual void updt_params();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -509,7 +509,6 @@ namespace tb {
|
||||||
bool_rewriter m_rw;
|
bool_rewriter m_rw;
|
||||||
smt_params m_fparams;
|
smt_params m_fparams;
|
||||||
smt::kernel m_solver;
|
smt::kernel m_solver;
|
||||||
volatile bool m_cancel;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
index(ast_manager& m):
|
index(ast_manager& m):
|
||||||
|
@ -523,8 +522,7 @@ namespace tb {
|
||||||
m_subst(m),
|
m_subst(m),
|
||||||
m_qe(m),
|
m_qe(m),
|
||||||
m_rw(m),
|
m_rw(m),
|
||||||
m_solver(m, m_fparams),
|
m_solver(m, m_fparams) {}
|
||||||
m_cancel(false) {}
|
|
||||||
|
|
||||||
void insert(ref<clause>& g) {
|
void insert(ref<clause>& g) {
|
||||||
m_index.push_back(g);
|
m_index.push_back(g);
|
||||||
|
@ -540,17 +538,6 @@ namespace tb {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel() {
|
|
||||||
m_cancel = true;
|
|
||||||
m_solver.cancel();
|
|
||||||
m_qe.set_cancel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanup() {
|
|
||||||
m_solver.reset_cancel();
|
|
||||||
m_qe.set_cancel(false);
|
|
||||||
m_cancel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
m_index.reset();
|
m_index.reset();
|
||||||
|
@ -594,7 +581,7 @@ namespace tb {
|
||||||
|
|
||||||
// extract pre_cond => post_cond validation obligation from match.
|
// extract pre_cond => post_cond validation obligation from match.
|
||||||
bool find_match(unsigned& subsumer) {
|
bool find_match(unsigned& subsumer) {
|
||||||
for (unsigned i = 0; !m_cancel && i < m_index.size(); ++i) {
|
for (unsigned i = 0; m.limit().inc() && i < m_index.size(); ++i) {
|
||||||
if (match_rule(i)) {
|
if (match_rule(i)) {
|
||||||
subsumer = m_index[i]->get_seqno();
|
subsumer = m_index[i]->get_seqno();
|
||||||
return true;
|
return true;
|
||||||
|
@ -631,7 +618,7 @@ namespace tb {
|
||||||
|
|
||||||
app* q = g.get_predicate(predicate_index);
|
app* q = g.get_predicate(predicate_index);
|
||||||
|
|
||||||
for (unsigned i = 0; !m_cancel && i < m_preds.size(); ++i) {
|
for (unsigned i = 0; m.limit().inc() && i < m_preds.size(); ++i) {
|
||||||
app* p = m_preds[i].get();
|
app* p = m_preds[i].get();
|
||||||
m_subst.push_scope();
|
m_subst.push_scope();
|
||||||
unsigned limit = m_sideconds.size();
|
unsigned limit = m_sideconds.size();
|
||||||
|
@ -660,7 +647,7 @@ namespace tb {
|
||||||
expr_ref_vector fmls(m_sideconds);
|
expr_ref_vector fmls(m_sideconds);
|
||||||
m_subst.reset_cache();
|
m_subst.reset_cache();
|
||||||
|
|
||||||
for (unsigned i = 0; !m_cancel && i < fmls.size(); ++i) {
|
for (unsigned i = 0; m.limit().inc() && i < fmls.size(); ++i) {
|
||||||
m_subst.apply(2, deltas, expr_offset(fmls[i].get(), 0), q);
|
m_subst.apply(2, deltas, expr_offset(fmls[i].get(), 0), q);
|
||||||
fmls[i] = q;
|
fmls[i] = q;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +664,7 @@ namespace tb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_rw.mk_and(fmls.size(), fmls.c_ptr(), postcond);
|
m_rw.mk_and(fmls.size(), fmls.c_ptr(), postcond);
|
||||||
if (m_cancel) {
|
if (!m.limit().inc()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m.is_false(postcond)) {
|
if (m.is_false(postcond)) {
|
||||||
|
@ -1350,7 +1337,6 @@ namespace datalog {
|
||||||
unsigned m_seqno;
|
unsigned m_seqno;
|
||||||
tb::instruction m_instruction;
|
tb::instruction m_instruction;
|
||||||
lbool m_status;
|
lbool m_status;
|
||||||
volatile bool m_cancel;
|
|
||||||
stats m_stats;
|
stats m_stats;
|
||||||
uint_set m_displayed_rules;
|
uint_set m_displayed_rules;
|
||||||
public:
|
public:
|
||||||
|
@ -1365,8 +1351,7 @@ namespace datalog {
|
||||||
m_rules(),
|
m_rules(),
|
||||||
m_seqno(0),
|
m_seqno(0),
|
||||||
m_instruction(tb::SELECT_PREDICATE),
|
m_instruction(tb::SELECT_PREDICATE),
|
||||||
m_status(l_undef),
|
m_status(l_undef)
|
||||||
m_cancel(false)
|
|
||||||
{
|
{
|
||||||
// m_fparams.m_relevancy_lvl = 0;
|
// m_fparams.m_relevancy_lvl = 0;
|
||||||
m_fparams.m_mbqi = false;
|
m_fparams.m_mbqi = false;
|
||||||
|
@ -1393,18 +1378,9 @@ namespace datalog {
|
||||||
IF_VERBOSE(1, display_clause(*get_clause(), verbose_stream() << "g" << get_clause()->get_seqno() << " "););
|
IF_VERBOSE(1, display_clause(*get_clause(), verbose_stream() << "g" << get_clause()->get_seqno() << " "););
|
||||||
return run();
|
return run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel() {
|
|
||||||
m_cancel = true;
|
|
||||||
m_index.cleanup();
|
|
||||||
m_solver.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
m_cancel = false;
|
|
||||||
m_clauses.reset();
|
m_clauses.reset();
|
||||||
m_index.cleanup();
|
|
||||||
m_solver.reset_cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_statistics() {
|
void reset_statistics() {
|
||||||
|
@ -1519,7 +1495,7 @@ namespace datalog {
|
||||||
m_status = l_undef;
|
m_status = l_undef;
|
||||||
while (true) {
|
while (true) {
|
||||||
IF_VERBOSE(2, verbose_stream() << m_instruction << "\n";);
|
IF_VERBOSE(2, verbose_stream() << m_instruction << "\n";);
|
||||||
if (m_cancel) {
|
if (!m.limit().inc()) {
|
||||||
cleanup();
|
cleanup();
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
|
@ -1671,9 +1647,6 @@ namespace datalog {
|
||||||
lbool tab::query(expr* query) {
|
lbool tab::query(expr* query) {
|
||||||
return m_imp->query(query);
|
return m_imp->query(query);
|
||||||
}
|
}
|
||||||
void tab::cancel() {
|
|
||||||
m_imp->cancel();
|
|
||||||
}
|
|
||||||
void tab::cleanup() {
|
void tab::cleanup() {
|
||||||
m_imp->cleanup();
|
m_imp->cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace datalog {
|
||||||
tab(context& ctx);
|
tab(context& ctx);
|
||||||
~tab();
|
~tab();
|
||||||
virtual lbool query(expr* query);
|
virtual lbool query(expr* query);
|
||||||
virtual void cancel();
|
|
||||||
virtual void cleanup();
|
virtual void cleanup();
|
||||||
virtual void reset_statistics();
|
virtual void reset_statistics();
|
||||||
virtual void collect_statistics(statistics& st) const;
|
virtual void collect_statistics(statistics& st) const;
|
||||||
|
|
|
@ -50,8 +50,7 @@ namespace datalog {
|
||||||
rm(ctx.get_rule_manager()),
|
rm(ctx.get_rule_manager()),
|
||||||
m_inner_ctx(m, ctx.get_register_engine(), ctx.get_fparams()),
|
m_inner_ctx(m, ctx.get_register_engine(), ctx.get_fparams()),
|
||||||
a(m),
|
a(m),
|
||||||
m_pinned(m),
|
m_pinned(m) {
|
||||||
m_cancel(false) {
|
|
||||||
params_ref params;
|
params_ref params;
|
||||||
params.set_sym("default_relation", symbol("karr_relation"));
|
params.set_sym("default_relation", symbol("karr_relation"));
|
||||||
params.set_sym("engine", symbol("datalog"));
|
params.set_sym("engine", symbol("datalog"));
|
||||||
|
@ -189,11 +188,6 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void mk_karr_invariants::cancel() {
|
|
||||||
m_cancel = true;
|
|
||||||
m_inner_ctx.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
rule_set * mk_karr_invariants::operator()(rule_set const & source) {
|
rule_set * mk_karr_invariants::operator()(rule_set const & source) {
|
||||||
if (!m_ctx.karr()) {
|
if (!m_ctx.karr()) {
|
||||||
|
@ -214,7 +208,7 @@ namespace datalog {
|
||||||
|
|
||||||
get_invariants(*src_loop);
|
get_invariants(*src_loop);
|
||||||
|
|
||||||
if (m_cancel) {
|
if (!m.limit().inc()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ namespace datalog {
|
||||||
arith_util a;
|
arith_util a;
|
||||||
obj_map<func_decl, expr*> m_fun2inv;
|
obj_map<func_decl, expr*> m_fun2inv;
|
||||||
ast_ref_vector m_pinned;
|
ast_ref_vector m_pinned;
|
||||||
volatile bool m_cancel;
|
|
||||||
|
|
||||||
void get_invariants(rule_set const& src);
|
void get_invariants(rule_set const& src);
|
||||||
|
|
||||||
|
@ -67,8 +66,6 @@ namespace datalog {
|
||||||
mk_karr_invariants(context & ctx, unsigned priority);
|
mk_karr_invariants(context & ctx, unsigned priority);
|
||||||
|
|
||||||
virtual ~mk_karr_invariants();
|
virtual ~mk_karr_invariants();
|
||||||
|
|
||||||
virtual void cancel();
|
|
||||||
|
|
||||||
rule_set * operator()(rule_set const & source);
|
rule_set * operator()(rule_set const & source);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace opt {
|
||||||
bool empty() const { return 0 == size(); }
|
bool empty() const { return 0 == size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile bool m_cancel;
|
reslimit& m_limit;
|
||||||
rational m_lower;
|
rational m_lower;
|
||||||
rational m_upper;
|
rational m_upper;
|
||||||
vector<rational> m_weights;
|
vector<rational> m_weights;
|
||||||
|
@ -144,8 +144,8 @@ namespace opt {
|
||||||
|
|
||||||
static unsigned const null_idx = UINT_MAX;
|
static unsigned const null_idx = UINT_MAX;
|
||||||
|
|
||||||
imp():
|
imp(reslimit& lim):
|
||||||
m_cancel(false),
|
m_limit(lim),
|
||||||
m_max_weight(0),
|
m_max_weight(0),
|
||||||
m_denominator(1),
|
m_denominator(1),
|
||||||
m_alloc("hitting-sets"),
|
m_alloc("hitting-sets"),
|
||||||
|
@ -155,6 +155,7 @@ namespace opt {
|
||||||
m_scope_lvl(0),
|
m_scope_lvl(0),
|
||||||
m_compare_scores(),
|
m_compare_scores(),
|
||||||
m_heap(0, m_compare_scores),
|
m_heap(0, m_compare_scores),
|
||||||
|
m_simplex(lim),
|
||||||
m_weights_var(0) {
|
m_weights_var(0) {
|
||||||
m_enable_simplex = true;
|
m_enable_simplex = true;
|
||||||
m_compare_scores.m_imp = this;
|
m_compare_scores.m_imp = this;
|
||||||
|
@ -298,11 +299,6 @@ namespace opt {
|
||||||
m_model[idx] == l_true;
|
m_model[idx] == l_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_cancel(bool f) {
|
|
||||||
m_cancel = f;
|
|
||||||
m_simplex.set_cancel(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void collect_statistics(::statistics& st) const {
|
void collect_statistics(::statistics& st) const {
|
||||||
m_simplex.collect_statistics(st);
|
m_simplex.collect_statistics(st);
|
||||||
}
|
}
|
||||||
|
@ -641,7 +637,7 @@ namespace opt {
|
||||||
|
|
||||||
inline unsigned scope_lvl() const { return m_scope_lvl; }
|
inline unsigned scope_lvl() const { return m_scope_lvl; }
|
||||||
inline bool inconsistent() const { return m_inconsistent; }
|
inline bool inconsistent() const { return m_inconsistent; }
|
||||||
inline bool canceled() const { return m_cancel; }
|
inline bool canceled() const { return !m_limit.inc(); }
|
||||||
inline unsigned lvl(unsigned idx) const { return m_level[idx]; }
|
inline unsigned lvl(unsigned idx) const { return m_level[idx]; }
|
||||||
inline lbool value(unsigned idx) const { return m_value[idx]; }
|
inline lbool value(unsigned idx) const { return m_value[idx]; }
|
||||||
|
|
||||||
|
@ -1073,7 +1069,7 @@ namespace opt {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
hitting_sets::hitting_sets() { m_imp = alloc(imp); }
|
hitting_sets::hitting_sets(reslimit& lim) { m_imp = alloc(imp, lim); }
|
||||||
hitting_sets::~hitting_sets() { dealloc(m_imp); }
|
hitting_sets::~hitting_sets() { dealloc(m_imp); }
|
||||||
void hitting_sets::add_weight(rational const& w) { m_imp->add_weight(w); }
|
void hitting_sets::add_weight(rational const& w) { m_imp->add_weight(w); }
|
||||||
void hitting_sets::add_exists_true(unsigned sz, unsigned const* elems) { m_imp->add_exists_true(sz, elems); }
|
void hitting_sets::add_exists_true(unsigned sz, unsigned const* elems) { m_imp->add_exists_true(sz, elems); }
|
||||||
|
@ -1084,7 +1080,6 @@ namespace opt {
|
||||||
rational hitting_sets::get_upper() { return m_imp->get_upper(); }
|
rational hitting_sets::get_upper() { return m_imp->get_upper(); }
|
||||||
void hitting_sets::set_upper(rational const& r) { return m_imp->set_upper(r); }
|
void hitting_sets::set_upper(rational const& r) { return m_imp->set_upper(r); }
|
||||||
bool hitting_sets::get_value(unsigned idx) { return m_imp->get_value(idx); }
|
bool hitting_sets::get_value(unsigned idx) { return m_imp->get_value(idx); }
|
||||||
void hitting_sets::set_cancel(bool f) { m_imp->set_cancel(f); }
|
|
||||||
void hitting_sets::collect_statistics(::statistics& st) const { m_imp->collect_statistics(st); }
|
void hitting_sets::collect_statistics(::statistics& st) const { m_imp->collect_statistics(st); }
|
||||||
void hitting_sets::reset() { m_imp->reset(); }
|
void hitting_sets::reset() { m_imp->reset(); }
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ Notes:
|
||||||
#include "rational.h"
|
#include "rational.h"
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "lbool.h"
|
#include "lbool.h"
|
||||||
|
#include "rlimit.h"
|
||||||
|
|
||||||
namespace opt {
|
namespace opt {
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ namespace opt {
|
||||||
struct imp;
|
struct imp;
|
||||||
imp* m_imp;
|
imp* m_imp;
|
||||||
public:
|
public:
|
||||||
hitting_sets();
|
hitting_sets(reslimit& lim);
|
||||||
~hitting_sets();
|
~hitting_sets();
|
||||||
void add_weight(rational const& w);
|
void add_weight(rational const& w);
|
||||||
void add_exists_true(unsigned sz, unsigned const* elems);
|
void add_exists_true(unsigned sz, unsigned const* elems);
|
||||||
|
|
|
@ -77,6 +77,7 @@ namespace opt {
|
||||||
public:
|
public:
|
||||||
maxhs(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft):
|
maxhs(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft):
|
||||||
maxsmt_solver_base(c, ws, soft),
|
maxsmt_solver_base(c, ws, soft),
|
||||||
|
m_hs(m.limit()),
|
||||||
m_aux(m),
|
m_aux(m),
|
||||||
m_at_lower_bound(false) {
|
m_at_lower_bound(false) {
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,6 @@ namespace opt {
|
||||||
|
|
||||||
virtual void set_cancel(bool f) {
|
virtual void set_cancel(bool f) {
|
||||||
maxsmt_solver_base::set_cancel(f);
|
maxsmt_solver_base::set_cancel(f);
|
||||||
m_hs.set_cancel(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void collect_statistics(statistics& st) const {
|
virtual void collect_statistics(statistics& st) const {
|
||||||
|
|
|
@ -896,8 +896,8 @@ namespace smt {
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
inf_eps_rational<inf_rational> theory_dense_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shared) {
|
inf_eps_rational<inf_rational> theory_dense_diff_logic<Ext>::maximize(theory_var v, expr_ref& blocker, bool& has_shared) {
|
||||||
typedef simplex::simplex<simplex::mpq_ext> Simplex;
|
typedef simplex::simplex<simplex::mpq_ext> Simplex;
|
||||||
Simplex S;
|
|
||||||
ast_manager& m = get_manager();
|
ast_manager& m = get_manager();
|
||||||
|
Simplex S(m.limit());
|
||||||
objective_term const& objective = m_objectives[v];
|
objective_term const& objective = m_objectives[v];
|
||||||
has_shared = false;
|
has_shared = false;
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,7 @@ namespace smt {
|
||||||
m_non_diff_logic_exprs(false),
|
m_non_diff_logic_exprs(false),
|
||||||
m_factory(0),
|
m_factory(0),
|
||||||
m_nc_functor(*this),
|
m_nc_functor(*this),
|
||||||
|
m_S(m.limit()),
|
||||||
m_num_simplex_edges(0) {
|
m_num_simplex_edges(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,7 @@ namespace smt {
|
||||||
theory_pb::theory_pb(ast_manager& m, theory_pb_params& p):
|
theory_pb::theory_pb(ast_manager& m, theory_pb_params& p):
|
||||||
theory(m.mk_family_id("pb")),
|
theory(m.mk_family_id("pb")),
|
||||||
m_params(p),
|
m_params(p),
|
||||||
|
m_simplex(m.limit()),
|
||||||
m_util(m),
|
m_util(m),
|
||||||
m_max_compiled_coeff(rational(8))
|
m_max_compiled_coeff(rational(8))
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,14 +98,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
|
||||||
\brief Reset cancel flag of t if this was not canceled.
|
|
||||||
*/
|
|
||||||
void parent_reset_cancel(tactic & t) {
|
|
||||||
if (!m_cancel) {
|
|
||||||
t.reset_cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void set_cancel(bool f) {
|
virtual void set_cancel(bool f) {
|
||||||
m_cancel = f;
|
m_cancel = f;
|
||||||
|
@ -390,14 +382,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
|
||||||
\brief Reset cancel flag of st if this was not canceled.
|
|
||||||
*/
|
|
||||||
void parent_reset_cancel(tactic & t) {
|
|
||||||
if (!m_cancel) {
|
|
||||||
t.reset_cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void set_cancel(bool f) {
|
virtual void set_cancel(bool f) {
|
||||||
m_cancel = f;
|
m_cancel = f;
|
||||||
|
@ -583,8 +567,10 @@ public:
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
for (unsigned j = 0; j < sz; j++) {
|
for (unsigned j = 0; j < sz; j++) {
|
||||||
if (static_cast<unsigned>(i) != j)
|
if (static_cast<unsigned>(i) != j) {
|
||||||
ts.get(j)->cancel();
|
ts.get(j)->cancel();
|
||||||
|
managers[j]->limit().cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast_translation translator(*(managers[i]), m, false);
|
ast_translation translator(*(managers[i]), m, false);
|
||||||
for (unsigned k = 0; k < _result.size(); k++) {
|
for (unsigned k = 0; k < _result.size(); k++) {
|
||||||
|
@ -784,8 +770,10 @@ public:
|
||||||
|
|
||||||
if (curr_failed) {
|
if (curr_failed) {
|
||||||
for (unsigned j = 0; j < r1_size; j++) {
|
for (unsigned j = 0; j < r1_size; j++) {
|
||||||
if (static_cast<unsigned>(i) != j)
|
if (static_cast<unsigned>(i) != j) {
|
||||||
ts2.get(j)->cancel();
|
ts2.get(j)->cancel();
|
||||||
|
managers[j]->limit().cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -804,8 +792,10 @@ public:
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
for (unsigned j = 0; j < r1_size; j++) {
|
for (unsigned j = 0; j < r1_size; j++) {
|
||||||
if (static_cast<unsigned>(i) != j)
|
if (static_cast<unsigned>(i) != j) {
|
||||||
ts2.get(j)->cancel();
|
ts2.get(j)->cancel();
|
||||||
|
managers[j]->limit().cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast_translation translator(new_m, m, false);
|
ast_translation translator(new_m, m, false);
|
||||||
SASSERT(r2.size() == 1);
|
SASSERT(r2.size() == 1);
|
||||||
|
|
|
@ -19,35 +19,36 @@ Revision History:
|
||||||
#include "rlimit.h"
|
#include "rlimit.h"
|
||||||
|
|
||||||
reslimit::reslimit():
|
reslimit::reslimit():
|
||||||
|
m_cancel(false),
|
||||||
m_count(0),
|
m_count(0),
|
||||||
m_limit(UINT_MAX) {
|
m_limit(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned reslimit::count() const {
|
uint64 reslimit::count() const {
|
||||||
return m_count;
|
return m_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reslimit::inc() {
|
bool reslimit::inc() {
|
||||||
++m_count;
|
++m_count;
|
||||||
return m_count <= m_limit;
|
return !m_cancel && (m_limit == 0 || m_count <= m_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reslimit::inc(unsigned offset) {
|
bool reslimit::inc(unsigned offset) {
|
||||||
m_count += offset;
|
m_count += offset;
|
||||||
return m_count <= m_limit;
|
return !m_cancel && (m_limit == 0 || m_count <= m_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reslimit::push(unsigned delta_limit) {
|
void reslimit::push(unsigned delta_limit) {
|
||||||
unsigned new_limit = delta_limit + m_count;
|
uint64 new_limit = delta_limit + m_count;
|
||||||
if (new_limit <= m_count) {
|
if (new_limit <= m_count) {
|
||||||
new_limit = UINT_MAX;
|
new_limit = 0;
|
||||||
}
|
}
|
||||||
m_limits.push_back(m_limit);
|
m_limits.push_back(m_limit);
|
||||||
m_limit = std::min(new_limit, m_limit);
|
m_limit = m_limit==0?new_limit:std::min(new_limit, m_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reslimit::pop() {
|
void reslimit::pop() {
|
||||||
if (m_count > m_limit) {
|
if (m_count > m_limit && m_limit > 0) {
|
||||||
m_count = m_limit;
|
m_count = m_limit;
|
||||||
}
|
}
|
||||||
m_limit = m_limits.back();
|
m_limit = m_limits.back();
|
||||||
|
|
|
@ -22,16 +22,21 @@ Revision History:
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
class reslimit {
|
class reslimit {
|
||||||
unsigned m_count;
|
volatile bool m_cancel;
|
||||||
unsigned m_limit;
|
uint64 m_count;
|
||||||
unsigned_vector m_limits;
|
uint64 m_limit;
|
||||||
|
svector<uint64> m_limits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
reslimit();
|
reslimit();
|
||||||
bool inc();
|
|
||||||
bool inc(unsigned offset);
|
|
||||||
void push(unsigned delta_limit);
|
void push(unsigned delta_limit);
|
||||||
void pop();
|
void pop();
|
||||||
unsigned count() const;
|
bool inc();
|
||||||
|
bool inc(unsigned offset);
|
||||||
|
uint64 count() const;
|
||||||
|
|
||||||
|
void cancel() { m_cancel = true; }
|
||||||
|
void reset_cancel() { m_cancel = false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class scoped_rlimit {
|
class scoped_rlimit {
|
||||||
|
|
|
@ -238,5 +238,5 @@ void get_memory_statistics(statistics& st) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_rlimit_statistics(reslimit& l, statistics& st) {
|
void get_rlimit_statistics(reslimit& l, statistics& st) {
|
||||||
st.update("rlimit count", l.count());
|
st.update("rlimit count", static_cast<double>(l.count()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue