3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00

fix init reorder warning

Signed-off-by: Lev Nachmanson <levnach@microsoft.com>
This commit is contained in:
Lev Nachmanson 2017-05-11 10:54:18 -07:00
parent 431feab1bf
commit cf8b35a6f3
9 changed files with 38 additions and 29 deletions

View file

@ -656,8 +656,8 @@ namespace smt {
m_asserted_qhead(0), m_asserted_qhead(0),
m_assume_eq_head(0), m_assume_eq_head(0),
m_num_conflicts(0), m_num_conflicts(0),
m_solver(0),
m_model_eqs(DEFAULT_HASHTABLE_INITIAL_CAPACITY, var_value_hash(*this), var_value_eq(*this)), m_model_eqs(DEFAULT_HASHTABLE_INITIAL_CAPACITY, var_value_hash(*this), var_value_eq(*this)),
m_solver(0),
m_resource_limit(*this) { m_resource_limit(*this) {
} }

View file

@ -18,6 +18,7 @@ namespace lean {
template <typename T, typename X> // X represents the type of the x variable and the bounds template <typename T, typename X> // X represents the type of the x variable and the bounds
class lp_core_solver_base { class lp_core_solver_base {
unsigned m_total_iterations; unsigned m_total_iterations;
unsigned m_iters_with_no_cost_growing;
unsigned inc_total_iterations() { ++m_settings.st().m_total_iterations; return m_total_iterations++; } unsigned inc_total_iterations() { ++m_settings.st().m_total_iterations; return m_total_iterations++; }
private: private:
lp_status m_status; lp_status m_status;
@ -47,7 +48,6 @@ public:
indexed_vector<T> m_w; // the vector featuring in 24.3 of the Chvatal book indexed_vector<T> m_w; // the vector featuring in 24.3 of the Chvatal book
vector<T> m_d; // the vector of reduced costs vector<T> m_d; // the vector of reduced costs
indexed_vector<T> m_ed; // the solution of B*m_ed = a indexed_vector<T> m_ed; // the solution of B*m_ed = a
unsigned m_iters_with_no_cost_growing;
const vector<column_type> & m_column_types; const vector<column_type> & m_column_types;
const vector<X> & m_low_bounds; const vector<X> & m_low_bounds;
const vector<X> & m_upper_bounds; const vector<X> & m_upper_bounds;
@ -678,6 +678,13 @@ public:
lean_assert(is_zero(this->m_costs[j])); lean_assert(is_zero(this->m_costs[j]));
} }
return true; return true;
} }
unsigned & iters_with_no_cost_growing() {
return m_iters_with_no_cost_growing;
}
const unsigned & iters_with_no_cost_growing() const {
return m_iters_with_no_cost_growing;
}
}; };
} }

View file

@ -22,6 +22,8 @@ lp_core_solver_base(static_matrix<T, X> & A,
const vector<column_type> & column_types, const vector<column_type> & column_types,
const vector<X> & low_bound_values, const vector<X> & low_bound_values,
const vector<X> & upper_bound_values): const vector<X> & upper_bound_values):
m_total_iterations(0),
m_iters_with_no_cost_growing(0),
m_status(FEASIBLE), m_status(FEASIBLE),
m_inf_set(A.column_count()), m_inf_set(A.column_count()),
m_using_infeas_costs(false), m_using_infeas_costs(false),
@ -50,10 +52,7 @@ lp_core_solver_base(static_matrix<T, X> & A,
m_steepest_edge_coefficients(A.column_count()), m_steepest_edge_coefficients(A.column_count()),
m_tracing_basis_changes(false), m_tracing_basis_changes(false),
m_pivoted_rows(nullptr), m_pivoted_rows(nullptr),
m_look_for_feasible_solution_only(false), m_look_for_feasible_solution_only(false) {
m_total_iterations(0),
m_iters_with_no_cost_growing(0)
{
lean_assert(bounds_for_boxed_are_set_correctly()); lean_assert(bounds_for_boxed_are_set_correctly());
init(); init();
init_basis_heading_and_non_basic_columns_vector(); init_basis_heading_and_non_basic_columns_vector();

View file

@ -429,7 +429,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::basis_change_a
if (snap_runaway_nonbasic_column(m_p)) { if (snap_runaway_nonbasic_column(m_p)) {
if (!this->find_x_by_solving()) { if (!this->find_x_by_solving()) {
revert_to_previous_basis(); revert_to_previous_basis();
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
return false; return false;
} }
} }
@ -437,7 +437,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::basis_change_a
if (!problem_is_dual_feasible()) { if (!problem_is_dual_feasible()) {
// todo : shift the costs!!!! // todo : shift the costs!!!!
revert_to_previous_basis(); revert_to_previous_basis();
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
return false; return false;
} }
@ -730,14 +730,14 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::solve() { // s
lean_assert(problem_is_dual_feasible()); lean_assert(problem_is_dual_feasible());
lean_assert(this->basis_heading_is_correct()); lean_assert(this->basis_heading_is_correct());
this->set_total_iterations(0); this->set_total_iterations(0);
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
do { do {
if (this->print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over("", *this->m_settings.get_message_ostream())){ if (this->print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over("", *this->m_settings.get_message_ostream())){
return; return;
} }
one_iteration(); one_iteration();
} while (this->get_status() != FLOATING_POINT_ERROR && this->get_status() != DUAL_UNBOUNDED && this->get_status() != OPTIMAL && } while (this->get_status() != FLOATING_POINT_ERROR && this->get_status() != DUAL_UNBOUNDED && this->get_status() != OPTIMAL &&
this->m_iters_with_no_cost_growing <= this->m_settings.max_number_of_iterations_with_no_improvements this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
&& this->total_iterations() <= this->m_settings.max_total_number_of_iterations); && this->total_iterations() <= this->m_settings.max_total_number_of_iterations);
} }
} }

