Fix warnings in debug

This commit is contained in:
quemy 2013-01-19 00:46:08 +01:00
commit 49190367af
10 changed files with 43 additions and 45 deletions

View file

@ -135,9 +135,9 @@ protected:
*/
virtual void send(eoSelect<EOT>& _select);
EOAlgo<EOT> algo;
eoEvalFunc<EOT>& eval;
eoPop<EOT>& pop;
EOAlgo<EOT> algo;
std::queue<eoPop<bEOT>> listImigrants;
IntPolicy<EOT>& intPolicy;
MigPolicy<EOT>& migPolicy;

View file

@ -32,7 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
void paradiseo::smp::Complete::operator()(unsigned nbNode, std::vector<std::vector<bool>>& 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<std::vect
std::vector<bool> line;
line.assign(nbNode,true);
matrix.assign(nbNode, line);
for(int i=0;i<nbNode;i++)
for(unsigned i = 0; i < nbNode; i++)
matrix[i][i]=false;
}
}

View file

@ -39,7 +39,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filename)
{
std :: ifstream f(filename);
std::ifstream f(filename);
if (f)
{
int temp;
@ -56,7 +56,7 @@ paradiseo::smp::CustomBooleanTopology::CustomBooleanTopology(std::string filenam
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
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<unsigned> paradiseo::smp::CustomBooleanTopology::getIdNeighbors(unsigned idNode) const
{
std::vector<unsigned> 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<unsigned> 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;
}
}

View file

@ -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;

View file

@ -34,13 +34,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
void paradiseo::smp::Hypercubic::operator()(unsigned nbNode, std::vector<std::vector<bool>>& 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<<power) == 0)
unsigned power = 0, i, j;
while((nbNode & 1 << power) == 0)
power++;
matrix.clear();
@ -51,14 +51,14 @@ void paradiseo::smp::Hypercubic::operator()(unsigned nbNode, std::vector<std::ve
//Construction
matrix[0][0] = false;
for (unsigned dim = 1; dim <= power; dim ++)
for(unsigned dim = 1; dim <= power; dim ++)
{
int stepNbNode = 1<< (dim-1); //represents the number of nodes for the current step.
for(i=0; i <stepNbNode; i++)
for(j=0; j< stepNbNode;j++)
unsigned stepNbNode = 1 << (dim-1); //represents the number of nodes for the current step.
for(i = 0; i < stepNbNode; i++)
for(j = 0; j < stepNbNode; j++)
{
matrix[i+stepNbNode][j+stepNbNode]=matrix[i][j];//Diagonal part
matrix[i][j+stepNbNode]= matrix[i+stepNbNode][j] = (i == j);//Identity
matrix[i+stepNbNode][j+stepNbNode]=matrix[i][j]; //Diagonal part
matrix[i][j+stepNbNode]= matrix[i+stepNbNode][j] = (i == j); //Identity
}
}
}

View file

@ -33,31 +33,28 @@ Contact: paradiseo-help@lists.gforge.inria.fr
void paradiseo::smp::Mesh::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
{
int i=0, j, height, width;
unsigned i = 0, j, height, width;
std::vector<unsigned> 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<listFact.size()-1 && (double)listFact[i]*listFact[i]/nbNode<_ratio)
while (i < listFact.size() - 1 && (double)listFact[i]*listFact[i] / nbNode < _ratio)
i++;
/*
listFact[i] contains first factor which produces a ratio above the variable _ratio,
or the last element if there is no ratio that can go over the variable _ratio.
*/
double r1 = (double)listFact[i]*listFact[i]/nbNode;
double r2 = (double)listFact[i-1]*listFact[i-1]/nbNode;
// listFact[i] contains first factor which produces a ratio above the variable _ratio,
// or the last element if there is no ratio that can go over the variable _ratio.
double r1 = (double)listFact[i] * listFact[i] / nbNode;
double r2 = (double)listFact[i-1] * listFact[i-1] / nbNode;
//which ratio (r1,r2) matches _ratio best?
if (std::abs(r2-_ratio) <= _ratio-r1)
// Which ratio (r1,r2) matches _ratio best?
if (std::abs(r2 - _ratio) <= _ratio - r1)
height = listFact[i-1];
else
height = listFact[i];
width = nbNode/height;
//Building matrix
// Building matrix
matrix.clear();
matrix.resize(nbNode);

View file

@ -32,7 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
void paradiseo::smp::Ring::operator()(unsigned nbNode, std::vector<std::vector<bool>>& 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<std::vector<b
line.assign(nbNode, false);
matrix.assign(nbNode, line);
for(int i=0; i<nbNode;i++)
for(unsigned i=0; i < nbNode; i++)
matrix[i][(i+1)%nbNode]=true;
}
}

View file

@ -47,7 +47,7 @@ void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbNode)
template <class TopologyType>
void paradiseo::smp::Topology<TopologyType>::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;

View file

@ -73,13 +73,12 @@ int main()
}
//Reading the actual matrix
std :: ifstream f("data-topo-stoch");
std::ifstream f("data-topo-stoch");
std::vector<std::vector<double>> _matrix;
if (f)
{
double temp;
unsigned size;
double isNeighbor, isFirst = true;
double isNeighbor;
std::string line;
std::vector<double> 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);
}

View file

@ -14,6 +14,7 @@ typedef eoBit<double> 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<size; ivar++)
@ -27,6 +28,7 @@ Indi2 fromBase(Indi& i, unsigned size)
Indi toBase(Indi2& i)
{
(void)i;
// Dummy conversion. We just create a new Indi
Indi v;
std::cout << "Convert to base : " << v << std::endl;