3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-22 05:43:39 +00:00

rename int_set to u_set

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2020-03-24 14:05:43 -07:00
parent bc5b68b16e
commit ea964e5c3b
12 changed files with 61 additions and 61 deletions

View file

@ -23,7 +23,7 @@
#include "math/lp/nla_intervals.h" #include "math/lp/nla_intervals.h"
#include "math/lp/nex.h" #include "math/lp/nex.h"
#include "math/lp/cross_nested.h" #include "math/lp/cross_nested.h"
#include "math/lp/int_set.h" #include "math/lp/u_set.h"
namespace nla { namespace nla {
class core; class core;

View file

@ -20,7 +20,7 @@ Revision History:
#pragma once #pragma once
#include "math/lp/lp_settings.h" #include "math/lp/lp_settings.h"
#include "math/lp/static_matrix.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_term.h"
#include "math/lp/lar_constraints.h" #include "math/lp/lar_constraints.h"
#include "math/lp/hnf_cutter.h" #include "math/lp/hnf_cutter.h"

View file

@ -96,7 +96,7 @@ public:
}; };
class constraint_set { class constrau_set {
region m_region; region m_region;
column_namer& m_namer; column_namer& m_namer;
vector<lar_base_constraint*> m_constraints; vector<lar_base_constraint*> m_constraints;
@ -139,10 +139,10 @@ class constraint_set {
} }
public: public:
constraint_set(column_namer& cn): constrau_set(column_namer& cn):
m_namer(cn) {} m_namer(cn) {}
~constraint_set() { ~constrau_set() {
for (auto* c : m_constraints) for (auto* c : m_constraints)
c->~lar_base_constraint(); c->~lar_base_constraint();
} }
@ -198,15 +198,15 @@ public:
bool valid_index(constraint_index ci) const { return ci < m_constraints.size(); } bool valid_index(constraint_index ci) const { return ci < m_constraints.size(); }
class active_constraints { class active_constraints {
friend class constraint_set; friend class constrau_set;
constraint_set const& cs; constrau_set const& cs;
public: public:
active_constraints(constraint_set const& cs): cs(cs) {} active_constraints(constrau_set const& cs): cs(cs) {}
class iterator { class iterator {
friend class constraint_set; friend class constrau_set;
constraint_set const& cs; constrau_set const& cs;
unsigned m_index; 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 next() { ++m_index; forward(); }
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; } void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; }
public: public:
@ -224,15 +224,15 @@ public:
active_constraints active() const { return active_constraints(*this); } active_constraints active() const { return active_constraints(*this); }
class active_indices { class active_indices {
friend class constraint_set; friend class constrau_set;
constraint_set const& cs; constrau_set const& cs;
public: public:
active_indices(constraint_set const& cs): cs(cs) {} active_indices(constrau_set const& cs): cs(cs) {}
class iterator { class iterator {
friend class constraint_set; friend class constrau_set;
constraint_set const& cs; constrau_set const& cs;
unsigned m_index; 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 next() { ++m_index; forward(); }
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; } void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; }
public: 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); return cs.display(out);
} }

View file

@ -324,7 +324,7 @@ void lar_solver::push() {
m_constraints.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<int> to_remove; vector<int> to_remove;
for (unsigned j: set) for (unsigned j: set)
if (j >= n) if (j >= n)
@ -333,7 +333,7 @@ void lar_solver::clean_popped_elements(unsigned n, int_set& set) {
set.erase(j); 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); clean_popped_elements(n, set);
set.resize(n); set.resize(n);
} }

View file

@ -93,14 +93,14 @@ public:
var_register m_var_register; var_register m_var_register;
var_register m_term_register; var_register m_term_register;
stacked_vector<ul_pair> m_columns_to_ul_pairs; stacked_vector<ul_pair> 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 // the set of column indices j such that bounds have changed for j
int_set m_columns_with_changed_bound; u_set m_columns_with_changed_bound;
int_set m_rows_with_changed_bounds; u_set m_rows_with_changed_bounds;
int_set m_basic_columns_with_changed_cost; u_set m_basic_columns_with_changed_cost;
// these are basic columns with the value changed, so the the corresponding row in the tableau // these are basic columns with the value changed, so the the corresponding row in the tableau
// does not sum to zero anymore // does not sum to zero anymore
int_set m_incorrect_columns; u_set m_incorrect_columns;
stacked_value<int> m_crossed_bounds_column_index; // such can be found at the initialization step stacked_value<int> m_crossed_bounds_column_index; // such can be found at the initialization step
stacked_value<unsigned> m_term_count; stacked_value<unsigned> m_term_count;
vector<lar_term*> m_terms; vector<lar_term*> m_terms;
@ -111,7 +111,7 @@ public:
const vector<lar_term*> & terms() const { return m_terms; } const vector<lar_term*> & terms() const { return m_terms; }
lar_term const& term(unsigned i) const { return *m_terms[i]; } 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; } void set_int_solver(int_solver * int_slv) { m_int_solver = int_slv; }
int_solver * get_int_solver() { return m_int_solver; } int_solver * get_int_solver() { return m_int_solver; }
@ -333,9 +333,9 @@ public:
vector<unsigned> get_list_of_all_var_indices() const; vector<unsigned> get_list_of_all_var_indices() const;
void push(); 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); void pop(unsigned k);

