diff --git a/src/util/lp/lar_core_solver.cpp b/src/util/lp/lar_core_solver.cpp index 820f0dec3..1a79de6ed 100644 --- a/src/util/lp/lar_core_solver.cpp +++ b/src/util/lp/lar_core_solver.cpp @@ -20,14 +20,12 @@ lar_core_solver::lar_core_solver(std::vector & x, std::vector & basis, static_matrix & A, lp_settings & settings, - std::unordered_map & column_names, - std::vector & right_side, - std::vector & costs) : // right_side and costs are redundant + std::unordered_map & column_names): lp_core_solver_base(A, - right_side, + m_right_sides_dummy, basis, x, - costs, + m_costs_dummy, settings, column_names, column_types, diff --git a/src/util/lp/lar_core_solver.h b/src/util/lp/lar_core_solver.h index 6222f7710..8c06610a6 100644 --- a/src/util/lp/lar_core_solver.h +++ b/src/util/lp/lar_core_solver.h @@ -26,16 +26,17 @@ class lar_core_solver : public lp_core_solver_base { binary_heap_priority_queue m_breakpoint_indices_queue; std::vector> m_infeasible_row; int m_infeasible_row_sign = 0; - // with a breakpoint at this delta + std::vector m_right_sides_dummy; + std::vector m_costs_dummy; public: - lar_core_solver(std::vector & x, std::vector & column_types, - std::vector & low_bounds, std::vector & upper_bounds, + lar_core_solver(std::vector & x, + std::vector & column_types, + std::vector & low_bounds, + std::vector & upper_bounds, std::vector & basis, static_matrix & A, lp_settings & settings, - std::unordered_map & column_names, - std::vector & right_side, - std::vector & costs); + std::unordered_map & column_names); int get_infeasible_row_sign() const { return m_infeasible_row_sign; } diff --git a/src/util/lp/lar_core_solver_instances.cpp b/src/util/lp/lar_core_solver_instances.cpp index c89328ec3..1c56d8fb1 100644 --- a/src/util/lp/lar_core_solver_instances.cpp +++ b/src/util/lp/lar_core_solver_instances.cpp @@ -10,7 +10,14 @@ #include #include #include "util/lp/lar_core_solver.cpp" -template lean::lar_core_solver >::lar_core_solver(std::vector, std::allocator > >&, std::vector >&, std::vector, std::allocator > >&, std::vector, std::allocator > >&, std::vector >&, lean::static_matrix >&, lean::lp_settings&, std::unordered_map, std::equal_to, std::allocator > >&, std::vector, std::allocator > >&, std::vector >&); +template lean::lar_core_solver >::lar_core_solver(std::vector, std::allocator > >&, + std::vector >&, + std::vector, std::allocator > >&, + std::vector, std::allocator > >&, + std::vector >&, + lean::static_matrix >&, + lean::lp_settings&, + std::unordered_map, std::equal_to, std::allocator > >&); template void lean::lar_core_solver >::solve(); template void lean::lar_core_solver >::prefix(); template void lean::lar_core_solver >::print_column_info(unsigned int, std::ostream & out); diff --git a/src/util/lp/lar_solver.cpp b/src/util/lp/lar_solver.cpp index 5547349a8..0f30907cf 100644 --- a/src/util/lp/lar_solver.cpp +++ b/src/util/lp/lar_solver.cpp @@ -427,12 +427,6 @@ void lar_solver::update_column_info_of_normalized_constraints() { update_column_info_of_normalized_constraint(it.second); } -template -void lar_solver::init_right_sides_with_zeros(std::vector & rs) { - rs.clear(); - rs.resize(m_basis.size(), zero_of_type()); -} - mpq lar_solver::sum_of_right_sides_of_evidence(const buffer> & evidence) { mpq ret = numeric_traits::zero(); for (auto & it : evidence) { @@ -464,7 +458,6 @@ void lar_solver::prepare_independently_of_numeric_type() { template void lar_solver::prepare_core_solver_fields(static_matrix & A, std::vector & x, - std::vector & right_side_vector, std::vector & low_bound, std::vector & upper_bound) { create_matrix_A(A); @@ -472,14 +465,12 @@ void lar_solver::prepare_core_solver_fields(static_matrix & A, std::vector if (m_status == INFEASIBLE) { lean_assert(false); // not implemented } - init_right_sides_with_zeros(right_side_vector); resize_x_and_init_with_zeros(x, A.column_count()); lean_assert(m_basis.size() == A.row_count()); } template void lar_solver::prepare_core_solver_fields_with_signature(static_matrix & A, std::vector & x, - std::vector & right_side_vector, std::vector & low_bound, std::vector & upper_bound, const lar_solution_signature & signature) { create_matrix_A(A); @@ -487,15 +478,16 @@ void lar_solver::prepare_core_solver_fields_with_signature(static_matrix & if (m_status == INFEASIBLE) { lean_assert(false); // not implemented } - init_right_sides_with_zeros(right_side_vector); resize_x_and_init_with_signature(x, low_bound, upper_bound, signature); } void lar_solver::find_solution_signature_with_doubles(lar_solution_signature & signature) { static_matrix A; - std::vector x, right_side_vector, low_bounds, upper_bounds; - prepare_core_solver_fields(A, x, right_side_vector, low_bounds, upper_bounds); + std::vector x, low_bounds, upper_bounds; + prepare_core_solver_fields(A, x, low_bounds, upper_bounds); std::vector column_scale_vector; + std::vector right_side_vector(A.row_count(), 0); + scaler scaler(right_side_vector, A, m_settings.scaling_minimum, m_settings.scaling_maximum, column_scale_vector, this->m_settings); if (!scaler.scale()) { // the scale did not succeed, unscaling @@ -526,7 +518,7 @@ void lar_solver::extract_signature_from_lp_core_solver(lp_primal_core_solver m_basis; std::vector> m_x; // the solution std::unordered_map m_column_names; - std::vector> m_right_side_vector; // this vector will be all zeroes, it might change when the optimization with fixed variables will used - std::vector m_costs; canonic_left_side * m_infeasible_canonic_left_side = nullptr; // such can be found at the initialization step canonic_left_side * create_or_fetch_existing_left_side(const buffer>& left_side_par); @@ -150,9 +148,7 @@ public: m_basis, m_A, m_settings, - m_column_names, - m_right_side_vector, - m_costs) { + m_column_names) { } @@ -178,21 +174,16 @@ public: void update_column_info_of_normalized_constraints(); - template - void init_right_sides_with_zeros(std::vector & rs); - mpq sum_of_right_sides_of_evidence(const buffer> & evidence); void prepare_independently_of_numeric_type(); template void prepare_core_solver_fields(static_matrix & A, std::vector & x, - std::vector & right_side_vector, std::vector & low_bound, std::vector & upper_bound); template void prepare_core_solver_fields_with_signature(static_matrix & A, std::vector & x, - std::vector & right_side_vector, std::vector & low_bound, std::vector & upper_bound, const lar_solution_signature & signature);