mirror of
https://github.com/Z3Prover/z3
synced 2025-08-14 14:55:25 +00:00
fix bug in bound simplification in Gomory for mixed integer linear cuts, enable fixed variable redution after bugfix, add notes that rewriting bounds does not work
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
aa9c7912dc
commit
3de5af3cb0
5 changed files with 121 additions and 261 deletions
|
@ -83,14 +83,13 @@ namespace lp {
|
|||
// consider return from here if b[i] is not an integer and return i
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vector<mpq> hnf_cutter::create_b(const svector<unsigned> & basis_rows) {
|
||||
if (basis_rows.size() == m_right_sides.size())
|
||||
return m_right_sides;
|
||||
vector<mpq> b;
|
||||
for (unsigned i : basis_rows) {
|
||||
b.push_back(m_right_sides[i]);
|
||||
}
|
||||
for (unsigned i : basis_rows)
|
||||
b.push_back(m_right_sides[i]);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -98,16 +97,15 @@ namespace lp {
|
|||
int ret = -1;
|
||||
int n = 0;
|
||||
for (int i = 0; i < static_cast<int>(b.size()); i++) {
|
||||
if (is_integer(b[i])) continue;
|
||||
if (n == 0 ) {
|
||||
if (is_integer(b[i]))
|
||||
continue;
|
||||
if (n == 0) {
|
||||
lp_assert(ret == -1);
|
||||
n = 1;
|
||||
ret = i;
|
||||
} else {
|
||||
if (m_settings.random_next() % (++n) == 0) {
|
||||
ret = i;
|
||||
}
|
||||
}
|
||||
else if (m_settings.random_next() % (++n) == 0)
|
||||
ret = i;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -240,10 +238,7 @@ branch y_i >= ceil(y0_i) is impossible.
|
|||
}
|
||||
|
||||
bool hnf_cutter::hnf_has_var_with_non_integral_value() const {
|
||||
for (unsigned j : vars())
|
||||
if (!lia.get_value(j).is_int())
|
||||
return true;
|
||||
return false;
|
||||
return any_of(vars(), [&](unsigned j) { return !lia.get_value(j).is_int(); });
|
||||
}
|
||||
|
||||
bool hnf_cutter::init_terms_for_hnf_cut() {
|
||||
|
@ -252,17 +247,15 @@ branch y_i >= ceil(y0_i) is impossible.
|
|||
try_add_term_to_A_for_hnf(tv::term(i));
|
||||
return hnf_has_var_with_non_integral_value();
|
||||
}
|
||||
|
||||
|
||||
lia_move hnf_cutter::make_hnf_cut() {
|
||||
if (!init_terms_for_hnf_cut()) {
|
||||
if (!init_terms_for_hnf_cut())
|
||||
return lia_move::undef;
|
||||
}
|
||||
lia.settings().stats().m_hnf_cutter_calls++;
|
||||
TRACE("hnf_cut", tout << "settings().stats().m_hnf_cutter_calls = " << lia.settings().stats().m_hnf_cutter_calls << "\n";
|
||||
for (u_dependency* d : constraints_for_explanation()) {
|
||||
for (auto ci : lra.flatten(d))
|
||||
lra.constraints().display(tout, ci);
|
||||
}
|
||||
for (u_dependency* d : constraints_for_explanation())
|
||||
for (auto ci : lra.flatten(d))
|
||||
lra.constraints().display(tout, ci);
|
||||
tout << lra.constraints();
|
||||
);
|
||||
#ifdef Z3DEBUG
|
||||
|
@ -273,14 +266,14 @@ branch y_i >= ceil(y0_i) is impossible.
|
|||
, x0
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
if (r == lia_move::cut) {
|
||||
TRACE("hnf_cut",
|
||||
lra.print_term(lia.m_t, tout << "cut:");
|
||||
tout << " <= " << lia.m_k << std::endl;
|
||||
for (auto* dep : constraints_for_explanation())
|
||||
for (auto ci : lra.flatten(dep))
|
||||
lra.constraints().display(tout, ci);
|
||||
lra.constraints().display(tout, ci);
|
||||
);
|
||||
lp_assert(lia.current_solution_is_inf_on_cut());
|
||||
lia.settings().stats().m_hnf_cuts++;
|
||||
|
@ -291,5 +284,4 @@ branch y_i >= ceil(y0_i) is impossible.
|
|||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue