From 49190367afbf65ac9d067591f58abeaa10010d2b Mon Sep 17 00:00:00 2001 From: quemy Date: Sat, 19 Jan 2013 00:46:08 +0100 Subject: [PATCH] Fix warnings in debug --- smp/src/island.h | 2 +- smp/src/topology/complete.cpp | 4 ++-- smp/src/topology/customBooleanTopology.cpp | 20 +++++++++--------- smp/src/topology/customStochasticTopology.cpp | 2 +- smp/src/topology/hypercubic.cpp | 20 +++++++++--------- smp/src/topology/mesh.cpp | 21 ++++++++----------- smp/src/topology/ring.cpp | 4 ++-- smp/src/topology/topology.cpp | 2 +- smp/test/t-smpCustomTopo.cpp | 11 +++++----- smp/test/t-smpMI_Heterogeneous.cpp | 2 ++ 10 files changed, 43 insertions(+), 45 deletions(-) diff --git a/smp/src/island.h b/smp/src/island.h index 44b5e83f8..4c3a26165 100644 --- a/smp/src/island.h +++ b/smp/src/island.h @@ -135,9 +135,9 @@ protected: */ virtual void send(eoSelect& _select); + EOAlgo algo; eoEvalFunc& eval; eoPop& pop; - EOAlgo algo; std::queue> listImigrants; IntPolicy& intPolicy; MigPolicy& migPolicy; diff --git a/smp/src/topology/complete.cpp b/smp/src/topology/complete.cpp index aa019c628..c50fc1cfe 100644 --- a/smp/src/topology/complete.cpp +++ b/smp/src/topology/complete.cpp @@ -32,7 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr void paradiseo::smp::Complete::operator()(unsigned nbNode, std::vector>& matrix) const { - if(nbNode!=matrix.size()) + if(nbNode != matrix.size()) { matrix.clear(); @@ -43,7 +43,7 @@ void paradiseo::smp::Complete::operator()(unsigned nbNode, std::vector line; line.assign(nbNode,true); matrix.assign(nbNode, line); - for(int i=0;i> temp >> std::skipws) + while(tokenizer >> temp >> std::skipws) { //white spaces are skipped, and the integer is converted to boolean, to be stored isNeighbor = (bool) temp; @@ -67,12 +67,12 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam if(isFirst) { size = lineVector.size(); - isFirst=false; + isFirst = false; } //for each vector non empty, if the size is not equal to the others, error if(lineVector.size() != size && !lineVector.empty()) - throw std::runtime_error("Mistake in the topology, line "+ std::to_string(_matrix.size()+1) ); + throw std::runtime_error("Mistake in the topology, line " + std::to_string(_matrix.size()+1) ); if(!lineVector.empty()) _matrix.push_back(lineVector); @@ -81,7 +81,7 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam //for each vector, verify if the size is equal to the size of the final matrix for(auto& line : _matrix) if(line.size() != _matrix.size()) - throw std::runtime_error("Mistake in the topology, matrix is not square" ); + throw std::runtime_error("Mistake in the topology, matrix is not squared" ); f.close () ; } @@ -94,7 +94,7 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam std::vector paradiseo::smp::CustomBooleanTopology::getIdNeighbors(unsigned idNode) const { std::vector neighbors; - for(unsigned j=0; j<_matrix.size();j++) + for(unsigned j = 0; j < _matrix.size();j++) if(_matrix[idNode][j]) neighbors.push_back(j); @@ -103,17 +103,17 @@ std::vector paradiseo::smp::CustomBooleanTopology::getIdNeighbors(unsi void paradiseo::smp::CustomBooleanTopology::construct(unsigned nbNode) { - assert(nbNode==_matrix.size()); + assert(nbNode == _matrix.size()); } void paradiseo::smp::CustomBooleanTopology::isolateNode(unsigned idNode) { - for(int i=0;i<_matrix.size();i++) + for(unsigned i = 0; i < _matrix.size(); i++) { //Line of idNode to false : no connection FROM this node - _matrix[idNode][i]=false; + _matrix[idNode][i] = false; //Column of idNode to false : no connection TO this node - _matrix[i][idNode]=false; + _matrix[i][idNode] = false; } } diff --git a/smp/src/topology/customStochasticTopology.cpp b/smp/src/topology/customStochasticTopology.cpp index ee6d43db3..87fa6d33e 100644 --- a/smp/src/topology/customStochasticTopology.cpp +++ b/smp/src/topology/customStochasticTopology.cpp @@ -118,7 +118,7 @@ void paradiseo::smp::CustomStochasticTopology::construct(unsigned nbNode) void paradiseo::smp::CustomStochasticTopology::isolateNode(unsigned idNode) { - for(int i=0;i<_matrix.size();i++) + for(unsigned i = 0; i < _matrix.size(); i++) { //Line of idNode to false : no connection FROM this node _matrix[idNode][i]=0; diff --git a/smp/src/topology/hypercubic.cpp b/smp/src/topology/hypercubic.cpp index fcc179097..972d4f428 100644 --- a/smp/src/topology/hypercubic.cpp +++ b/smp/src/topology/hypercubic.cpp @@ -34,13 +34,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr void paradiseo::smp::Hypercubic::operator()(unsigned nbNode, std::vector>& matrix) const { - if(nbNode!=matrix.size()) + if(nbNode != matrix.size()) { - //Check if the number of node is coherent with an hypercube + // Check if the number of node is coherent with an hypercube assert((nbNode & (nbNode-1)) == 0); - unsigned power=0,i,j; - while((nbNode & 1<>& matrix) const { - int i=0, j, height, width; + unsigned i = 0, j, height, width; std::vector listFact = paradiseo::smp::Mesh::factorization(nbNode); - int nbFact = listFact.size(); //Compute width and height //find the ratio height/width of the grid that matches best the variable _ratio - while (i>& matrix) const { - if(nbNode!=matrix.size()) + if(nbNode != matrix.size()) { matrix.clear(); @@ -44,7 +44,7 @@ void paradiseo::smp::Ring::operator()(unsigned nbNode, std::vector::construct(unsigned nbNode) template void paradiseo::smp::Topology::isolateNode(unsigned idNode) { - for(int i=0;i<_matrix.size();i++) + for(unsigned i = 0; i < _matrix.size(); i++) { //Line of idNode to false : no connection FROM this node _matrix[idNode][i] = false; diff --git a/smp/test/t-smpCustomTopo.cpp b/smp/test/t-smpCustomTopo.cpp index 7315b41a1..13f0e4fed 100644 --- a/smp/test/t-smpCustomTopo.cpp +++ b/smp/test/t-smpCustomTopo.cpp @@ -73,13 +73,12 @@ int main() } //Reading the actual matrix - std :: ifstream f("data-topo-stoch"); + std::ifstream f("data-topo-stoch"); std::vector> _matrix; if (f) { double temp; - unsigned size; - double isNeighbor, isFirst = true; + double isNeighbor; std::string line; std::vector lineVector; @@ -91,7 +90,7 @@ int main() std::istringstream tokenizer(line); std::string token; - while(tokenizer>> temp >> std::skipws) + while(tokenizer >> temp >> std::skipws) { //white spaces are skipped, and the integer is converted to boolean, to be stored @@ -112,7 +111,7 @@ int main() } //Comparison to the actual matrix : _matrix - for(int i = 0; i < matrix.size(); i++) - for(int j = 0; j < matrix.size(); j++) + for(unsigned i = 0; i < matrix.size(); i++) + for(unsigned j = 0; j < matrix.size(); j++) assert(std::abs(_matrix[i][j] - matrix[i][j]) < .05); } diff --git a/smp/test/t-smpMI_Heterogeneous.cpp b/smp/test/t-smpMI_Heterogeneous.cpp index 09f59bdfe..64f4937f6 100644 --- a/smp/test/t-smpMI_Heterogeneous.cpp +++ b/smp/test/t-smpMI_Heterogeneous.cpp @@ -14,6 +14,7 @@ typedef eoBit Indi2; // A bitstring with fitness double // Conversion functions Indi2 fromBase(Indi& i, unsigned size) { + (void)i; // Dummy conversion. We just create a new Indi2 Indi2 v; for (unsigned ivar=0; ivar