Added the genop.tmpl, template for general op, 3 cases, growing pop, shrinking pop through erase, thrinking pop through extra selector
71 lines
1.7 KiB
Cheetah
71 lines
1.7 KiB
Cheetah
Template for simple operators
|
|
=============================
|
|
|
|
===========================================================================
|
|
eoQuad : crossover operators that take 2 parents and modify both
|
|
======
|
|
|
|
template<class Indi> class eoMyDerivedQuadOp: public eoQuadOp<Indi>
|
|
{
|
|
public:
|
|
/**
|
|
* (Default) Constructor.
|
|
*/
|
|
eoMyDerivedQuadOp(paramType _anyParameter) :
|
|
anyParameter(_anyParameter) {}
|
|
|
|
/// The class name. Used to display statistics
|
|
string className() const { return "eoMyDerivedQuadOp"; }
|
|
|
|
/**
|
|
* eoQuad crossover - modifies both parents
|
|
* @param Indi1 The first parent
|
|
* @param Indi2 The first parent
|
|
*/
|
|
bool operator()(Indi& Indi1, Indi& Indi2)
|
|
{
|
|
// do whatever needs to be done
|
|
|
|
// if at least one individual has been modified
|
|
return true;
|
|
// otherwise
|
|
// return false;
|
|
}
|
|
|
|
protected:
|
|
paramType anyParameter
|
|
};
|
|
|
|
===========================================================================
|
|
eoBin : crossover operators that take 2 parents and modify the first one
|
|
=====
|
|
|
|
template<class Indi> class eoMyDerivedBinOp: public eoBinOp<Indi>
|
|
{
|
|
public:
|
|
/**
|
|
* (Default) Constructor.
|
|
*/
|
|
eoMyDerivedBinOp(paramType _anyParameter) :
|
|
anyParameter(_anyParameter) {}
|
|
|
|
/// The class name. Used to display statistics
|
|
string className() const { return "eoMyDerivedBinOp"; }
|
|
|
|
/**
|
|
* eoQuad crossover - modifies first parent only
|
|
* @param Indi1 The first parent
|
|
* @param Indi2 The first parent - const
|
|
*/
|
|
bool operator()(Indi& Indi1, const Indi& Indi2)
|
|
{
|
|
// do whatever needs to be done
|
|
// if Indi1 has been modified
|
|
return true;
|
|
// otherwise
|
|
// return false;
|
|
}
|
|
|
|
protected:
|
|
paramType anyParameter
|
|
};
|