From fbe4f56aea6156b1d6620e5e21212b995343ec8c Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Tue, 26 Jan 2016 14:40:29 -0800 Subject: [PATCH] chore(lp): remove warnings Signed-off-by: Lev Nachmanson --- src/tests/util/lp/lp.cpp | 6 +++++- src/tests/util/lp/mps_reader.h | 2 +- src/util/lp/binary_heap_priority_queue.cpp | 8 ++++---- src/util/lp/lp_core_solver_base.cpp | 8 ++++---- src/util/lp/lp_dual_core_solver.cpp | 2 +- src/util/lp/lp_dual_simplex.cpp | 2 +- src/util/lp/lp_primal_simplex.cpp | 2 +- src/util/lp/lu.cpp | 4 ++-- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/tests/util/lp/lp.cpp b/src/tests/util/lp/lp.cpp index 12b953046..7766c7a41 100644 --- a/src/tests/util/lp/lp.cpp +++ b/src/tests/util/lp/lp.cpp @@ -2076,7 +2076,11 @@ void process_test_file(string test_dir, string test_file_name, argument_parser & } } } -int my_readdir(DIR *dirp, struct dirent *entry, struct dirent **result) { +int my_readdir(DIR *dirp, struct dirent * +#ifndef LEAN_WINDOWS + entry +#endif + , struct dirent **result) { #ifdef LEAN_WINDOWS *result = readdir(dirp); return *result != nullptr? 0 : 1; diff --git a/src/tests/util/lp/mps_reader.h b/src/tests/util/lp/mps_reader.h index 77c9394ab..a5545adc1 100644 --- a/src/tests/util/lp/mps_reader.h +++ b/src/tests/util/lp/mps_reader.h @@ -239,7 +239,7 @@ class mps_reader { void read_column(string column_name, string column_data){ auto tokens = split_and_trim(column_data); - for (int i = 0; i < tokens.size() - 1; i+= 2) { + for (unsigned i = 0; i < tokens.size() - 1; i+= 2) { auto row_name = tokens[i]; if (row_name == "'MARKER'") return; // it is the integrality marker, no real data here auto t = m_rows.find(row_name); diff --git a/src/util/lp/binary_heap_priority_queue.cpp b/src/util/lp/binary_heap_priority_queue.cpp index 881221bb3..7cf693b79 100644 --- a/src/util/lp/binary_heap_priority_queue.cpp +++ b/src/util/lp/binary_heap_priority_queue.cpp @@ -57,7 +57,7 @@ template void binary_heap_priority_queue::remove(unsigned o) { return; // nothing to do } lean_assert(o_in_heap <= m_heap_size); - if (o_in_heap < m_heap_size) { + if (static_cast(o_in_heap) < m_heap_size) { put_at(o_in_heap, m_heap[m_heap_size--]); if (m_priorities[m_heap[o_in_heap]] > priority_of_o) { fix_heap_under(o_in_heap); @@ -143,11 +143,11 @@ template unsigned binary_heap_priority_queue::dequeue_and_get_pr template void binary_heap_priority_queue::fix_heap_under(unsigned i) { while (true) { - int smallest = i; - int l = i << 1; + unsigned smallest = i; + unsigned l = i << 1; if (l <= m_heap_size && m_priorities[m_heap[l]] < m_priorities[m_heap[i]]) smallest = l; - int r = l + 1; + unsigned r = l + 1; if (r <= m_heap_size && m_priorities[m_heap[r]] < m_priorities[m_heap[smallest]]) smallest = r; if (smallest != i) diff --git a/src/util/lp/lp_core_solver_base.cpp b/src/util/lp/lp_core_solver_base.cpp index 0dc592947..d8cf50285 100644 --- a/src/util/lp/lp_core_solver_base.cpp +++ b/src/util/lp/lp_core_solver_base.cpp @@ -474,18 +474,18 @@ non_basis_has_no_doubles() { template bool lp_core_solver_base:: basis_is_correctly_represented_in_heading() { for (unsigned i = 0; i < m_m; i++) { - if (m_basis_heading[m_basis[i]] != i) + if (m_basis_heading[m_basis[i]] != static_cast(i)) return false; } return true; } template bool lp_core_solver_base:: non_basis_is_correctly_represented_in_heading() { - for (int i = 0; i < m_non_basic_columns.size(); i++) { - if (m_basis_heading[m_non_basic_columns[i]] != - i - 1) + for (unsigned i = 0; i < m_non_basic_columns.size(); i++) { + if (m_basis_heading[m_non_basic_columns[i]] != - static_cast(i) - 1) return false; } - for (int j = 0; j < m_A.column_count(); j++) { + for (unsigned j = 0; j < m_A.column_count(); j++) { if (m_basis_heading[j] >= 0) { lean_assert(m_basis_heading[j] < m_A.row_count() && m_basis[m_basis_heading[j]] == j); } diff --git a/src/util/lp/lp_dual_core_solver.cpp b/src/util/lp/lp_dual_core_solver.cpp index c12c09037..d34a87a3a 100644 --- a/src/util/lp/lp_dual_core_solver.cpp +++ b/src/util/lp/lp_dual_core_solver.cpp @@ -379,7 +379,7 @@ template void lp_dual_core_solver::update_betas() T k = -2 * one_over_arq; unsigned i = this->m_m; while (i--) { - if (i == m_r) continue; + if (static_cast(i) == m_r) continue; T a = this->m_ed[i]; m_betas[i] += a * (a * beta_r + k * this->m_pivot_row_of_B_1[i]); if (m_betas[i] < T(0.0001)) diff --git a/src/util/lp/lp_dual_simplex.cpp b/src/util/lp/lp_dual_simplex.cpp index 46bc0e348..846803d96 100644 --- a/src/util/lp/lp_dual_simplex.cpp +++ b/src/util/lp/lp_dual_simplex.cpp @@ -315,7 +315,7 @@ template void lp_dual_simplex::augment_matrix_A_a template void lp_dual_simplex::copy_m_b_aside_and_set_it_to_zeros() { - for (int i = 0; i < this->m_b.size(); i++) { + for (unsigned i = 0; i < this->m_b.size(); i++) { m_b_copy.push_back(this->m_b[i]); this->m_b[i] = numeric_traits::zero(); // preparing for the first stage } diff --git a/src/util/lp/lp_primal_simplex.cpp b/src/util/lp/lp_primal_simplex.cpp index b668b543e..831b1fdc4 100644 --- a/src/util/lp/lp_primal_simplex.cpp +++ b/src/util/lp/lp_primal_simplex.cpp @@ -233,7 +233,7 @@ template void lp_primal_simplex::solve_with_total fill_A_x_and_basis_for_stage_one_total_inf(); this->print_statistics_on_A(); this->fill_column_names_for_core_solver(); - int j = this->m_A->column_count() - 1; + unsigned j = this->m_A->column_count() - 1; unsigned core_solver_cols = this->number_of_core_structurals(); while (j >= core_solver_cols) diff --git a/src/util/lp/lu.cpp b/src/util/lp/lu.cpp index ea58c323d..85ba4375b 100644 --- a/src/util/lp/lu.cpp +++ b/src/util/lp/lu.cpp @@ -424,7 +424,7 @@ template void lu::process_column(int j) { unsigned pi, pj; m_U.get_pivot_for_column(pi, pj, T(m_settings.c_partial_pivoting), j); - if (pi == -1) { + if (static_cast(pi) == -1) { std::cout << "cannot find the pivot for column " << j << std::endl; m_failure = true; return; @@ -523,7 +523,7 @@ void lu::pivot_in_dense_mode(unsigned i) { m_failure = true; return; } - if (i != j) { + if (i != static_cast(j)) { swap_columns(i, j); m_dense_LU->swap_columns(i, j); }