View file

@ -905,8 +905,8 @@ public:
column_type_array, column_type_array,
low_bound_values, low_bound_values,
upper_bound_values), upper_bound_values),
m_epsilon_of_reduced_cost(T(1)/T(10000000)),
m_beta(A.row_count()), m_beta(A.row_count()),
m_epsilon_of_reduced_cost(T(1)/T(10000000)),
m_bland_mode_threshold(1000) { m_bland_mode_threshold(1000) {
if (!(numeric_traits<T>::precise())) { if (!(numeric_traits<T>::precise())) {

View file

@ -628,7 +628,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::backup_an
template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run() { template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run() {
this->m_basis_sort_counter = 0; // to initiate the sort of the basis this->m_basis_sort_counter = 0; // to initiate the sort of the basis
this->set_total_iterations(0); this->set_total_iterations(0);
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
init_inf_set(); init_inf_set();
if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only) if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
return; return;
@ -664,7 +664,7 @@ void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving(int entering
this->init_lu(); this->init_lu();
if (!this->find_x_by_solving()) { if (!this->find_x_by_solving()) {
this->restore_x(entering, t * m_sign_of_entering_delta); this->restore_x(entering, t * m_sign_of_entering_delta);
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
LP_OUT(this->m_settings, "failing in advance_on_entering_equal_leaving for entering = " << entering << std::endl); LP_OUT(this->m_settings, "failing in advance_on_entering_equal_leaving for entering = " << entering << std::endl);
return; return;
} }
@ -679,7 +679,7 @@ void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving(int entering
if (need_to_switch_costs() ||!this->current_x_is_feasible()) { if (need_to_switch_costs() ||!this->current_x_is_feasible()) {
init_reduced_costs(); init_reduced_costs();
} }
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
} }
template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_entering_and_leaving(int entering, int leaving, X & t) { template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_entering_and_leaving(int entering, int leaving, X & t) {
@ -699,14 +699,14 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
if (!pivot_compare_result){;} if (!pivot_compare_result){;}
else if (pivot_compare_result == 2) { // the sign is changed, cannot continue else if (pivot_compare_result == 2) { // the sign is changed, cannot continue
this->set_status(UNSTABLE); this->set_status(UNSTABLE);
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
return; return;
} else { } else {
lean_assert(pivot_compare_result == 1); lean_assert(pivot_compare_result == 1);
this->init_lu(); this->init_lu();
if (this->m_factorization == nullptr || this->m_factorization->get_status() != LU_status::OK) { if (this->m_factorization == nullptr || this->m_factorization->get_status() != LU_status::OK) {
this->set_status(UNSTABLE); this->set_status(UNSTABLE);
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
return; return;
} }
} }
@ -728,7 +728,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
} }
if (!is_zero(t)) { if (!is_zero(t)) {
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
init_infeasibility_after_update_x_if_inf(leaving); init_infeasibility_after_update_x_if_inf(leaving);
} }
@ -783,7 +783,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::advance_on_e
this->init_lu(); this->init_lu();
init_reduced_costs(); init_reduced_costs();
if (refresh_result == 2) { if (refresh_result == 2) {
this->m_iters_with_no_cost_growing++; this->iters_with_no_cost_growing()++;
return; return;
} }
} }
@ -934,7 +934,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
&& &&
this->get_status() != INFEASIBLE this->get_status() != INFEASIBLE
&& &&
this->m_iters_with_no_cost_growing <= this->m_settings.max_number_of_iterations_with_no_improvements this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
&& &&
this->total_iterations() <= this->m_settings.max_total_number_of_iterations this->total_iterations() <= this->m_settings.max_total_number_of_iterations
&& &&

View file

@ -169,7 +169,7 @@ unsigned lp_primal_core_solver<T, X>::solve_with_tableau() {
&& &&
this->get_status() != INFEASIBLE this->get_status() != INFEASIBLE
&& &&
this->m_iters_with_no_cost_growing <= this->m_settings.max_number_of_iterations_with_no_improvements this->iters_with_no_cost_growing() <= this->m_settings.max_number_of_iterations_with_no_improvements
&& &&
this->total_iterations() <= this->m_settings.max_total_number_of_iterations this->total_iterations() <= this->m_settings.max_total_number_of_iterations
&& &&
@ -202,7 +202,7 @@ template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_en
} }
this->update_basis_and_x_tableau(entering, leaving, t); this->update_basis_and_x_tableau(entering, leaving, t);
lean_assert(this->A_mult_x_is_off() == false); lean_assert(this->A_mult_x_is_off() == false);
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
} else { } else {
this->pivot_column_tableau(entering, this->m_basis_heading[leaving]); this->pivot_column_tableau(entering, this->m_basis_heading[leaving]);
this->change_basis(entering, leaving); this->change_basis(entering, leaving);
@ -233,7 +233,7 @@ void lp_primal_core_solver<T, X>::advance_on_entering_equal_leaving_tableau(int
if (need_to_switch_costs()) { if (need_to_switch_costs()) {
init_reduced_costs_tableau(); init_reduced_costs_tableau();
} }
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
} }
template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_and_t_tableau(unsigned entering, X & t) { template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_and_t_tableau(unsigned entering, X & t) {
unsigned k = 0; unsigned k = 0;
@ -302,7 +302,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run_tab
lean_assert(basis_columns_are_set_correctly()); lean_assert(basis_columns_are_set_correctly());
this->m_basis_sort_counter = 0; // to initiate the sort of the basis this->m_basis_sort_counter = 0; // to initiate the sort of the basis
this->set_total_iterations(0); this->set_total_iterations(0);
this->m_iters_with_no_cost_growing = 0; this->iters_with_no_cost_growing() = 0;
lean_assert(this->inf_set_is_correct()); lean_assert(this->inf_set_is_correct());
if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only) if (this->current_x_is_feasible() && this->m_look_for_feasible_solution_only)
return; return;

View file

@ -122,12 +122,15 @@ class mps_reader {
row_type m_type; row_type m_type;
std::string m_name; std::string m_name;
std::unordered_map<std::string, T> m_row_columns; std::unordered_map<std::string, T> m_row_columns;
T m_right_side;
unsigned m_index; unsigned m_index;
T m_right_side;
T m_range; T m_range;
row(row_type type, std::string name, unsigned index) : m_type(type), m_name(name), m_index(index), row(row_type type, std::string name, unsigned index) :
m_right_side(zero_of_type<T>()), m_type(type),
m_range(zero_of_type<T>()) m_name(name),
m_index(index),
m_right_side(zero_of_type<T>()),
m_range(zero_of_type<T>())
{ {
} }
}; };

View file

@ -16,7 +16,6 @@ namespace lean {
template <typename T> struct numeric_pair; // forward definition template <typename T> struct numeric_pair; // forward definition
class lar_core_solver; // forward definition class lar_core_solver; // forward definition
class random_updater { class random_updater {
unsigned range ;
struct interval { struct interval {
bool upper_bound_is_set; bool upper_bound_is_set;
numeric_pair<mpq> upper_bound; numeric_pair<mpq> upper_bound;
@ -61,6 +60,7 @@ class random_updater {
}; };
std::set<var_index> m_var_set; std::set<var_index> m_var_set;
lar_core_solver & m_core_solver; lar_core_solver & m_core_solver;
unsigned range;
linear_combination_iterator<mpq>* m_column_j; // the actual column linear_combination_iterator<mpq>* m_column_j; // the actual column
interval find_shift_interval(unsigned j); interval find_shift_interval(unsigned j);
interval get_interval_of_non_basic_var(unsigned j); interval get_interval_of_non_basic_var(unsigned j);