fix more warnings

This commit is contained in:
Johann Dreo 2020-04-28 16:37:48 +02:00
commit 8ad56f7ad3
9 changed files with 26 additions and 25 deletions

View file

@ -192,16 +192,16 @@ public:
/** /**
* Print the structure of the topology on the standrad output. * Print the structure of the topology on the standrad output.
*/ */
void printOn() void printOn(std::ostream& out) const
{ {
for (unsigned i=0;i< neighborhoods.size();i++) for (unsigned i=0;i< neighborhoods.size();i++)
{ {
std::cout << "{ " ; out << "{ " ;
for (unsigned j=0;j< neighborhoods[i].size();j++) for (unsigned j=0;j< neighborhoods[i].size();j++)
{ {
std::cout << neighborhoods[i].get(j) << " "; out << neighborhoods[i].get(j) << " ";
} }
std::cout << "}" << std::endl; out << "}" << std::endl;
} }
} }

View file

@ -53,23 +53,23 @@ public:
bool operator()(EOT & _solution1, EOT & _solution2) { bool operator()(EOT & _solution1, EOT & _solution2) {
if (_solution1.size() > 1) { if (_solution1.size() > 1) {
// random indexes such that i1 < i2 // random indexes such that i1 < i2
int i1 = rng.random(_solution1.size()); size_t i1 = rng.random(_solution1.size());
int i2 = rng.random(_solution1.size()); size_t i2 = rng.random(_solution1.size());
while (i1 == i2) while (i1 == i2)
i2 = rng.random(_solution1.size()); i2 = rng.random(_solution1.size());
if (i1 > i2) { if (i1 > i2) {
int tmp = i1; size_t tmp = i1;
i1 = i2; i1 = i2;
i2 = tmp; i2 = tmp;
} }
// the permutations between s1 and s2 // the permutations between s1 and s2
int * p1 = new int[_solution1.size()]; size_t * p1 = new size_t[_solution1.size()];
int * p2 = new int[_solution1.size()]; size_t * p2 = new size_t[_solution1.size()];
int i; size_t i;
for(i = 0; i < _solution1.size(); i++) { for(i = 0; i < _solution1.size(); i++) {
p1[i] = -1; p1[i] = -1;
p2[i] = -1; p2[i] = -1;

View file

@ -143,16 +143,16 @@ public:
/** /**
* Print the structure of the topology on the standard output. * Print the structure of the topology on the standard output.
*/ */
void printOn() void printOn(std::ostream& out) const
{ {
for (unsigned i=0;i< neighborhoods.size();i++) for (unsigned i=0;i< neighborhoods.size();i++)
{ {
std::cout << "{ " ; out << "{ " ;
for (unsigned j=0;j< neighborhoods[i].size();j++) for (unsigned j=0;j< neighborhoods[i].size();j++)
{ {
std::cout << neighborhoods[i].get(j) << " "; out << neighborhoods[i].get(j) << " ";
} }
std::cout << "}" << std::endl; out << "}" << std::endl;
} }
} }

View file

@ -16,7 +16,7 @@ double f (const Particle & _particle)
return (-sum); return (-sum);
} }
int main_function(int argc, char **argv) int main_function(int /*argc*/, char **/*argv*/)
{ {
const unsigned POP_SIZE = 6, VEC_SIZE = 2, NEIGHBORHOOD_SIZE=2; const unsigned POP_SIZE = 6, VEC_SIZE = 2, NEIGHBORHOOD_SIZE=2;

View file

@ -22,7 +22,7 @@ int main() {
sol1.resize(9); sol1.resize(9);
sol2.resize(9); sol2.resize(9);
for(int i = 0; i < sol1.size(); i++) for(size_t i = 0; i < sol1.size(); i++)
sol1[i] = i; sol1[i] = i;
sol2[0] = 3; sol2[0] = 3;
@ -46,23 +46,23 @@ int main() {
std::cout << sol2 << std::endl; std::cout << sol2 << std::endl;
int verif[9]; int verif[9];
for(int i = 0; i < sol1.size(); i++) for(size_t i = 0; i < sol1.size(); i++)
verif[i] = -1; verif[i] = -1;
for(int i = 0; i < sol1.size(); i++) for(size_t i = 0; i < sol1.size(); i++)
verif[ sol1[i] ] = 1; verif[ sol1[i] ] = 1;
for(int i = 0; i < sol1.size(); i++) for(size_t i = 0; i < sol1.size(); i++)
assert(verif[i] != -1); assert(verif[i] != -1);
for(int i = 0; i < sol2.size(); i++) for(size_t i = 0; i < sol2.size(); i++)
verif[i] = -1; verif[i] = -1;
for(int i = 0; i < sol2.size(); i++) for(size_t i = 0; i < sol2.size(); i++)
verif[ sol2[i] ] = 1; verif[ sol2[i] ] = 1;
for(int i = 0; i < sol2.size(); i++) for(size_t i = 0; i < sol2.size(); i++)
assert(verif[i] != -1); assert(verif[i] != -1);
std::cout << "[t-eoPartiallyMappedXover] => OK" << std::endl; std::cout << "[t-eoPartiallyMappedXover] => OK" << std::endl;

View file

@ -16,7 +16,7 @@ double f (const Indi & _indi)
return (-sum); return (-sum);
} }
int main_function(int argc, char **argv) int main_function(int /*argc*/, char **/*argv*/)
{ {
//Parameters //Parameters
const unsigned int VEC_SIZE = 2; const unsigned int VEC_SIZE = 2;

View file

@ -8,6 +8,7 @@ struct OpInterface
std::string _name; std::string _name;
OpInterface(std::string name) : _name(name) {} OpInterface(std::string name) : _name(name) {}
virtual void operator()() = 0; virtual void operator()() = 0;
virtual ~OpInterface() {}
}; };
struct OpA : public OpInterface struct OpA : public OpInterface

View file

@ -36,7 +36,7 @@ typedef eoBit<double> Indi; // A bitstring with fitness double
// GENERAL // GENERAL
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void main_function(int argc, char **argv) void main_function(int /*argc*/, char **/*argv*/)
{ {
// PARAMETRES // PARAMETRES
const unsigned int SEED = 42; // seed for random number generator const unsigned int SEED = 42; // seed for random number generator

View file

@ -34,7 +34,7 @@ double binary_value (const Particle & _particle)
void main_function(int argc, char **argv) void main_function(int /*argc*/, char **/*argv*/)
{ {
// PARAMETRES // PARAMETRES
// all parameters are hard-coded! // all parameters are hard-coded!