View file

@ -51,7 +51,7 @@ public:
return m_inf_set.size() == 0; return m_inf_set.size() == 0;
} }
bool current_x_is_infeasible() const { 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; bool m_using_infeas_costs;
@ -83,7 +83,7 @@ public:
vector<T> m_steepest_edge_coefficients; vector<T> m_steepest_edge_coefficients;
vector<unsigned> m_trace_of_basis_change_vector; // the even positions are entering, the odd positions are leaving vector<unsigned> m_trace_of_basis_change_vector; // the even positions are entering, the odd positions are leaving
bool m_tracing_basis_changes; bool m_tracing_basis_changes;
int_set* m_pivoted_rows; u_set* m_pivoted_rows;
bool m_look_for_feasible_solution_only; bool m_look_for_feasible_solution_only;
void start_tracing_basis_changes() { void start_tracing_basis_changes() {

View file

@ -39,7 +39,7 @@ public:
T m_theta_P; T m_theta_P;
int m_q; int m_q;
// todo : replace by a vector later // todo : replace by a vector later
std::set<unsigned> m_breakpoint_set; // it is F in "Progress in the dual simplex method ..." std::set<unsigned> m_breakpou_set; // it is F in "Progress in the dual simplex method ..."
std::set<unsigned> m_flipped_boxed; std::set<unsigned> m_flipped_boxed;
std::set<unsigned> m_tight_set; // it is the set of all breakpoints that become tight when m_q becomes tight std::set<unsigned> m_tight_set; // it is the set of all breakpoints that become tight when m_q becomes tight
vector<T> m_a_wave; vector<T> m_a_wave;
@ -124,7 +124,7 @@ public:
bool can_be_breakpoint(unsigned j); bool can_be_breakpoint(unsigned j);
void fill_breakpoint_set(); void fill_breakpou_set();
void DSE_FTran(); void DSE_FTran();
T get_delta(); T get_delta();
@ -183,7 +183,7 @@ public:
bool tight_breakpoinst_are_all_boxed(); 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 ); void fill_tight_set_on_harris_delta(const T & harris_delta );
@ -191,7 +191,7 @@ public:
void find_q_and_tight_set(); 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(); bool ratio_test();

View file

@ -285,11 +285,11 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::can_be_breakpo
} }
} }
template <typename T, typename X> void lp_dual_core_solver<T, X>::fill_breakpoint_set() { template <typename T, typename X> void lp_dual_core_solver<T, X>::fill_breakpou_set() {
m_breakpoint_set.clear(); m_breakpou_set.clear();
for (unsigned j : this->non_basis()) { for (unsigned j : this->non_basis()) {
if (can_be_breakpoint(j)) { if (can_be_breakpoint(j)) {
m_breakpoint_set.insert(j); m_breakpou_set.insert(j);
} }
} }
} }
@ -590,11 +590,11 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::tight_breakpoi
return true; return true;
} }
template <typename T, typename X> T lp_dual_core_solver<T, X>::calculate_harris_delta_on_breakpoint_set() { template <typename T, typename X> T lp_dual_core_solver<T, X>::calculate_harris_delta_on_breakpou_set() {
bool first_time = true; bool first_time = true;
T ret = zero_of_type<T>(); T ret = zero_of_type<T>();
lp_assert(m_breakpoint_set.size() > 0); lp_assert(m_breakpou_set.size() > 0);
for (auto j : m_breakpoint_set) { for (auto j : m_breakpou_set) {
T t; T t;
if (this->x_is_at_lower_bound(j)) { if (this->x_is_at_lower_bound(j)) {
t = abs((std::max(this->m_d[j], numeric_traits<T>::zero()) + m_harris_tolerance) / this->m_pivot_row[j]); t = abs((std::max(this->m_d[j], numeric_traits<T>::zero()) + m_harris_tolerance) / this->m_pivot_row[j]);
@ -613,7 +613,7 @@ template <typename T, typename X> T lp_dual_core_solver<T, X>::calculate_harris_
template <typename T, typename X> void lp_dual_core_solver<T, X>::fill_tight_set_on_harris_delta(const T & harris_delta ){ template <typename T, typename X> void lp_dual_core_solver<T, X>::fill_tight_set_on_harris_delta(const T & harris_delta ){
m_tight_set.clear(); 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 (this->x_is_at_lower_bound(j)) {
if (abs(std::max(this->m_d[j], numeric_traits<T>::zero()) / this->m_pivot_row[j]) <= harris_delta){ if (abs(std::max(this->m_d[j], numeric_traits<T>::zero()) / this->m_pivot_row[j]) <= harris_delta){
m_tight_set.insert(j); m_tight_set.insert(j);
@ -646,26 +646,26 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::find_q_on_tigh
} }
template <typename T, typename X> void lp_dual_core_solver<T, X>::find_q_and_tight_set() { template <typename T, typename X> void lp_dual_core_solver<T, X>::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); fill_tight_set_on_harris_delta(harris_del);
find_q_on_tight_set(); find_q_on_tight_set();
m_entering_boundary_position = this->get_non_basic_column_value_position(m_q); m_entering_boundary_position = this->get_non_basic_column_value_position(m_q);
} }
template <typename T, typename X> void lp_dual_core_solver<T, X>::erase_tight_breakpoints_and_q_from_breakpoint_set() { template <typename T, typename X> void lp_dual_core_solver<T, X>::erase_tight_breakpoints_and_q_from_breakpou_set() {
m_breakpoint_set.erase(m_q); m_breakpou_set.erase(m_q);
for (auto j : m_tight_set) { for (auto j : m_tight_set) {
m_breakpoint_set.erase(j); m_breakpou_set.erase(j);
} }
} }
template <typename T, typename X> bool lp_dual_core_solver<T, X>::ratio_test() { template <typename T, typename X> bool lp_dual_core_solver<T, X>::ratio_test() {
m_sign_of_alpha_r = define_sign_of_alpha_r(); m_sign_of_alpha_r = define_sign_of_alpha_r();
fill_breakpoint_set(); fill_breakpou_set();
m_flipped_boxed.clear(); m_flipped_boxed.clear();
int initial_delta_sign = m_delta >= numeric_traits<T>::zero()? 1: -1; int initial_delta_sign = m_delta >= numeric_traits<T>::zero()? 1: -1;
do { do {
if (m_breakpoint_set.empty()) { if (m_breakpou_set.empty()) {
set_status_to_tentative_dual_unbounded_or_dual_unbounded(); set_status_to_tentative_dual_unbounded_or_dual_unbounded();
return false; return false;
} }
@ -674,13 +674,13 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::ratio_test() {
if (!tight_breakpoinst_are_all_boxed()) break; if (!tight_breakpoinst_are_all_boxed()) break;
T del = m_delta - delta_lost_on_flips_of_tight_breakpoints() * initial_delta_sign; 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 (!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 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 // 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(); add_tight_breakpoints_and_q_to_flipped_set();
m_delta = del; m_delta = del;
erase_tight_breakpoints_and_q_from_breakpoint_set(); erase_tight_breakpoints_and_q_from_breakpou_set();
} while (true); } while (true);
m_theta_D = this->m_d[m_q] / this->m_pivot_row[m_q]; m_theta_D = this->m_d[m_q] / this->m_pivot_row[m_q];
return true; return true;

View file

@ -36,7 +36,7 @@ Revision History:
#include "math/lp/lp_core_solver_base.h" #include "math/lp/lp_core_solver_base.h"
#include "math/lp/breakpoint.h" #include "math/lp/breakpoint.h"
#include "math/lp/binary_heap_priority_queue.h" #include "math/lp/binary_heap_priority_queue.h"
#include "math/lp/int_set.h" #include "math/lp/u_set.h"
namespace lp { namespace lp {
// This core solver solves (Ax=b, lower_bound_values \leq x \leq upper_bound_values, maximize costs*x ) // 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; T m_converted_harris_eps;
unsigned m_inf_row_index_for_tableau; unsigned m_inf_row_index_for_tableau;
bool m_bland_mode_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_bland_mode_threshold;
unsigned m_left_basis_repeated; unsigned m_left_basis_repeated;
vector<unsigned> m_leaving_candidates; vector<unsigned> m_leaving_candidates;

View file

@ -79,7 +79,7 @@ public:
var_eqs<emonics> m_evars; var_eqs<emonics> m_evars;
lp::lar_solver& m_lar_solver; lp::lar_solver& m_lar_solver;
vector<lemma> * m_lemma_vec; vector<lemma> * m_lemma_vec;
lp::int_set m_to_refine; lp::u_set m_to_refine;
tangents m_tangents; tangents m_tangents;
basics m_basics; basics m_basics;
order m_order; order m_order;
@ -92,13 +92,13 @@ public:
private: private:
emonics m_emons; emonics m_emons;
svector<lpvar> m_add_buffer; svector<lpvar> m_add_buffer;
mutable lp::int_set m_active_var_set; mutable lp::u_set m_active_var_set;
lp::int_set m_rows; lp::u_set m_rows;
public: public:
reslimit m_reslim; 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); } 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); } void insert_to_active_var_set(unsigned j) const { m_active_var_set.insert(j); }

View file

@ -34,7 +34,7 @@ Revision History:
#include "math/lp/eta_matrix.h" #include "math/lp/eta_matrix.h"
#include "math/lp/binary_heap_upair_queue.h" #include "math/lp/binary_heap_upair_queue.h"
#include "math/lp/numeric_pair.h" #include "math/lp/numeric_pair.h"
#include "math/lp/int_set.h" #include "math/lp/u_set.h"
namespace lp { namespace lp {
// it is a square matrix // it is a square matrix
template <typename T, typename X> template <typename T, typename X>

View file

@ -15,7 +15,7 @@ Author:
Revision History: 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 #pragma once
@ -23,14 +23,14 @@ Revision History:
#include <ostream> #include <ostream>
namespace lp { namespace lp {
// serves at a set of non-negative integers smaller than the set size // serves at a set of non-negative integers smaller than the set size
class int_set { class u_set {
svector<int> m_data; svector<int> m_data;
unsigned_vector m_index; unsigned_vector m_index;
public: public:
int_set(unsigned size): m_data(size, -1) {} u_set(unsigned size): m_data(size, -1) {}
int_set() {} u_set() {}
int_set(int_set const& other): u_set(u_set const& other):
m_data(other.m_data), m_data(other.m_data),
m_index(other.m_index) {} m_index(other.m_index) {}