Skip to content

Commit

Permalink
more dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Mar 8, 2023
1 parent 1fb24eb commit 3efe91c
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 140 deletions.
1 change: 0 additions & 1 deletion src/math/lp/lar_core_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Copyright (c) 2017 Microsoft Corporation
#include "math/lp/indexed_vector.h"
#include "math/lp/lp_primal_core_solver.h"
#include "math/lp/stacked_vector.h"
#include "math/lp/lar_solution_signature.h"
#include "util/stacked_value.h"
namespace lp {

Expand Down
1 change: 0 additions & 1 deletion src/math/lp/lar_core_solver_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Revision History:
#include <string>
#include "util/vector.h"
#include "math/lp/lar_core_solver.h"
#include "math/lp/lar_solution_signature.h"
namespace lp {
lar_core_solver::lar_core_solver(
lp_settings & settings,
Expand Down
28 changes: 0 additions & 28 deletions src/math/lp/lar_solution_signature.h

This file was deleted.

45 changes: 0 additions & 45 deletions src/math/lp/lar_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ namespace lp {
evidence.add_pair(ul.lower_bound_witness(), -numeric_traits<mpq>::one());
}


unsigned lar_solver::get_total_iterations() const { return m_mpq_lar_core_solver.m_r_solver.total_iterations(); }

void lar_solver::push() {
m_simplex_strategy = m_settings.simplex_strategy();
m_simplex_strategy.push();
Expand Down Expand Up @@ -761,20 +758,6 @@ namespace lp {
return r;
}

bool lar_solver::x_is_correct() const {
if (m_mpq_lar_core_solver.m_r_x.size() != A_r().column_count()) {
return false;
}
for (unsigned i = 0; i < A_r().row_count(); i++) {
numeric_pair<mpq> delta = A_r().dot_product_with_row(i, m_mpq_lar_core_solver.m_r_x);
if (!delta.is_zero()) {
return false;
}
}
return true;;

}

bool lar_solver::var_is_registered(var_index vj) const {
if (tv::is_term(vj)) {
return tv::unmask_term(vj) < m_terms.size();
Expand Down Expand Up @@ -824,28 +807,6 @@ namespace lp {
return false; // it is unreachable
}

bool lar_solver::the_relations_are_of_same_type(const vector<std::pair<mpq, unsigned>>& evidence, lconstraint_kind& the_kind_of_sum) const {
unsigned n_of_G = 0, n_of_L = 0;
bool strict = false;
for (auto& it : evidence) {
mpq coeff = it.first;
constraint_index con_ind = it.second;
lconstraint_kind kind = coeff.is_pos() ?
m_constraints[con_ind].kind() :
flip_kind(m_constraints[con_ind].kind());
if (kind == GT || kind == LT)
strict = true;
if (kind == GE || kind == GT)
n_of_G++;
else if (kind == LE || kind == LT)
n_of_L++;
}
the_kind_of_sum = n_of_G ? GE : (n_of_L ? LE : EQ);
if (strict)
the_kind_of_sum = static_cast<lconstraint_kind>((static_cast<int>(the_kind_of_sum) / 2));

return n_of_G == 0 || n_of_L == 0;
}

void lar_solver::register_in_map(std::unordered_map<var_index, mpq>& coeffs, const lar_base_constraint& cn, const mpq& a) {
for (auto& it : cn.coeffs()) {
Expand Down Expand Up @@ -1227,12 +1188,6 @@ namespace lp {
insert_row_with_changed_bounds(r.var());
}



void lar_solver::pivot_fixed_vars_from_basis() {
m_mpq_lar_core_solver.m_r_solver.pivot_fixed_vars_from_basis();
}

void lar_solver::pop() {
pop(1);
}
Expand Down
12 changes: 2 additions & 10 deletions src/math/lp/lar_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ class lar_solver : public column_namer {
void update_x_and_inf_costs_for_columns_with_changed_bounds_tableau();
void solve_with_core_solver();
numeric_pair<mpq> get_basic_var_value_from_row(unsigned i);
bool x_is_correct() const;
bool all_constrained_variables_are_registered(const vector<std::pair<mpq, var_index>>& left_side);
bool all_constraints_hold() const;
bool constraint_holds(const lar_base_constraint & constr, std::unordered_map<var_index, mpq> & var_map) const;
bool the_relations_are_of_same_type(const vector<std::pair<mpq, unsigned>> & evidence, lconstraint_kind & the_kind_of_sum) const;
static void register_in_map(std::unordered_map<var_index, mpq> & coeffs, const lar_base_constraint & cn, const mpq & a);
static void register_monoid_in_map(std::unordered_map<var_index, mpq> & coeffs, const mpq & a, unsigned j);
bool the_left_sides_sum_to_zero(const vector<std::pair<mpq, unsigned>> & evidence) const;
Expand All @@ -229,7 +227,6 @@ class lar_solver : public column_namer {
int inf_sign) const;
mpq get_left_side_val(const lar_base_constraint & cns, const std::unordered_map<var_index, mpq> & var_map) const;
void fill_var_set_for_random_update(unsigned sz, var_index const * vars, vector<unsigned>& column_list);
void pivot_fixed_vars_from_basis();
bool column_represents_row_in_tableau(unsigned j);
void make_sure_that_the_bottom_right_elem_not_zero_in_tableau(unsigned i, unsigned j);
void remove_last_row_and_column_from_tableau(unsigned j);
Expand Down Expand Up @@ -264,10 +261,7 @@ class lar_solver : public column_namer {
return m_fixed_var_table_int;
}

map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>>& fixed_var_table_int() {
return m_fixed_var_table_int;
}


const map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>>& fixed_var_table_real() const {
return m_fixed_var_table_real;
}
Expand All @@ -293,9 +287,7 @@ class lar_solver : public column_namer {
inline void set_column_value_test(unsigned j, const impq& v) {
set_column_value(j, v);
}

unsigned get_total_iterations() const;


var_index add_named_var(unsigned ext_j, bool is_integer, const std::string&);

lp_status maximize_term(unsigned j_or_term, impq &term_max);
Expand Down
4 changes: 0 additions & 4 deletions src/math/lp/lp_core_solver_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ Revision History:
#include "util/vector.h"
#include <functional>
#include "math/lp/lp_core_solver_base_def.h"
template lp::non_basic_column_value_position lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::get_non_basic_column_value_position(unsigned int) const;
template lp::non_basic_column_value_position lp::lp_core_solver_base<lp::mpq, lp::mpq>::get_non_basic_column_value_position(unsigned int) const;

template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_statistics_with_iterations_and_nonzeroes_and_cost_and_check_that_the_time_is_over(char const*, std::ostream &);
template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::basis_heading_is_correct() const ;
template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::column_is_dual_feasible(unsigned int) const;
Expand Down Expand Up @@ -61,7 +58,6 @@ template std::string lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq>
template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::pretty_print(std::ostream & out);
template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::calc_current_x_is_feasible_include_non_basis(void)const;
template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::calc_current_x_is_feasible_include_non_basis() const;
template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::pivot_fixed_vars_from_basis();
template bool lp::lp_core_solver_base<lp::mpq, lp::mpq>::column_is_feasible(unsigned int) const;
// template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_linear_combination_of_column_indices(vector<std::pair<lp::mpq, unsigned int>, std::allocator<std::pair<lp::mpq, unsigned int> > > const&, std::ostream&) const;
template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::column_is_feasible(unsigned int) const;
Expand Down
5 changes: 0 additions & 5 deletions src/math/lp/lp_core_solver_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,6 @@ class lp_core_solver_base {

}



non_basic_column_value_position get_non_basic_column_value_position(unsigned j) const;

void pivot_fixed_vars_from_basis();
bool remove_from_basis(unsigned j);
bool remove_from_basis(unsigned j, const impq&);
bool pivot_column_general(unsigned j, unsigned j_basic, indexed_vector<T> & w);
Expand Down
44 changes: 0 additions & 44 deletions src/math/lp/lp_core_solver_base_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,29 +423,6 @@ column_name(unsigned column) const {
return m_column_names.get_variable_name(column);
}

template <typename T, typename X> non_basic_column_value_position lp_core_solver_base<T, X>::
get_non_basic_column_value_position(unsigned j) const {
switch (m_column_types[j]) {
case column_type::fixed:
return x_is_at_lower_bound(j)? at_fixed : not_at_bound;
case column_type::free_column:
return free_of_bounds;
case column_type::boxed:
return x_is_at_lower_bound(j)? at_lower_bound :(
x_is_at_upper_bound(j)? at_upper_bound:
not_at_bound
);
case column_type::lower_bound:
return x_is_at_lower_bound(j)? at_lower_bound : not_at_bound;
case column_type::upper_bound:
return x_is_at_upper_bound(j)? at_upper_bound : not_at_bound;
default:
lp_unreachable();
}
lp_unreachable();
return at_lower_bound;
}

template <typename T, typename X> void lp_core_solver_base<T, X>::transpose_rows_tableau(unsigned i, unsigned j) {
transpose_basis(i, j);
m_A.transpose_rows(i, j);
Expand All @@ -463,27 +440,6 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::pivot_column_g
return true;
}

template <typename T, typename X> void lp_core_solver_base<T, X>::pivot_fixed_vars_from_basis() {
// run over basis and non-basis at the same time
indexed_vector<T> w(m_basis.size()); // the buffer
unsigned i = 0; // points to basis
for (; i < m_basis.size(); i++) {
unsigned basic_j = m_basis[i];

if (get_column_type(basic_j) != column_type::fixed) continue;
T a;
unsigned j;
for (auto &c : m_A.m_rows[i]) {
j = c.var();
if (j == basic_j)
continue;
if (get_column_type(j) != column_type::fixed) {
if (pivot_column_general(j, basic_j, w))
break;
}
}
}
}

template <typename T, typename X> bool lp_core_solver_base<T, X>::remove_from_basis(unsigned basic_j) {
indexed_vector<T> w(m_basis.size()); // the buffer
Expand Down
2 changes: 0 additions & 2 deletions src/math/lp/lp_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ inline std::ostream& operator<<(std::ostream& out, lp_status status) {

lp_status lp_status_from_string(std::string status);

enum non_basic_column_value_position { at_lower_bound, at_upper_bound, at_fixed, free_of_bounds, not_at_bound };


class lp_resource_limit {
public:
Expand Down

0 comments on commit 3efe91c

Please sign in to comment.