From 5e4276b0bdc42ec3cd4ee234c758ae5d6b786448 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 3 May 2020 10:26:11 -0700 Subject: [PATCH] fix #4197 --- src/sat/sat_local_search.cpp | 14 +++++++------- src/sat/sat_local_search.h | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sat/sat_local_search.cpp b/src/sat/sat_local_search.cpp index 8930fc24e..954bccb6f 100644 --- a/src/sat/sat_local_search.cpp +++ b/src/sat/sat_local_search.cpp @@ -260,7 +260,7 @@ namespace sat { } void local_search::verify_constraint(constraint const& c) const { - unsigned value = constraint_value(c); + uint64_t value = constraint_value(c); IF_VERBOSE(11, display(verbose_stream() << "verify ", c);); TRACE("sat", display(verbose_stream() << "verify ", c);); if (c.m_k < value) { @@ -278,8 +278,8 @@ namespace sat { } } - unsigned local_search::constraint_value(constraint const& c) const { - unsigned value = 0; + uint64_t local_search::constraint_value(constraint const& c) const { + uint64_t value = 0; for (literal t : c) { if (is_true(t)) { value += constraint_coeff(c, t); @@ -682,7 +682,7 @@ namespace sat { bool tt = cur_solution(v); coeff_vector const& falsep = m_vars[v].m_watch[!tt]; for (pbcoeff const& pbc : falsep) { - int slack = constraint_slack(pbc.m_constraint_id); + auto slack = constraint_slack(pbc.m_constraint_id); if (slack < 0) ++best_bsb; else if (slack < static_cast(pbc.m_coeff)) @@ -697,7 +697,7 @@ namespace sat { coeff_vector const& falsep = m_vars[v].m_watch[!cur_solution(v)]; auto it = falsep.begin(), end = falsep.end(); for (; it != end; ++it) { - int slack = constraint_slack(it->m_constraint_id); + auto slack = constraint_slack(it->m_constraint_id); if (slack < 0) { if (bsb == best_bsb) { break; @@ -784,7 +784,7 @@ namespace sat { for (auto const& pbc : truep) { unsigned ci = pbc.m_constraint_id; constraint& c = m_constraints[ci]; - int old_slack = c.m_slack; + auto old_slack = c.m_slack; c.m_slack -= pbc.m_coeff; DEBUG_CODE(verify_slack(c);); if (c.m_slack < 0 && old_slack >= 0) { // from non-negative to negative: sat -> unsat @@ -794,7 +794,7 @@ namespace sat { for (auto const& pbc : falsep) { unsigned ci = pbc.m_constraint_id; constraint& c = m_constraints[ci]; - int old_slack = c.m_slack; + auto old_slack = c.m_slack; c.m_slack += pbc.m_coeff; DEBUG_CODE(verify_slack(c);); if (c.m_slack >= 0 && old_slack < 0) { // from negative to non-negative: unsat -> sat diff --git a/src/sat/sat_local_search.h b/src/sat/sat_local_search.h index 0f955a17e..e7f942b4a 100644 --- a/src/sat/sat_local_search.h +++ b/src/sat/sat_local_search.h @@ -122,7 +122,7 @@ namespace sat { struct constraint { unsigned m_id; unsigned m_k; - int m_slack; + int64_t m_slack; unsigned m_size; literal_vector m_literals; constraint(unsigned k, unsigned id) : m_id(id), m_k(k), m_slack(0), m_size(0) {} @@ -196,8 +196,8 @@ namespace sat { inline bool is_unit(literal l) const { return m_vars[l.var()].m_unit; } unsigned num_constraints() const { return m_constraints.size(); } // constraint index from 1 to num_constraint - - unsigned constraint_slack(unsigned ci) const { return m_constraints[ci].m_slack; } + + uint64_t constraint_slack(unsigned ci) const { return m_constraints[ci].m_slack; } void init(); void reinit(); @@ -221,7 +221,7 @@ namespace sat { void verify_slack(constraint const& c) const; void verify_slack() const; bool verify_goodvar() const; - unsigned constraint_value(constraint const& c) const; + uint64_t constraint_value(constraint const& c) const; unsigned constraint_coeff(constraint const& c, literal l) const; void print_info(std::ostream& out); void extract_model();