paradiseo/tutorial/eo/Lesson5/eoOneMaxEvalFunc.h
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

68 lines
1.9 KiB
C++
Executable file

/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
The above line is usefulin Emacs-like editors
*/
/*
Template for evaluator in EO, a functor that computes the fitness of an EO
==========================================================================
*/
#ifndef _eoOneMaxEvalFunc_h
#define _eoOneMaxEvalFunc_h
// include whatever general include you need
#include <stdexcept>
#include <fstream>
// include the base definition of eoEvalFunc
#include <paradiseo/eo/eoEvalFunc.h>
/**
Always write a comment in this format before class definition
if you want the class to be documented by Doxygen
*/
template <class EOT>
class eoOneMaxEvalFunc : public eoEvalFunc<EOT>
{
public:
/// Ctor - no requirement
// START eventually add or modify the anyVariable argument
eoOneMaxEvalFunc()
// eoOneMaxEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
// END eventually add or modify the anyVariable argument
{
// START Code of Ctor of an eoOneMaxEvalFunc object
// END Code of Ctor of an eoOneMaxEvalFunc object
}
/** Actually compute the fitness
*
* @param EOT & _eo the EO object to evaluate
* it should stay templatized to be usable
* with any fitness type
*/
void operator()(EOT & _eo)
{
// test for invalid to avoid recomputing fitness of unmodified individuals
if (_eo.invalid())
{
double fit; // to hold fitness value
// START Code of computation of fitness of the eoOneMax object
const vector<bool> & b = _eo.B();
fit = 0;
for (unsigned i=0; i<b.size(); i++)
fit += (b[i]?0:1);
// END Code of computation of fitness of the eoOneMax object
_eo.fitness(fit);
}
}
private:
// START Private data of an eoOneMaxEvalFunc object
// varType anyVariable; // for example ...
// END Private data of an eoOneMaxEvalFunc object
};
#endif