diff --git a/src/util/lp/lp_core_solver_base.h b/src/util/lp/lp_core_solver_base.h index 86382dd49..03034b31d 100644 --- a/src/util/lp/lp_core_solver_base.h +++ b/src/util/lp/lp_core_solver_base.h @@ -28,37 +28,37 @@ public: bool m_using_infeas_costs; - vector m_columns_nz; // m_columns_nz[i] keeps an approximate value of non zeroes the i-th column - vector m_rows_nz; // m_rows_nz[i] keeps an approximate value of non zeroes in the i-th row - indexed_vector m_pivot_row_of_B_1; // the pivot row of the reverse of B - indexed_vector m_pivot_row; // this is the real pivot row of the simplex tableu + vector m_columns_nz; // m_columns_nz[i] keeps an approximate value of non zeroes the i-th column + vector m_rows_nz; // m_rows_nz[i] keeps an approximate value of non zeroes in the i-th row + indexed_vector m_pivot_row_of_B_1; // the pivot row of the reverse of B + indexed_vector m_pivot_row; // this is the real pivot row of the simplex tableu static_matrix & m_A; // the matrix A - vector & m_b; // the right side - vector & m_basis; - vector& m_nbasis; - vector& m_basis_heading; - vector & m_x; // a feasible solution, the fist time set in the constructor - vector & m_costs; - lp_settings & m_settings; - vector m_y; // the buffer for yB = cb + vector & m_b; // the right side + vector & m_basis; + vector& m_nbasis; + vector& m_basis_heading; + vector & m_x; // a feasible solution, the fist time set in the constructor + vector & m_costs; + lp_settings & m_settings; + vector m_y; // the buffer for yB = cb // a device that is able to solve Bx=c, xB=d, and change the basis - lu * m_factorization; - const column_namer & m_column_names; - indexed_vector m_w; // the vector featuring in 24.3 of the Chvatal book - vector m_d; // the vector of reduced costs - indexed_vector m_ed; // the solution of B*m_ed = a - unsigned m_iters_with_no_cost_growing; + lu * m_factorization; + const column_namer & m_column_names; + indexed_vector m_w; // the vector featuring in 24.3 of the Chvatal book + vector m_d; // the vector of reduced costs + indexed_vector m_ed; // the solution of B*m_ed = a + unsigned m_iters_with_no_cost_growing; const vector & m_column_types; - const vector & m_low_bounds; - const vector & m_upper_bounds; - vector m_column_norms; // the approximate squares of column norms that help choosing a profitable column - vector m_copy_of_xB; - unsigned m_basis_sort_counter; - 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; - bool m_look_for_feasible_solution_only; + const vector & m_low_bounds; + const vector & m_upper_bounds; + vector m_column_norms; // the approximate squares of column norms that help choosing a profitable column + vector m_copy_of_xB; + unsigned m_basis_sort_counter; + 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; + bool m_look_for_feasible_solution_only; void start_tracing_basis_changes() { m_trace_of_basis_change_vector.resize(0); m_tracing_basis_changes = true; diff --git a/src/util/lp/lp_core_solver_base.hpp b/src/util/lp/lp_core_solver_base.hpp index 5ae1e399c..6bd1c807c 100644 --- a/src/util/lp/lp_core_solver_base.hpp +++ b/src/util/lp/lp_core_solver_base.hpp @@ -24,6 +24,7 @@ lp_core_solver_base(static_matrix & A, const vector & upper_bound_values): m_status(FEASIBLE), m_inf_set(A.column_count()), + m_using_infeas_costs(false), m_pivot_row_of_B_1(A.row_count()), m_pivot_row(A.column_count()), m_A(A), @@ -45,14 +46,14 @@ lp_core_solver_base(static_matrix & A, m_upper_bounds(upper_bound_values), m_column_norms(m_n()), m_copy_of_xB(m_m()), - m_steepest_edge_coefficients(A.column_count()), - m_total_iterations(0), - m_using_infeas_costs(false), - m_iters_with_no_cost_growing(0), m_basis_sort_counter(0), + m_steepest_edge_coefficients(A.column_count()), m_tracing_basis_changes(false), 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()); init(); init_basis_heading_and_non_basic_columns_vector(); diff --git a/src/util/lp/lu.h b/src/util/lp/lu.h index f58c0d845..0d8163a14 100644 --- a/src/util/lp/lu.h +++ b/src/util/lp/lu.h @@ -113,22 +113,22 @@ class lu { LU_status m_status; public: // the fields - unsigned m_dim; + unsigned m_dim; static_matrix const &m_A; - permutation_matrix m_Q; - permutation_matrix m_R; - permutation_matrix m_r_wave; - sparse_matrix m_U; + permutation_matrix m_Q; + permutation_matrix m_R; + permutation_matrix m_r_wave; + sparse_matrix m_U; square_dense_submatrix* m_dense_LU; vector *> m_tail; - lp_settings & m_settings; - bool m_failure; - indexed_vector m_row_eta_work_vector; - indexed_vector m_w_for_extension; - indexed_vector m_y_copy; - indexed_vector m_ii; //to optimize the work with the m_index fields - unsigned m_refactor_counter; + lp_settings & m_settings; + bool m_failure; + indexed_vector m_row_eta_work_vector; + indexed_vector m_w_for_extension; + indexed_vector m_y_copy; + indexed_vector m_ii; //to optimize the work with the m_index fields + unsigned m_refactor_counter; // constructor // if A is an m by n matrix then basis has length m and values in [0,n); the values are all different // they represent the set of m columns diff --git a/src/util/lp/lu.hpp b/src/util/lp/lu.hpp index c0b3d19ad..b13583d17 100644 --- a/src/util/lp/lu.hpp +++ b/src/util/lp/lu.hpp @@ -111,6 +111,7 @@ template lu::lu(static_matrix const & A, vector& basis, lp_settings & settings): + m_status(LU_status::OK), m_dim(A.row_count()), m_A(A), m_Q(m_dim), @@ -118,9 +119,8 @@ lu::lu(static_matrix const & A, m_r_wave(m_dim), m_U(A, basis), // create the square matrix that eventually will be factorized m_settings(settings), - m_row_eta_work_vector(A.row_count()), - m_status(LU_status::OK), m_failure(false), + m_row_eta_work_vector(A.row_count()), m_refactor_counter(0) { lean_assert(!(numeric_traits::precise() && settings.use_tableau())); #ifdef LEAN_DEBUG diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 8fcb75e03..7256004da 100644 --- a/src/util/lp/sparse_matrix.h +++ b/src/util/lp/sparse_matrix.h @@ -44,17 +44,17 @@ class sparse_matrix } }; - unsigned m_n_of_active_elems; + unsigned m_n_of_active_elems; binary_heap_upair_queue m_pivot_queue; public: vector>> m_rows; - vector m_columns; - permutation_matrix m_row_permutation; - permutation_matrix m_column_permutation; + vector m_columns; + permutation_matrix m_row_permutation; + permutation_matrix m_column_permutation; // m_work_pivot_vector[j] = offset of elementh of j-th column in the row we are pivoting to // if the column is not present then m_work_pivot_vector[j] is -1 - vector m_work_pivot_vector; - vector m_processed; + vector m_work_pivot_vector; + vector m_processed; unsigned get_n_of_active_elems() const { return m_n_of_active_elems; } #ifdef LEAN_DEBUG diff --git a/src/util/lp/sparse_matrix.hpp b/src/util/lp/sparse_matrix.hpp index f25eadbb4..ff6ac9997 100644 --- a/src/util/lp/sparse_matrix.hpp +++ b/src/util/lp/sparse_matrix.hpp @@ -36,12 +36,12 @@ void sparse_matrix::copy_B(static_matrix const &A, vector // constructor that copies columns of the basis from A template sparse_matrix::sparse_matrix(static_matrix const &A, vector & basis) : + m_n_of_active_elems(0), m_pivot_queue(A.row_count()), m_row_permutation(A.row_count()), m_column_permutation(A.row_count()), m_work_pivot_vector(A.row_count(), -1), - m_processed(A.row_count()), - m_n_of_active_elems(0) { + m_processed(A.row_count()) { init_row_headers(); init_column_headers(); copy_B(A, basis);