mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
fix #4197
This commit is contained in:
parent
dc9221e4bd
commit
5e4276b0bd
|
@ -260,7 +260,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
|
|
||||||
void local_search::verify_constraint(constraint const& c) const {
|
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););
|
IF_VERBOSE(11, display(verbose_stream() << "verify ", c););
|
||||||
TRACE("sat", display(verbose_stream() << "verify ", c););
|
TRACE("sat", display(verbose_stream() << "verify ", c););
|
||||||
if (c.m_k < value) {
|
if (c.m_k < value) {
|
||||||
|
@ -278,8 +278,8 @@ namespace sat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned local_search::constraint_value(constraint const& c) const {
|
uint64_t local_search::constraint_value(constraint const& c) const {
|
||||||
unsigned value = 0;
|
uint64_t value = 0;
|
||||||
for (literal t : c) {
|
for (literal t : c) {
|
||||||
if (is_true(t)) {
|
if (is_true(t)) {
|
||||||
value += constraint_coeff(c, t);
|
value += constraint_coeff(c, t);
|
||||||
|
@ -682,7 +682,7 @@ namespace sat {
|
||||||
bool tt = cur_solution(v);
|
bool tt = cur_solution(v);
|
||||||
coeff_vector const& falsep = m_vars[v].m_watch[!tt];
|
coeff_vector const& falsep = m_vars[v].m_watch[!tt];
|
||||||
for (pbcoeff const& pbc : falsep) {
|
for (pbcoeff const& pbc : falsep) {
|
||||||
int slack = constraint_slack(pbc.m_constraint_id);
|
auto slack = constraint_slack(pbc.m_constraint_id);
|
||||||
if (slack < 0)
|
if (slack < 0)
|
||||||
++best_bsb;
|
++best_bsb;
|
||||||
else if (slack < static_cast<int>(pbc.m_coeff))
|
else if (slack < static_cast<int>(pbc.m_coeff))
|
||||||
|
@ -697,7 +697,7 @@ namespace sat {
|
||||||
coeff_vector const& falsep = m_vars[v].m_watch[!cur_solution(v)];
|
coeff_vector const& falsep = m_vars[v].m_watch[!cur_solution(v)];
|
||||||
auto it = falsep.begin(), end = falsep.end();
|
auto it = falsep.begin(), end = falsep.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
int slack = constraint_slack(it->m_constraint_id);
|
auto slack = constraint_slack(it->m_constraint_id);
|
||||||
if (slack < 0) {
|
if (slack < 0) {
|
||||||
if (bsb == best_bsb) {
|
if (bsb == best_bsb) {
|
||||||
break;
|
break;
|
||||||
|
@ -784,7 +784,7 @@ namespace sat {
|
||||||
for (auto const& pbc : truep) {
|
for (auto const& pbc : truep) {
|
||||||
unsigned ci = pbc.m_constraint_id;
|
unsigned ci = pbc.m_constraint_id;
|
||||||
constraint& c = m_constraints[ci];
|
constraint& c = m_constraints[ci];
|
||||||
int old_slack = c.m_slack;
|
auto old_slack = c.m_slack;
|
||||||
c.m_slack -= pbc.m_coeff;
|
c.m_slack -= pbc.m_coeff;
|
||||||
DEBUG_CODE(verify_slack(c););
|
DEBUG_CODE(verify_slack(c););
|
||||||
if (c.m_slack < 0 && old_slack >= 0) { // from non-negative to negative: sat -> unsat
|
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) {
|
for (auto const& pbc : falsep) {
|
||||||
unsigned ci = pbc.m_constraint_id;
|
unsigned ci = pbc.m_constraint_id;
|
||||||
constraint& c = m_constraints[ci];
|
constraint& c = m_constraints[ci];
|
||||||
int old_slack = c.m_slack;
|
auto old_slack = c.m_slack;
|
||||||
c.m_slack += pbc.m_coeff;
|
c.m_slack += pbc.m_coeff;
|
||||||
DEBUG_CODE(verify_slack(c););
|
DEBUG_CODE(verify_slack(c););
|
||||||
if (c.m_slack >= 0 && old_slack < 0) { // from negative to non-negative: unsat -> sat
|
if (c.m_slack >= 0 && old_slack < 0) { // from negative to non-negative: unsat -> sat
|
||||||
|
|
|
@ -122,7 +122,7 @@ namespace sat {
|
||||||
struct constraint {
|
struct constraint {
|
||||||
unsigned m_id;
|
unsigned m_id;
|
||||||
unsigned m_k;
|
unsigned m_k;
|
||||||
int m_slack;
|
int64_t m_slack;
|
||||||
unsigned m_size;
|
unsigned m_size;
|
||||||
literal_vector m_literals;
|
literal_vector m_literals;
|
||||||
constraint(unsigned k, unsigned id) : m_id(id), m_k(k), m_slack(0), m_size(0) {}
|
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; }
|
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 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 init();
|
||||||
void reinit();
|
void reinit();
|
||||||
|
@ -221,7 +221,7 @@ namespace sat {
|
||||||
void verify_slack(constraint const& c) const;
|
void verify_slack(constraint const& c) const;
|
||||||
void verify_slack() const;
|
void verify_slack() const;
|
||||||
bool verify_goodvar() 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;
|
unsigned constraint_coeff(constraint const& c, literal l) const;
|
||||||
void print_info(std::ostream& out);
|
void print_info(std::ostream& out);
|
||||||
void extract_model();
|
void extract_model();
|
||||||
|
|
Loading…
Reference in a new issue