mirror of
https://github.com/Z3Prover/z3
synced 2025-05-02 21:37:02 +00:00
Tabs, formatting.
This commit is contained in:
parent
8871cb120a
commit
00651f8f21
63 changed files with 715 additions and 717 deletions
|
@ -114,22 +114,22 @@ public :
|
|||
}
|
||||
return a * lb(j).x;
|
||||
}
|
||||
mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
|
||||
if (is_pos(a)) {
|
||||
strict = !is_zero(ub(j).y);
|
||||
return a * ub(j).x;
|
||||
}
|
||||
strict = !is_zero(lb(j).y);
|
||||
return a * lb(j).x;
|
||||
}
|
||||
const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
|
||||
if (!a_is_pos) {
|
||||
strict = !is_zero(ub(j).y);
|
||||
return ub(j).x;
|
||||
}
|
||||
strict = !is_zero(lb(j).y);
|
||||
return lb(j).x;
|
||||
}
|
||||
mpq monoid_max(const mpq & a, unsigned j, bool & strict) const {
|
||||
if (is_pos(a)) {
|
||||
strict = !is_zero(ub(j).y);
|
||||
return a * ub(j).x;
|
||||
}
|
||||
strict = !is_zero(lb(j).y);
|
||||
return a * lb(j).x;
|
||||
}
|
||||
const mpq & monoid_min_no_mult(bool a_is_pos, unsigned j, bool & strict) const {
|
||||
if (!a_is_pos) {
|
||||
strict = !is_zero(ub(j).y);
|
||||
return ub(j).x;
|
||||
}
|
||||
strict = !is_zero(lb(j).y);
|
||||
return lb(j).x;
|
||||
}
|
||||
|
||||
mpq monoid_min(const mpq & a, unsigned j, bool& strict) const {
|
||||
if (is_neg(a)) {
|
||||
|
@ -166,7 +166,7 @@ public :
|
|||
m_it.reset();
|
||||
while (m_it.next(a, j)) {
|
||||
bool str;
|
||||
bool a_is_pos = is_pos(a);
|
||||
bool a_is_pos = is_pos(a);
|
||||
mpq bound = total / a + monoid_min_no_mult(a_is_pos, j, str);
|
||||
if (a_is_pos) {
|
||||
limit_j(j, bound, true, false, strict - static_cast<int>(str) > 0);
|
||||
|
@ -192,8 +192,8 @@ public :
|
|||
m_it.reset();
|
||||
while (m_it.next(a, j)) {
|
||||
bool str;
|
||||
bool a_is_pos = is_pos(a);
|
||||
mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
|
||||
bool a_is_pos = is_pos(a);
|
||||
mpq bound = total / a + monoid_max_no_mult(a_is_pos, j, str);
|
||||
bool astrict = strict - static_cast<int>(str) > 0;
|
||||
if (a_is_pos) {
|
||||
limit_j(j, bound, true, true, astrict);
|
||||
|
|
|
@ -123,7 +123,7 @@ void add_row_for_term(const lar_term * term, unsigned term_ext_index) {
|
|||
void add_row_from_term_no_constraint(const lar_term * term, unsigned term_ext_index) {
|
||||
register_new_ext_var_index(term_ext_index);
|
||||
// j will be a new variable
|
||||
unsigned j = A_r().column_count();
|
||||
unsigned j = A_r().column_count();
|
||||
ul_pair ul(j);
|
||||
m_vars_to_ul_pairs.push_back(ul);
|
||||
add_basic_var_to_core_fields();
|
||||
|
@ -152,7 +152,7 @@ void add_basic_var_to_core_fields() {
|
|||
}
|
||||
|
||||
constraint_index add_var_bound(var_index j, lconstraint_kind kind, const mpq & right_side) {
|
||||
constraint_index ci = m_constraints.size();
|
||||
constraint_index ci = m_constraints.size();
|
||||
if (!is_term(j)) { // j is a var
|
||||
auto vc = new lar_var_constraint(j, kind, right_side);
|
||||
m_constraints.push_back(vc);
|
||||
|
@ -212,8 +212,8 @@ void add_constraint_from_term_and_create_new_column_row(unsigned term_j, const l
|
|||
}
|
||||
|
||||
void decide_on_strategy_and_adjust_initial_state() {
|
||||
lean_assert(strategy_is_undecided());
|
||||
if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
|
||||
lean_assert(strategy_is_undecided());
|
||||
if (m_vars_to_ul_pairs.size() > m_settings.column_number_threshold_for_using_lu_in_lar_solver) {
|
||||
m_settings.simplex_strategy() = simplex_strategy_enum::lu;
|
||||
} else {
|
||||
m_settings.simplex_strategy() = simplex_strategy_enum::tableau_rows; // todo: when to switch to tableau_costs?
|
||||
|
@ -239,14 +239,14 @@ void adjust_initial_state() {
|
|||
|
||||
void adjust_initial_state_for_lu() {
|
||||
copy_from_mpq_matrix(A_d());
|
||||
unsigned n = A_d().column_count();
|
||||
m_mpq_lar_core_solver.m_d_x.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_low_bounds.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_upper_bounds.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading;
|
||||
m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis;
|
||||
unsigned n = A_d().column_count();
|
||||
m_mpq_lar_core_solver.m_d_x.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_low_bounds.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_upper_bounds.resize(n);
|
||||
m_mpq_lar_core_solver.m_d_heading = m_mpq_lar_core_solver.m_r_heading;
|
||||
m_mpq_lar_core_solver.m_d_basis = m_mpq_lar_core_solver.m_r_basis;
|
||||
|
||||
/*
|
||||
/*
|
||||
unsigned j = A_d().column_count();
|
||||
A_d().add_column();
|
||||
lean_assert(m_mpq_lar_core_solver.m_d_x.size() == j);
|
||||
|
|
|
@ -550,7 +550,7 @@ public:
|
|||
lean_assert(m_r_solver.m_basis_heading[leaving] >= 0);
|
||||
m_r_solver.change_basis_unconditionally(entering, leaving);
|
||||
if(!m_r_solver.pivot_column_tableau(entering, m_r_solver.m_basis_heading[entering])) {
|
||||
// unroll the last step
|
||||
// unroll the last step
|
||||
m_r_solver.change_basis_unconditionally(leaving, entering);
|
||||
#ifdef LEAN_DEBUG
|
||||
bool t =
|
||||
|
|
|
@ -380,8 +380,8 @@ public:
|
|||
|
||||
|
||||
bool term_is_used_as_row(unsigned term) const {
|
||||
lean_assert(is_term(term));
|
||||
return contains(m_ext_vars_to_columns, term);
|
||||
lean_assert(is_term(term));
|
||||
return contains(m_ext_vars_to_columns, term);
|
||||
}
|
||||
|
||||
void propagate_bounds_on_terms(lp_bound_propagator & bp) {
|
||||
|
@ -484,16 +484,16 @@ public:
|
|||
|
||||
void pop(unsigned k) {
|
||||
int n_was = static_cast<int>(m_ext_vars_to_columns.size());
|
||||
m_status.pop(k);
|
||||
m_infeasible_column_index.pop(k);
|
||||
m_status.pop(k);
|
||||
m_infeasible_column_index.pop(k);
|
||||
unsigned n = m_vars_to_ul_pairs.peek_size(k);
|
||||
for (unsigned j = n_was; j-- > n;)
|
||||
m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]);
|
||||
m_columns_to_ext_vars_or_term_indices.resize(n);
|
||||
if (m_settings.use_tableau()) {
|
||||
for (unsigned j = n_was; j-- > n;)
|
||||
m_ext_vars_to_columns.erase(m_columns_to_ext_vars_or_term_indices[j]);
|
||||
m_columns_to_ext_vars_or_term_indices.resize(n);
|
||||
if (m_settings.use_tableau()) {
|
||||
pop_tableau();
|
||||
}
|
||||
m_vars_to_ul_pairs.pop(k);
|
||||
m_vars_to_ul_pairs.pop(k);
|
||||
|
||||
m_mpq_lar_core_solver.pop(k);
|
||||
clean_large_elements_after_pop(n, m_columns_with_changed_bound);
|
||||
|
@ -501,7 +501,7 @@ public:
|
|||
clean_large_elements_after_pop(m, m_rows_with_changed_bounds);
|
||||
clean_inf_set_of_r_solver_after_pop();
|
||||
lean_assert(m_settings.simplex_strategy() == simplex_strategy_enum::undecided ||
|
||||
(!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
|
||||
(!use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
|
||||
|
||||
|
||||
lean_assert(ax_is_correct());
|
||||
|
@ -518,9 +518,9 @@ public:
|
|||
}
|
||||
m_terms.resize(m_term_count);
|
||||
m_orig_terms.resize(m_term_count);
|
||||
m_simplex_strategy.pop(k);
|
||||
m_settings.simplex_strategy() = m_simplex_strategy;
|
||||
lean_assert(sizes_are_correct());
|
||||
m_simplex_strategy.pop(k);
|
||||
m_settings.simplex_strategy() = m_simplex_strategy;
|
||||
lean_assert(sizes_are_correct());
|
||||
lean_assert((!m_settings.use_tableau()) || m_mpq_lar_core_solver.m_r_solver.reduced_costs_are_correct_tableau());
|
||||
}
|
||||
|
||||
|
@ -967,8 +967,8 @@ public:
|
|||
|
||||
template <typename U, typename V>
|
||||
void copy_from_mpq_matrix(static_matrix<U, V> & matr) {
|
||||
matr.m_rows.resize(A_r().row_count());
|
||||
matr.m_columns.resize(A_r().column_count());
|
||||
matr.m_rows.resize(A_r().row_count());
|
||||
matr.m_columns.resize(A_r().column_count());
|
||||
for (unsigned i = 0; i < matr.row_count(); i++) {
|
||||
for (auto & it : A_r().m_rows[i]) {
|
||||
matr.set(i, it.m_j, convert_struct<U, mpq>::convert(it.get_val()));
|
||||
|
|
|
@ -17,11 +17,11 @@ const impq & lp_bound_propagator::get_upper_bound(unsigned j) const {
|
|||
}
|
||||
void lp_bound_propagator::try_add_bound(const mpq & v, unsigned j, bool is_low, bool coeff_before_j_is_pos, unsigned row_or_term_index, bool strict) {
|
||||
unsigned term_j = m_lar_solver.adjust_column_index_to_term_index(j);
|
||||
mpq w = v;
|
||||
if (term_j != j) {
|
||||
j = term_j;
|
||||
w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back
|
||||
}
|
||||
mpq w = v;
|
||||
if (term_j != j) {
|
||||
j = term_j;
|
||||
w += m_lar_solver.get_term(term_j).m_v; // when terms are turned into the columns they "lose" the right side, at this moment they aquire it back
|
||||
}
|
||||
lconstraint_kind kind = is_low? GE : LE;
|
||||
if (strict)
|
||||
kind = static_cast<lconstraint_kind>(kind / 2);
|
||||
|
|
|
@ -278,13 +278,13 @@ public:
|
|||
return m_simplex_strategy;
|
||||
}
|
||||
|
||||
bool use_lu() const {
|
||||
return m_simplex_strategy == simplex_strategy_enum::lu;
|
||||
}
|
||||
bool use_lu() const {
|
||||
return m_simplex_strategy == simplex_strategy_enum::lu;
|
||||
}
|
||||
|
||||
bool use_tableau() const {
|
||||
return m_simplex_strategy == simplex_strategy_enum::tableau_rows ||
|
||||
m_simplex_strategy == simplex_strategy_enum::tableau_costs;
|
||||
return m_simplex_strategy == simplex_strategy_enum::tableau_rows ||
|
||||
m_simplex_strategy == simplex_strategy_enum::tableau_costs;
|
||||
}
|
||||
|
||||
bool use_tableau_rows() const {
|
||||
|
|
|
@ -18,7 +18,7 @@ bool try_get_val(const std::unordered_map<A,B> & map, const A& key, B & val) {
|
|||
|
||||
template <typename A, typename B>
|
||||
bool contains(const std::unordered_map<A, B> & map, const A& key) {
|
||||
return map.find(key) != map.end();
|
||||
return map.find(key) != map.end();
|
||||
}
|
||||
|
||||
#ifdef lp_for_z3
|
||||
|
|
|
@ -51,10 +51,10 @@ public:
|
|||
|
||||
private:
|
||||
void emplace_replace(unsigned i,const B & b) {
|
||||
if (m_vector[i] != b) {
|
||||
m_changes.push_back(std::make_pair(i, m_vector[i]));
|
||||
m_vector[i] = b;
|
||||
}
|
||||
if (m_vector[i] != b) {
|
||||
m_changes.push_back(std::make_pair(i, m_vector[i]));
|
||||
m_vector[i] = b;
|
||||
}
|
||||
}
|
||||
public:
|
||||
|
||||
|
@ -87,14 +87,14 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void pop_tail(vector<T> & v, unsigned k) {
|
||||
lean_assert(v.size() >= k);
|
||||
v.resize(v.size() - k);
|
||||
}
|
||||
void pop_tail(vector<T> & v, unsigned k) {
|
||||
lean_assert(v.size() >= k);
|
||||
v.resize(v.size() - k);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void resize(vector<T> & v, unsigned new_size) {
|
||||
v.resize(new_size);
|
||||
v.resize(new_size);
|
||||
}
|
||||
|
||||
void pop(unsigned k) {
|
||||
|
@ -156,10 +156,10 @@ public:
|
|||
m_vector.resize(m_vector.size() + 1);
|
||||
}
|
||||
|
||||
unsigned peek_size(unsigned k) const {
|
||||
lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
|
||||
return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
|
||||
}
|
||||
unsigned peek_size(unsigned k) const {
|
||||
lean_assert(k > 0 && k <= m_stack_of_vector_sizes.size());
|
||||
return m_stack_of_vector_sizes[m_stack_of_vector_sizes.size() - k];
|
||||
}
|
||||
|
||||
const vector<B>& operator()() const { return m_vector; }
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ class static_matrix
|
|||
dim(unsigned m, unsigned n) :m_m(m), m_n(n) {}
|
||||
};
|
||||
std::stack<dim> m_stack;
|
||||
vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting
|
||||
vector<unsigned> m_became_zeros; // the row indices that became zeroes during the pivoting
|
||||
public:
|
||||
typedef vector<row_cell<T>> row_strip;
|
||||
typedef vector<column_cell> column_strip;
|
||||
|
|
|
@ -49,8 +49,8 @@ public:
|
|||
&& m_upper_bound_witness == p.m_upper_bound_witness &&
|
||||
m_i == p.m_i;
|
||||
}
|
||||
// empty constructor
|
||||
ul_pair() :
|
||||
// empty constructor
|
||||
ul_pair() :
|
||||
m_low_bound_witness(static_cast<constraint_index>(-1)),
|
||||
m_upper_bound_witness(static_cast<constraint_index>(-1)),
|
||||
m_i(static_cast<row_index>(-1))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue