3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 20:05:51 +00:00

remove warnings in scaler and use m_cut_solver_cycle_on_var

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

detect slow propagations

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

fiddle with the stop conditions

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

get rid of constraint->m_predecessors, fix a bug in push/pop with lemmas

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

clean detection of stale lemmas in pop

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

add constraints lazily to cut_solver

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

refactor some of cut_solver classes into include files

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

prepare to index constraint from 0 to to n - 1, where n is the number of constraints

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

prepare for constraint priority

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

use priorities in active_set

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

remove unnecesessary parameters

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

speedup bound propagations

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

restore tactics

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

speedup bound propagation by avoiding some calls to propagate_constraint_only_one_unlim

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

fixes by Nikolaj

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

fix print lp_core_solver

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

work on gomory test, subs terms indices correctly

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

correct const_iterator for lar_term

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

improve static_matrix with iterators

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

make row_strip a struct

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

move row_strip outside of static_matrix

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

add const_iterator to row_strip

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

remove the hierarchy of iterators - use std::iterators

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

adding gcd_test stats and taking care of for iterators

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

restore qflia_tactic.cpp

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

run gcd_test according to settings()

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>

experiment with picking a narrow or random branch

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2018-02-25 10:52:53 -08:00
parent 6202b2f2e4
commit 2bb94ed4fe
55 changed files with 1715 additions and 1347 deletions

View file

