From ea964e5c3b9fa22c9c600df8200bf6cc27d1d708 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Tue, 24 Mar 2020 14:05:43 -0700 Subject: [PATCH] rename int_set to u_set Signed-off-by: Lev Nachmanson --- src/math/lp/horner.h | 2 +- src/math/lp/int_solver.h | 2 +- src/math/lp/lar_constraints.h | 32 +++++++++++++-------------- src/math/lp/lar_solver.cpp | 4 ++-- src/math/lp/lar_solver.h | 16 +++++++------- src/math/lp/lp_core_solver_base.h | 4 ++-- src/math/lp/lp_dual_core_solver.h | 8 +++---- src/math/lp/lp_dual_core_solver_def.h | 30 ++++++++++++------------- src/math/lp/lp_primal_core_solver.h | 4 ++-- src/math/lp/nla_core.h | 8 +++---- src/math/lp/square_sparse_matrix.h | 2 +- src/math/lp/{int_set.h => u_set.h} | 10 ++++----- 12 files changed, 61 insertions(+), 61 deletions(-) rename src/math/lp/{int_set.h => u_set.h} (93%) diff --git a/src/math/lp/horner.h b/src/math/lp/horner.h index 87573467a..2b6fc3cd8 100644 --- a/src/math/lp/horner.h +++ b/src/math/lp/horner.h @@ -23,7 +23,7 @@ #include "math/lp/nla_intervals.h" #include "math/lp/nex.h" #include "math/lp/cross_nested.h" -#include "math/lp/int_set.h" +#include "math/lp/u_set.h" namespace nla { class core; diff --git a/src/math/lp/int_solver.h b/src/math/lp/int_solver.h index 11568497b..a87472178 100644 --- a/src/math/lp/int_solver.h +++ b/src/math/lp/int_solver.h @@ -20,7 +20,7 @@ Revision History: #pragma once #include "math/lp/lp_settings.h" #include "math/lp/static_matrix.h" -#include "math/lp/int_set.h" +#include "math/lp/u_set.h" #include "math/lp/lar_term.h" #include "math/lp/lar_constraints.h" #include "math/lp/hnf_cutter.h" diff --git a/src/math/lp/lar_constraints.h b/src/math/lp/lar_constraints.h index 0260ab8cc..416a3b41c 100644 --- a/src/math/lp/lar_constraints.h +++ b/src/math/lp/lar_constraints.h @@ -96,7 +96,7 @@ public: }; -class constraint_set { +class constrau_set { region m_region; column_namer& m_namer; vector m_constraints; @@ -139,10 +139,10 @@ class constraint_set { } public: - constraint_set(column_namer& cn): + constrau_set(column_namer& cn): m_namer(cn) {} - ~constraint_set() { + ~constrau_set() { for (auto* c : m_constraints) c->~lar_base_constraint(); } @@ -198,15 +198,15 @@ public: bool valid_index(constraint_index ci) const { return ci < m_constraints.size(); } class active_constraints { - friend class constraint_set; - constraint_set const& cs; + friend class constrau_set; + constrau_set const& cs; public: - active_constraints(constraint_set const& cs): cs(cs) {} + active_constraints(constrau_set const& cs): cs(cs) {} class iterator { - friend class constraint_set; - constraint_set const& cs; + friend class constrau_set; + constrau_set const& cs; unsigned m_index; - iterator(constraint_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); } + iterator(constrau_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); } void next() { ++m_index; forward(); } void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; } public: @@ -224,15 +224,15 @@ public: active_constraints active() const { return active_constraints(*this); } class active_indices { - friend class constraint_set; - constraint_set const& cs; + friend class constrau_set; + constrau_set const& cs; public: - active_indices(constraint_set const& cs): cs(cs) {} + active_indices(constrau_set const& cs): cs(cs) {} class iterator { - friend class constraint_set; - constraint_set const& cs; + friend class constrau_set; + constrau_set const& cs; unsigned m_index; - iterator(constraint_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); } + iterator(constrau_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); } void next() { ++m_index; forward(); } void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; } public: @@ -288,7 +288,7 @@ public: }; -inline std::ostream& operator<<(std::ostream& out, constraint_set const& cs) { +inline std::ostream& operator<<(std::ostream& out, constrau_set const& cs) { return cs.display(out); } diff --git a/src/math/lp/lar_solver.cpp b/src/math/lp/lar_solver.cpp index acd21b79e..b36244a66 100644 --- a/src/math/lp/lar_solver.cpp +++ b/src/math/lp/lar_solver.cpp @@ -324,7 +324,7 @@ void lar_solver::push() { m_constraints.push(); } -void lar_solver::clean_popped_elements(unsigned n, int_set& set) { +void lar_solver::clean_popped_elements(unsigned n, u_set& set) { vector to_remove; for (unsigned j: set) if (j >= n) @@ -333,7 +333,7 @@ void lar_solver::clean_popped_elements(unsigned n, int_set& set) { set.erase(j); } -void lar_solver::shrink_inf_set_after_pop(unsigned n, int_set & set) { +void lar_solver::shrink_inf_set_after_pop(unsigned n, u_set & set) { clean_popped_elements(n, set); set.resize(n); } diff --git a/src/math/lp/lar_solver.h b/src/math/lp/lar_solver.h index 51885e39b..98e1031b6 100644 --- a/src/math/lp/lar_solver.h +++ b/src/math/lp/lar_solver.h @@ -93,14 +93,14 @@ public: var_register m_var_register; var_register m_term_register; stacked_vector m_columns_to_ul_pairs; - constraint_set m_constraints; + constrau_set m_constraints; // the set of column indices j such that bounds have changed for j - int_set m_columns_with_changed_bound; - int_set m_rows_with_changed_bounds; - int_set m_basic_columns_with_changed_cost; + u_set m_columns_with_changed_bound; + u_set m_rows_with_changed_bounds; + u_set m_basic_columns_with_changed_cost; // these are basic columns with the value changed, so the the corresponding row in the tableau // does not sum to zero anymore - int_set m_incorrect_columns; + u_set m_incorrect_columns; stacked_value m_crossed_bounds_column_index; // such can be found at the initialization step stacked_value m_term_count; vector m_terms; @@ -111,7 +111,7 @@ public: const vector & terms() const { return m_terms; } lar_term const& term(unsigned i) const { return *m_terms[i]; } - constraint_set const& constraints() const { return m_constraints; } + constrau_set const& constraints() const { return m_constraints; } void set_int_solver(int_solver * int_slv) { m_int_solver = int_slv; } int_solver * get_int_solver() { return m_int_solver; } @@ -333,9 +333,9 @@ public: vector get_list_of_all_var_indices() const; void push(); - static void clean_popped_elements(unsigned n, int_set& set); + static void clean_popped_elements(unsigned n, u_set& set); - static void shrink_inf_set_after_pop(unsigned n, int_set & set); + static void shrink_inf_set_after_pop(unsigned n, u_set & set); void pop(unsigned k); diff --git a/src/math/lp/lp_core_solver_base.h b/src/math/lp/lp_core_solver_base.h index a932bc615..a1dc714a7 100644 --- a/src/math/lp/lp_core_solver_base.h +++ b/src/math/lp/lp_core_solver_base.h @@ -51,7 +51,7 @@ public: return m_inf_set.size() == 0; } bool current_x_is_infeasible() const { return m_inf_set.size() != 0; } - int_set m_inf_set; + u_set m_inf_set; bool m_using_infeas_costs; @@ -83,7 +83,7 @@ public: vector m_steepest_edge_coefficients; vector m_trace_of_basis_change_vector; // the even positions are entering, the odd positions are leaving bool m_tracing_basis_changes; - int_set* m_pivoted_rows; + u_set* m_pivoted_rows; bool m_look_for_feasible_solution_only; void start_tracing_basis_changes() { diff --git a/src/math/lp/lp_dual_core_solver.h b/src/math/lp/lp_dual_core_solver.h index f4aa4b44d..b6f1707c2 100644 --- a/src/math/lp/lp_dual_core_solver.h +++ b/src/math/lp/lp_dual_core_solver.h @@ -39,7 +39,7 @@ public: T m_theta_P; int m_q; // todo : replace by a vector later - std::set m_breakpoint_set; // it is F in "Progress in the dual simplex method ..." + std::set m_breakpou_set; // it is F in "Progress in the dual simplex method ..." std::set m_flipped_boxed; std::set m_tight_set; // it is the set of all breakpoints that become tight when m_q becomes tight vector m_a_wave; @@ -124,7 +124,7 @@ public: bool can_be_breakpoint(unsigned j); - void fill_breakpoint_set(); + void fill_breakpou_set(); void DSE_FTran(); T get_delta(); @@ -183,7 +183,7 @@ public: bool tight_breakpoinst_are_all_boxed(); - T calculate_harris_delta_on_breakpoint_set(); + T calculate_harris_delta_on_breakpou_set(); void fill_tight_set_on_harris_delta(const T & harris_delta ); @@ -191,7 +191,7 @@ public: void find_q_and_tight_set(); - void erase_tight_breakpoints_and_q_from_breakpoint_set(); + void erase_tight_breakpoints_and_q_from_breakpou_set(); bool ratio_test(); diff --git a/src/math/lp/lp_dual_core_solver_def.h b/src/math/lp/lp_dual_core_solver_def.h index 1e6553458..91d8f0025 100644 --- a/src/math/lp/lp_dual_core_solver_def.h +++ b/src/math/lp/lp_dual_core_solver_def.h @@ -285,11 +285,11 @@ template bool lp_dual_core_solver::can_be_breakpo } } -template void lp_dual_core_solver::fill_breakpoint_set() { - m_breakpoint_set.clear(); +template void lp_dual_core_solver::fill_breakpou_set() { + m_breakpou_set.clear(); for (unsigned j : this->non_basis()) { if (can_be_breakpoint(j)) { - m_breakpoint_set.insert(j); + m_breakpou_set.insert(j); } } } @@ -590,11 +590,11 @@ template bool lp_dual_core_solver::tight_breakpoi return true; } -template T lp_dual_core_solver::calculate_harris_delta_on_breakpoint_set() { +template T lp_dual_core_solver::calculate_harris_delta_on_breakpou_set() { bool first_time = true; T ret = zero_of_type(); - lp_assert(m_breakpoint_set.size() > 0); - for (auto j : m_breakpoint_set) { + lp_assert(m_breakpou_set.size() > 0); + for (auto j : m_breakpou_set) { T t; if (this->x_is_at_lower_bound(j)) { t = abs((std::max(this->m_d[j], numeric_traits::zero()) + m_harris_tolerance) / this->m_pivot_row[j]); @@ -613,7 +613,7 @@ template T lp_dual_core_solver::calculate_harris_ template void lp_dual_core_solver::fill_tight_set_on_harris_delta(const T & harris_delta ){ m_tight_set.clear(); - for (auto j : m_breakpoint_set) { + for (auto j : m_breakpou_set) { if (this->x_is_at_lower_bound(j)) { if (abs(std::max(this->m_d[j], numeric_traits::zero()) / this->m_pivot_row[j]) <= harris_delta){ m_tight_set.insert(j); @@ -646,26 +646,26 @@ template void lp_dual_core_solver::find_q_on_tigh } template void lp_dual_core_solver::find_q_and_tight_set() { - T harris_del = calculate_harris_delta_on_breakpoint_set(); + T harris_del = calculate_harris_delta_on_breakpou_set(); fill_tight_set_on_harris_delta(harris_del); find_q_on_tight_set(); m_entering_boundary_position = this->get_non_basic_column_value_position(m_q); } -template void lp_dual_core_solver::erase_tight_breakpoints_and_q_from_breakpoint_set() { - m_breakpoint_set.erase(m_q); +template void lp_dual_core_solver::erase_tight_breakpoints_and_q_from_breakpou_set() { + m_breakpou_set.erase(m_q); for (auto j : m_tight_set) { - m_breakpoint_set.erase(j); + m_breakpou_set.erase(j); } } template bool lp_dual_core_solver::ratio_test() { m_sign_of_alpha_r = define_sign_of_alpha_r(); - fill_breakpoint_set(); + fill_breakpou_set(); m_flipped_boxed.clear(); int initial_delta_sign = m_delta >= numeric_traits::zero()? 1: -1; do { - if (m_breakpoint_set.empty()) { + if (m_breakpou_set.empty()) { set_status_to_tentative_dual_unbounded_or_dual_unbounded(); return false; } @@ -674,13 +674,13 @@ template bool lp_dual_core_solver::ratio_test() { if (!tight_breakpoinst_are_all_boxed()) break; T del = m_delta - delta_lost_on_flips_of_tight_breakpoints() * initial_delta_sign; if (!delta_keeps_the_sign(initial_delta_sign, del)) break; - if (m_tight_set.size() + 1 == m_breakpoint_set.size()) { + if (m_tight_set.size() + 1 == m_breakpou_set.size()) { break; // deciding not to flip since we might get stuck without finding m_q, the column entering the basis } // we can flip m_q together with the tight set and look for another breakpoint candidate for m_q and another tight set add_tight_breakpoints_and_q_to_flipped_set(); m_delta = del; - erase_tight_breakpoints_and_q_from_breakpoint_set(); + erase_tight_breakpoints_and_q_from_breakpou_set(); } while (true); m_theta_D = this->m_d[m_q] / this->m_pivot_row[m_q]; return true; diff --git a/src/math/lp/lp_primal_core_solver.h b/src/math/lp/lp_primal_core_solver.h index e891e6a3e..25a51089c 100644 --- a/src/math/lp/lp_primal_core_solver.h +++ b/src/math/lp/lp_primal_core_solver.h @@ -36,7 +36,7 @@ Revision History: #include "math/lp/lp_core_solver_base.h" #include "math/lp/breakpoint.h" #include "math/lp/binary_heap_priority_queue.h" -#include "math/lp/int_set.h" +#include "math/lp/u_set.h" namespace lp { // This core solver solves (Ax=b, lower_bound_values \leq x \leq upper_bound_values, maximize costs*x ) @@ -57,7 +57,7 @@ public: T m_converted_harris_eps; unsigned m_inf_row_index_for_tableau; bool m_bland_mode_tableau; - int_set m_left_basis_tableau; + u_set m_left_basis_tableau; unsigned m_bland_mode_threshold; unsigned m_left_basis_repeated; vector m_leaving_candidates; diff --git a/src/math/lp/nla_core.h b/src/math/lp/nla_core.h index bfc5481a4..d077d14f5 100644 --- a/src/math/lp/nla_core.h +++ b/src/math/lp/nla_core.h @@ -79,7 +79,7 @@ public: var_eqs m_evars; lp::lar_solver& m_lar_solver; vector * m_lemma_vec; - lp::int_set m_to_refine; + lp::u_set m_to_refine; tangents m_tangents; basics m_basics; order m_order; @@ -92,13 +92,13 @@ public: private: emonics m_emons; svector m_add_buffer; - mutable lp::int_set m_active_var_set; - lp::int_set m_rows; + mutable lp::u_set m_active_var_set; + lp::u_set m_rows; public: reslimit m_reslim; - const lp::int_set& active_var_set () const { return m_active_var_set;} + const lp::u_set& active_var_set () const { return m_active_var_set;} bool active_var_set_contains(unsigned j) const { return m_active_var_set.contains(j); } void insert_to_active_var_set(unsigned j) const { m_active_var_set.insert(j); } diff --git a/src/math/lp/square_sparse_matrix.h b/src/math/lp/square_sparse_matrix.h index 39713fe25..5637af99f 100644 --- a/src/math/lp/square_sparse_matrix.h +++ b/src/math/lp/square_sparse_matrix.h @@ -34,7 +34,7 @@ Revision History: #include "math/lp/eta_matrix.h" #include "math/lp/binary_heap_upair_queue.h" #include "math/lp/numeric_pair.h" -#include "math/lp/int_set.h" +#include "math/lp/u_set.h" namespace lp { // it is a square matrix template diff --git a/src/math/lp/int_set.h b/src/math/lp/u_set.h similarity index 93% rename from src/math/lp/int_set.h rename to src/math/lp/u_set.h index 7a0561c85..23833925d 100644 --- a/src/math/lp/int_set.h +++ b/src/math/lp/u_set.h @@ -15,7 +15,7 @@ Author: Revision History: - TBD use indexed_uint_set from src/util/uint_set.h, + TBD use indexed_uu_set from src/util/uu_set.h, --*/ #pragma once @@ -23,14 +23,14 @@ Revision History: #include namespace lp { // serves at a set of non-negative integers smaller than the set size -class int_set { +class u_set { svector m_data; unsigned_vector m_index; public: - int_set(unsigned size): m_data(size, -1) {} - int_set() {} - int_set(int_set const& other): + u_set(unsigned size): m_data(size, -1) {} + u_set() {} + u_set(u_set const& other): m_data(other.m_data), m_index(other.m_index) {}