paradiseo/test/eo/t-eofitness.cpp
Adèle Harrissart 490e837f7a * New tree configuration of the project:
.../
   ...           + -- EO
   |             |
   |             |
   +-- src ----- + -- EDO
   |             |
   |             |
   +-- test      + -- MO
   |             |
   |             |
   +-- tutorial  + -- MOEO
   |             |
   |             |
   +-- doc       + -- SMP
   |             |
   |             |
   ...           + -- EOMPI
                 |
                 |
                 + -- EOSERIAL

Question for current maintainers: ./README: new release?

Also:

* Moving out eompi & eoserial modules (issue #2).

* Correction of the errors when executing "make doc" command.

* Adding a solution for the conflicting headers problem (see the two CMake Cache
 Values: PROJECT_TAG & PROJECT_HRS_INSTALL_SUBPATH) (issue #1)

* Header inclusions:
        ** src: changing absolute paths into relative paths ('#include <...>' -> '#include "..."')
        ** test, tutorial: changing relative paths into absolute paths ('#include "..."' -> '#include <...>')

* Moving out some scripts from EDO -> to the root

* Add a new script for compilation and installation (see build_gcc_linux_install)

* Compilation with uBLAS library or EDO module: now ok

* Minor modifications on README & INSTALL files

* Comment eompi failed tests with no end

*** TODO: CPack (debian (DEB) & RedHat (RPM) packages) (issues #6 & #7) ***
2014-09-06 13:04:35 +02:00

89 lines
2.5 KiB
C++
Executable file

//-----------------------------------------------------------------------------
// t-eofitness.cpp
// (c) GeNeura Team 1998
//-----------------------------------------------------------------------------
#include <time.h> // time
#include <stdlib.h> // srand, rand
#include <iostream> // std::cout
#include <paradiseo/eo/eoScalarFitness.h>
using namespace std;
//-----------------------------------------------------------------------------
template <class Fitness>
int test_fitness(Fitness a, Fitness b)
{
// srand(time(0));
// Fitness a = aval; //static_cast<double>(rand()) / RAND_MAX;
// Fitness b = bval; //static_cast<double>(rand()) / RAND_MAX;
std::cout.precision(2);
unsigned repeat = 2;
while (repeat--)
{
std::cout << "------------------------------------------------------" << std::endl;
std::cout << "testing < ";
if (a < b)
std::cout << a << " < " << b << " is true" << std::endl;
else
std::cout << a << " < " << b << " is false" <<std::endl;
std::cout << "testing > ";
if (a > b)
std::cout << a << " > " << b << " is true" << std::endl;
else
std::cout << a << " > " << b << " is false" <<std::endl;
std::cout << "testing == ";
if (a == b)
std::cout << a << " == " << b << " is true" << std::endl;
else
std::cout << a << " == " << b << " is false" <<std::endl;
std::cout << "testing != ";
if (a != b)
std::cout << a << " != " << b << " is true" << std::endl;
else
std::cout << a << " != " << b << " is false" <<std::endl;
a = b;
}
return 1;
}
int main()
{
std::cout << "Testing minimizing fitness with 1 and 2" << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
eoMinimizingFitness a = 1;
eoMinimizingFitness b = 2;
test_fitness(a, b);
std::cout << "Testing minimizing fitness with 2 and 1" << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
test_fitness(b, a);
std::cout << "Testing maximizing fitness with 1 and 2" << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
eoMaximizingFitness a1 = 1;
eoMaximizingFitness b1 = 2;
test_fitness(a1,b1);
std::cout << "Testing maximizing fitness with 2 and 1" << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
test_fitness(b1,a1);
}
//-----------------------------------------------------------------------------