@ -26,7 +26,6 @@ Revision History:
#include "util/lp/sparse_vector.h"
#include "util/lp/indexed_vector.h"
#include "util/lp/permutation_matrix.h"
#include "util/lp/linear_combination_iterator.h"
#include <stack>
namespace lp {
@ -35,20 +34,26 @@ struct column_cell {
unsigned m_offset; // the offset of the element in the matrix row
column_cell(unsigned i, unsigned offset) : m_i(i), m_offset(offset) {
}
};
template <typename T>
struct row_cell {
unsigned m_j; // points to the column
unsigned m_offset; // offset in column
T m_value;
row_cell(unsigned j, unsigned offset, T const & val) : m_j(j), m_offset(offset), m_value(val) {
}
const T & get_val() const { return m_value;}
T & get_val() { return m_value;}
void set_val(const T& v) { m_value = v; }
T m_value;
unsigned var() const { return m_j;}
const T & coeff() const { return m_value;}
};
template <typename T>
using row_strip = vector<row_cell<T>>;
// each assignment for this matrix should be issued only once!!!
template <typename T, typename X>
class static_matrix
@ -63,11 +68,10 @@ class static_matrix
};
std::stack<dim> m_stack;
public:
typedef vector<row_cell<T>> row_strip;
typedef vector<column_cell> column_strip;
vector<int> m_vector_of_row_offsets;
indexed_vector<T> m_work_vector;
vector<row_strip> m_rows;
vector<row_strip<T>> m_rows;
vector<column_strip> m_columns;
// starting inner classes
class ref {
@ -97,10 +101,6 @@ public:
return m_rows[c.m_i][c.m_offset].get_val();
}
row_cell<T> & get_row_cell(const column_cell & c) {
return m_rows[c.m_i][c.m_offset];
}
column_cell & get_column_cell(const row_cell<T> &rc) {
return m_columns[rc.m_j][rc.m_offset];
}
@ -132,7 +132,7 @@ public:
void add_columns_at_the_end(unsigned delta);
void add_new_element(unsigned i, unsigned j, const T & v);
void add_row() {m_rows.push_back(row_strip());}
void add_row() {m_rows.push_back(row_strip<T>());}
void add_column() {
m_columns.push_back(column_strip());
m_vector_of_row_offsets.push_back(-1);
@ -195,7 +195,7 @@ public:
//
void fix_row_indices_in_each_column_for_crossed_row(unsigned k);
void cross_out_row_from_columns(unsigned k, row_strip & row);
void cross_out_row_from_columns(unsigned k, row_strip<T> & row);
void cross_out_row_from_column(unsigned col, unsigned k);
@ -294,7 +294,7 @@ public:
// pivot row i to row ii
bool pivot_row_to_row_given_cell(unsigned i, column_cell& c, unsigned);
void scan_row_ii_to_offset_vector(const row_strip & rvals);
void scan_row_ii_to_offset_vector(const row_strip<T> & rvals);
void transpose_rows(unsigned i, unsigned ii) {
auto t = m_rows[i];
@ -313,46 +313,54 @@ public:
}
}
void fill_last_row_with_pivoting_loop_block(unsigned j, const vector<int> & basis_heading) {
int row_index = basis_heading[j];
if (row_index < 0)
return;
T & alpha = m_work_vector[j]; // the pivot alpha
if (is_zero(alpha))
return;
for (const auto & c : m_rows[row_index]) {
if (c.m_j == j) {
continue;
}
T & wv = m_work_vector.m_data[c.m_j];
bool was_zero = is_zero(wv);
wv -= alpha * c.m_value;
if (was_zero)
m_work_vector.m_index.push_back(c.m_j);
else {
if (is_zero(wv)) {
m_work_vector.erase_from_index(c.m_j);
}
}
}
alpha = zero_of_type<T>();
m_work_vector.erase_from_index(j);
}
void fill_last_row_with_pivoting(linear_combination_iterator<T> & it, const vector<int> & basis_heading) {
template <typename term>
void fill_last_row_with_pivoting(const term& row,
unsigned bj, // the index of the basis column
const vector<int> & basis_heading) {
lp_assert(numeric_traits<T>::precise());
lp_assert(row_count() > 0);
m_work_vector.resize(column_count());
T a;
unsigned j;
while (it.next(a, j)) {
m_work_vector.set_value(-a, j); // we use the form -it + 1 = 0
// we use the form -it + 1 = 0
m_work_vector.set_value(one_of_type<T>(), bj);
for (auto p : row) {
m_work_vector.set_value(-p.coeff(), p.var());
// but take care of the basis 1 later
}
it.reset();
// not iterate with pivoting
while (it.next(j)) {
int row_index = basis_heading[j];
if (row_index < 0)
continue;
T & alpha = m_work_vector[j]; // the pivot alpha
if (is_zero(alpha))
continue;
for (const auto & c : m_rows[row_index]) {
if (c.m_j == j) {
continue;
}
T & wv = m_work_vector.m_data[c.m_j];
bool was_zero = is_zero(wv);
wv -= alpha * c.m_value;
if (was_zero)
m_work_vector.m_index.push_back(c.m_j);
else {
if (is_zero(wv)) {
m_work_vector.erase_from_index(c.m_j);
}
}
}
alpha = zero_of_type<T>();
m_work_vector.erase_from_index(j);
// now iterate with pivoting
fill_last_row_with_pivoting_loop_block(bj, basis_heading);
for (auto p : row) {
fill_last_row_with_pivoting_loop_block(p.var(), basis_heading);
}
lp_assert(m_work_vector.is_OK());
unsigned last_row = row_count() - 1;
@ -382,5 +390,66 @@ public:
}
return ret;
}
struct column_cell_plus {
const column_cell & m_c;
const static_matrix& m_A;
// constructor
column_cell_plus(const column_cell & c, const static_matrix& A) :
m_c(c), m_A(A) {}
unsigned var() const { return m_c.m_i; }
const T & coeff() const { return m_A.m_rows[var()][m_c.m_offset].get_val(); }
};
struct column_container {
unsigned m_j; // the column index
const static_matrix & m_A;
column_container(unsigned j, const static_matrix& A) : m_j(j), m_A(A) {
}
struct const_iterator {
// fields
const column_cell *m_c;
const static_matrix& m_A;
//typedefs
typedef const_iterator self_type;
typedef column_cell_plus value_type;
typedef const column_cell_plus reference;
// typedef const column_cell* pointer;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
reference operator*() const {
return column_cell_plus(*m_c, m_A);
}
self_type operator++() { self_type i = *this; m_c++; return i; }
self_type operator++(int) { m_c++; return *this; }
const_iterator(const column_cell* it, const static_matrix& A) :
m_c(it),
m_A(A)
{}
bool operator==(const self_type &other) const {
return m_c == other.m_c;
}
bool operator!=(const self_type &other) const { return !(*this == other); }
};
const_iterator begin() const {
return const_iterator(m_A.m_columns[m_j].begin(), m_A);
}
const_iterator end() const {
return const_iterator(m_A.m_columns[m_j].end(), m_A);
}
};
column_container column(unsigned j) const {
return column_container(j, *this);
}
};
}