paradiseo/tutorial/eo/Templates/moreOffspringGenOp.tmpl
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

77 lines
2.1 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 general operators
===============================
i.e. that takes any number of parents and generates any number of offspring
Here, a GenOp that creates more (or same number of) offspring
than there are parents
*/
#ifndef eoMoreOffspringGenOp_H
#define eoMoreOffspringGenOp_H
#include <eoGenOp.h>
/**
* Always write a comment in this format before class definition
* if you want the class to be documented by Doxygen
*
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
* must be called if the genotypes of the indis is modified
*/
template<class EOT>
class eoMoreOffspringGenOp: public eoGenOp<EOT>
{
public:
/**
* (Default) Constructor.
*/
eoMoreOffspringGenOp(paramType _anyParameter) :
anyParameter(_anyParameter) {}
/// The class name. Used to display statistics
string className() const { return "eoMoreOffspringGenOp"; }
/// The TOTAL number of offspring (including modified parents)
unsigned max_production(void) { return NbOffspring; }
/**
* eoMoreOffspringGenOp operator - eventually modifies the parents
* BUT does generate more offspring
*
* @param _pop a POPULATOR (not a simple population)
*/
void apply(eoPopulator<EOT>& _plop)
{
EOT& parent1 = *_plop; // select the first parent
++_plop; // advance once for each selected parents
...
EOT& parentN = *_plop; // select the last parent
// don't advance after the last one: _plop always
// points to the last that has already been treated
// apply operator to the parents (modifying them AND generating
// new individuals ofs1, ofs2, ..., ofsN
++_plop; // advance before each insertion
_plop.insert(ofs1);
...
++_plop; // advance before each insertion
_plop.insert(ofsN);
// oh right, and invalidate fitnesses of modified parents
parent1.invalidate();
...
parentN.invalidate();
}
private:
paramType anyParameter
};
#endif