mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
more careful resize in int_set
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
0ec12f497c
commit
c16d90307b
|
@ -24,6 +24,7 @@ namespace lp {
|
|||
// serves at a set of non-negative integers smaller than the set size
|
||||
class int_set {
|
||||
vector<int> m_data;
|
||||
vector<int> m_resize_buffer;
|
||||
public:
|
||||
vector<int> m_index;
|
||||
int_set(unsigned size): m_data(size, -1) {}
|
||||
|
@ -56,6 +57,16 @@ public:
|
|||
int operator[](unsigned j) const { return m_index[j]; }
|
||||
|
||||
void resize(unsigned size) {
|
||||
if (size < data_size()) {
|
||||
for (unsigned j: m_index) {
|
||||
if (j > size)
|
||||
m_resize_buffer.push_back(j);
|
||||
}
|
||||
for (unsigned j : m_resize_buffer)
|
||||
erase(j);
|
||||
std::cout << m_resize_buffer.size() << "\n";
|
||||
m_resize_buffer.clear();
|
||||
}
|
||||
m_data.resize(size, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -839,7 +839,6 @@ void lar_solver::solve_with_core_solver() {
|
|||
}
|
||||
m_mpq_lar_core_solver.prefix_r();
|
||||
if (costs_are_used()) {
|
||||
m_basic_columns_with_changed_cost.clear();
|
||||
m_basic_columns_with_changed_cost.resize(m_mpq_lar_core_solver.m_r_x.size());
|
||||
}
|
||||
if (use_tableau())
|
||||
|
|
|
@ -244,6 +244,7 @@ public:
|
|||
d -= this->m_costs[this->m_basis[cc.var()]] * this->m_A.get_val(cc);
|
||||
}
|
||||
if (m_d[j] != d) {
|
||||
TRACE("lar_solver", tout << "reduced costs are incorrect for column j = " << j << " should be " << d << " but we have m_d[j] = " << m_d[j] << std::endl;);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -996,9 +996,11 @@ lp_core_solver_base<T, X>::infeasibility_costs_are_correct() const {
|
|||
lp_assert(costs_on_nbasis_are_zeros());
|
||||
for (unsigned j :this->m_basis) {
|
||||
if (!infeasibility_cost_is_correct_for_column(j)) {
|
||||
TRACE("lar_solver", tout << "incorrect cost for column " << j << std::endl;);
|
||||
return false;
|
||||
}
|
||||
if (!is_zero(m_d[j])) {
|
||||
TRACE("lar_solver", tout << "non zero inf cost for basis j = " << j << std::endl;);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue