fix(util/lp,tests/util/lp): warning msgs on OSX

This commit is contained in:
Leonardo de Moura 2016-02-05 10:46:29 -08:00
parent e785827688
commit 6c1c6cbbdd
16 changed files with 36 additions and 33 deletions

View file

@ -182,7 +182,7 @@ class mps_reader {
void read_name() {
do {
read_line();
if (!m_line.find("NAME") == 0) {
if (m_line.find("NAME") != 0) {
continue;
}
m_line = m_line.substr(4);
@ -347,7 +347,7 @@ class mps_reader {
}
void read_bounds() {
if (!m_line.find("BOUNDS") == 0) {
if (m_line.find("BOUNDS") != 0) {
return;
}
@ -361,7 +361,7 @@ class mps_reader {
}
void read_ranges() {
if (!m_line.find("RANGES") == 0) {
if (m_line.find("RANGES") != 0) {
return;
}
do {

View file

@ -56,7 +56,7 @@ public:
raw_blob scan_to_row_blob() {
}
test_file_blob scan_row_blob_to_test_file_blob(raw_blob rblob) {
test_file_blob scan_row_blob_to_test_file_blob(raw_blob /* rblob */) {
}
test_result<T> * get_test_result() {

View file

@ -1,3 +1,11 @@
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_lower)
if (CMAKE_BUILD_TYPE_lower STREQUAL "debug")
# LP_DBG_FILES include files that are only needed in DEBUG mode.
# We use this trick to avoid warning messages when compiling in Release mode on OSX.
# These files are empty in Release mode.
set(LP_DBG_FILES dense_matrix_instances.cpp matrix_instances.cpp)
endif()
add_library(lp OBJECT
binary_heap_priority_queue_instances.cpp
binary_heap_upair_queue_instances.cpp
@ -19,8 +27,7 @@ add_library(lp OBJECT
square_dense_submatrix_instances.cpp
static_matrix_instances.cpp
scaler_instances.cpp
dense_matrix_instances.cpp
eta_matrix_instances.cpp
matrix_instances.cpp
lar_constraints.cpp
${LP_DBG_FILES}
)

View file

@ -57,7 +57,7 @@ template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
if (o_in_heap == -1) {
return; // nothing to do
}
lean_assert(o_in_heap <= m_heap_size);
lean_assert(static_cast<unsigned>(o_in_heap) <= m_heap_size);
if (static_cast<unsigned>(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) {
@ -74,11 +74,11 @@ template <typename T> void binary_heap_priority_queue<T>::remove(unsigned o) {
}
}
} else {
lean_assert(o_in_heap == m_heap_size);
lean_assert(static_cast<unsigned>(o_in_heap) == m_heap_size);
m_heap_size--;
}
m_heap_inverse[o] = -1;
// lean_assert(is_consistent());
// lean_assert(is_consistent());
}
// n is the initial queue capacity.
// The capacity will be enlarged two times automatically if needed

View file

@ -135,7 +135,7 @@ template <typename T, typename X> unsigned core_solver_pretty_printer<T, X>:: ge
return w;
}
template <typename T, typename X> std::string core_solver_pretty_printer<T, X>::regular_cell_string(unsigned row, unsigned column, std::string name) {
template <typename T, typename X> std::string core_solver_pretty_printer<T, X>::regular_cell_string(unsigned row, unsigned /* column */, std::string name) {
T t = fabs(m_core_solver.m_ed[row]);
if ( t == 1) return name;
return T_to_string(t) + name;

View file

@ -117,15 +117,15 @@ apply_from_left_with_different_dims(std::vector<T> & w) {
template <typename T, typename X> void dense_matrix<T, X>::apply_from_left(std::vector<T> & w) {
T * t = new T[m_m];
for (int i = 0; i < m_m; i ++) {
for (unsigned i = 0; i < m_m; i ++) {
T v = numeric_traits<T>::zero();
for (int j = 0; j < m_m; j++) {
for (unsigned j = 0; j < m_m; j++) {
v += w[j]* get_elem(i, j);
}
t[i] = v;
}
for (int i = 0; i < m_m; i ++) {
for (unsigned i = 0; i < m_m; i ++) {
w[i] = t[i];
}
delete [] t;
@ -166,7 +166,7 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_left_to_X(
// alpha and adding it to row i0.
template <typename T, typename X> void dense_matrix<T, X>::pivot_row_to_row(unsigned i, T alpha, unsigned i0,
double & pivot_epsilon) {
thread_local T _0 = numeric_traits<T>::zero();
T _0 = numeric_traits<T>::zero();
for (unsigned j = 0; j < m_n; j++) {
m_values[i0 * m_n + j] += m_values[i * m_n + j] * alpha;
if (fabs(m_values[i0 + m_n + j]) < pivot_epsilon) {

View file

@ -70,7 +70,7 @@ void indexed_vector<T>::erase_from_index(unsigned j) {
#ifdef LEAN_DEBUG
template <typename T>
bool indexed_vector<T>::is_OK() const {
int size = 0;
unsigned size = 0;
for (unsigned i = 0; i < m_data.size(); i++) {
if (!is_zero(m_data[i])) {
if (std::find(m_index.begin(), m_index.end(), i) == m_index.end())

View file

@ -491,7 +491,7 @@ non_basis_is_correctly_represented_in_heading() {
}
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);
lean_assert(static_cast<unsigned>(m_basis_heading[j]) < m_A.row_count() && m_basis[m_basis_heading[j]] == j);
}
}
return true;
@ -715,4 +715,3 @@ template <typename T, typename X> int lp_core_solver_base<T, X>::pivots_in_colum
}
}

View file

@ -136,14 +136,14 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::done() {
}
template <typename T, typename X> T lp_dual_core_solver<T, X>::get_edge_steepness_for_low_bound(unsigned p) {
lean_assert(this->m_basis_heading[p] >= 0 && this->m_basis_heading[p] < this->m_m);
lean_assert(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m);
T del = this->m_x[p] - this->m_low_bound_values[p];
del *= del;
return del / this->m_betas[this->m_basis_heading[p]];
}
template <typename T, typename X> T lp_dual_core_solver<T, X>::get_edge_steepness_for_upper_bound(unsigned p) {
lean_assert(this->m_basis_heading[p] >= 0 && this->m_basis_heading[p] < this->m_m);
lean_assert(this->m_basis_heading[p] >= 0 && static_cast<unsigned>(this->m_basis_heading[p]) < this->m_m);
T del = this->m_x[p] - this->m_upper_bound_values[p];
del *= del;
return del / this->m_betas[this->m_basis_heading[p]];

View file

@ -299,10 +299,10 @@ lp_primal_core_solver(static_matrix<T, X> & A,
template <typename T, typename X> bool lp_primal_core_solver<T, X>::initial_x_is_correct() {
std::set<unsigned> basis_set;
for (int i = 0; i < this->m_A.row_count(); i++) {
for (unsigned i = 0; i < this->m_A.row_count(); i++) {
basis_set.insert(this->m_basis[i]);
}
for (int j = 0; j < this->m_n; j++) {
for (unsigned j = 0; j < this->m_n; j++) {
if (column_has_low_bound(j) && this->m_x[j] < numeric_traits<T>::zero()) {
std::cout << "low bound for variable " << j << " does not hold: this->m_x[" << j << "] = " << this->m_x[j] << " is negative " << std::endl;
return false;
@ -359,7 +359,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::update_re
// the basis heading has changed already
#ifdef LEAN_DEBUG
auto & basis_heading = this->m_factorization->m_basis_heading;
lean_assert(basis_heading[entering] >= 0 && basis_heading[entering] < this->m_ed.size());
lean_assert(basis_heading[entering] >= 0 && static_cast<unsigned>(basis_heading[entering]) < this->m_ed.size());
lean_assert(basis_heading[leaving] < 0);
#endif
T pivot = this->m_pivot_row[entering];
@ -436,7 +436,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::calc_work
}
template <typename T, typename X>void lp_primal_core_solver<T, X>::advance_on_entering_and_leaving(int entering, int leaving, X & t) {
lean_assert(m_non_basis_list.back() == entering);
lean_assert(entering >= 0 && m_non_basis_list.back() == static_cast<unsigned>(entering));
lean_assert(t >= zero_of_type<X>());
lean_assert(leaving >= 0 && entering >= 0);
lean_assert(entering != leaving || !is_zero(t)); // otherwise nothing changes

View file

@ -265,7 +265,7 @@ void lu<T, X>::change_basis(unsigned entering, unsigned leaving) {
lean_assert(entering < m_A.column_count() && leaving < m_A.column_count());
int place_in_basis = m_basis_heading[leaving];
int place_in_non_basis = - m_basis_heading[entering] - 1;
lean_assert(0 <= place_in_basis && place_in_basis < m_A.column_count());
lean_assert(0 <= place_in_basis && static_cast<unsigned>(place_in_basis) < m_A.column_count());
m_basis_heading[entering] = place_in_basis;
m_basis_heading[leaving] = -place_in_non_basis - 1;
m_basis[place_in_basis] = entering;

View file

@ -257,7 +257,7 @@ public:
void scan_last_row_to_work_vector(unsigned lowest_row_of_the_bump);
bool diagonal_element_is_off(T diag_element) { return false; }
bool diagonal_element_is_off(T /* diag_element */) { return false; }
void pivot_and_solve_the_system(unsigned replaced_column, unsigned lowest_row_of_the_bump);
// see Achim Koberstein's thesis page 58, but here we solve the system and pivot to the last

View file

@ -5,6 +5,7 @@
Author: Lev Nachmanson
*/
#ifdef LEAN_DEBUG
#include <cmath>
#include <vector>
#include <string>
#include "util/lp/matrix.h"
@ -89,10 +90,6 @@ void print_string_matrix(std::vector<std::vector<std::string>> & A, std::ostream
template <typename T, typename X>
void print_matrix(matrix<T, X> const & m, std::ostream & out) {
if (&m == nullptr) {
out << "null" << std::endl;
return;
}
std::vector<std::vector<std::string>> A(m.row_count());
for (unsigned i = 0; i < m.row_count(); i++) {
for (unsigned j = 0; j < m.column_count(); j++) {

View file

@ -118,8 +118,8 @@ public:
apply_from_left_local(w, settings);
}
void apply_from_right(indexed_vector<T> & w) {
lean_assert(false); // not implemented
void apply_from_right(indexed_vector<T> & /* w */) {
lean_unreachable(); // not implemented
}
void apply_from_left(std::vector<X> & w, lp_settings & /*settings*/) {
apply_from_left_to_vector(w);// , settings);

View file

@ -24,7 +24,7 @@ void static_matrix<T, X>::init_row_columns(unsigned m, unsigned n) {
// constructor that copies columns of the basis from A
template <typename T, typename X>
static_matrix<T, X>::static_matrix(static_matrix const &A, unsigned * basis) :
static_matrix<T, X>::static_matrix(static_matrix const &A, unsigned * /* basis */) :
m_work_pivot_vector(A.row_count(), numeric_traits<T>::zero()) {
unsigned m = A.row_count();
init_row_columns(m, m);

View file

@ -191,7 +191,7 @@ public:
virtual void set_number_of_columns(unsigned /*n*/) { }
#endif
T get_max_val_in_row(unsigned i) const { lean_unreachable(); }
T get_max_val_in_row(unsigned /* i */) const { lean_unreachable(); }
T get_balance() const;