3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-16 20:24:45 +00:00

moving to resource managed cancellation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-12-11 13:13:11 -08:00
parent 61dbb6168e
commit 32b6b2da44
41 changed files with 55 additions and 280 deletions

View file

@ -41,11 +41,6 @@ Notes:
namespace opt {
void optsmt::set_cancel(bool f) {
TRACE("opt", tout << "set cancel: " << f << "\n";);
m_cancel = f;
}
void optsmt::set_max(vector<inf_eps>& dst, vector<inf_eps> const& src, expr_ref_vector& fmls) {
for (unsigned i = 0; i < src.size(); ++i) {
if (src[i] >= dst[i]) {
@ -74,7 +69,7 @@ namespace opt {
expr* vars[1];
solver::scoped_push _push(*m_s);
while (is_sat == l_true && !m_cancel) {
while (is_sat == l_true && !m.canceled()) {
tmp = m.mk_fresh_const("b", m.mk_bool_sort());
vars[0] = tmp;
@ -86,7 +81,7 @@ namespace opt {
}
}
if (m_cancel || is_sat == l_undef) {
if (m.canceled() || is_sat == l_undef) {
return l_undef;
}
@ -110,11 +105,11 @@ namespace opt {
lbool is_sat = l_true;
while (is_sat == l_true && !m_cancel) {
while (is_sat == l_true && !m.canceled()) {
is_sat = update_upper();
}
if (m_cancel || is_sat == l_undef) {
if (m.canceled() || is_sat == l_undef) {
return l_undef;
}
@ -150,7 +145,7 @@ namespace opt {
lbool is_sat = l_true;
solver::scoped_push _push(*m_s);
while (!m_cancel) {
while (!m.canceled()) {
m_s->assert_expr(fml);
TRACE("opt", tout << fml << "\n";);
is_sat = m_s->check_sat(1,vars);
@ -185,7 +180,7 @@ namespace opt {
bound = m.mk_or(m_lower_fmls.size(), m_lower_fmls.c_ptr());
m_s->assert_expr(bound);
if (m_cancel) {
if (m.canceled()) {
return l_undef;
}
return basic_opt();
@ -242,7 +237,7 @@ namespace opt {
vector<inf_eps> mid;
for (unsigned i = 0; i < m_lower.size() && !m_cancel; ++i) {
for (unsigned i = 0; i < m_lower.size() && !m.canceled(); ++i) {
if (m_lower[i] < m_upper[i]) {
mid.push_back((m_upper[i]+m_lower[i])/rational(2));
bound = m_s->mk_ge(i, mid[i]);
@ -254,7 +249,7 @@ namespace opt {
}
}
bool progress = false;
for (unsigned i = 0; i < m_lower.size() && !m_cancel; ++i) {
for (unsigned i = 0; i < m_lower.size() && !m.canceled(); ++i) {
if (m_lower[i] <= mid[i] && mid[i] <= m_upper[i] && m_lower[i] < m_upper[i]) {
th.enable_record_conflict(bounds[i].get());
lbool is_sat = m_s->check_sat(1, bounds.c_ptr() + i);
@ -284,7 +279,7 @@ namespace opt {
progress = true;
}
}
if (m_cancel) {
if (m.canceled()) {
return l_undef;
}
if (!progress) {
@ -328,7 +323,7 @@ namespace opt {
for (unsigned i = 0; i < obj_index; ++i) {
commit_assignment(i);
}
while (is_sat == l_true && !m_cancel) {
while (is_sat == l_true && !m.canceled()) {
is_sat = m_s->check_sat(0, 0);
if (is_sat != l_true) break;
@ -357,8 +352,8 @@ namespace opt {
// on current state.
}
if (m_cancel || is_sat == l_undef) {
TRACE("opt", tout << "undef: " << m_cancel << " " << is_sat << "\n";);
if (m.canceled() || is_sat == l_undef) {
TRACE("opt", tout << "undef: " << m.canceled() << " " << is_sat << "\n";);
return l_undef;
}