Adding Templates in dir tutorial, to hold some simple files that
only need to be filled by the user to code new items. At the moment, only eoMonOp (in mutation.tmpl), and eoBinOp and eoQuadOp (in crossover.tmpl)
This commit is contained in:
parent
00b435f19a
commit
3d93a07d74
2 changed files with 103 additions and 0 deletions
68
eo/tutorial/Templates/crossover.tmpl
Normal file
68
eo/tutorial/Templates/crossover.tmpl
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
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
|
||||
*/
|
||||
void operator()(Indi& Indi1, Indi& Indi2)
|
||||
{
|
||||
// do whatever needs to be done
|
||||
|
||||
// DON'T FORGET if an individual is modified, to invalidate its fitness!!!
|
||||
Indi1.invalidate();
|
||||
Indi2.invalidate();
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
void operator()(Indi& Indi1, const Indi& Indi2)
|
||||
{
|
||||
// do whatever needs to be done
|
||||
// DON'T FORGET if an individual is modified, to invalidate its fitness!!!
|
||||
Indi1.invalidate();
|
||||
}
|
||||
|
||||
protected:
|
||||
paramType anyParameter
|
||||
};
|
||||
35
eo/tutorial/Templates/mutation.tmpl
Normal file
35
eo/tutorial/Templates/mutation.tmpl
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
Template for simple operators
|
||||
=============================
|
||||
|
||||
===========================================================================
|
||||
eoMon : mutation operators
|
||||
======
|
||||
|
||||
template<class Indi> class eoMyDerivedMonOp: public eoMonOp<Indi>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
*/
|
||||
eoMyDerivedMonOp(paramType _anyParameter) :
|
||||
anyParameter(_anyParameter) {}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
string className() const { return "eoMyDerivedMonOp"; }
|
||||
|
||||
/**
|
||||
* eoMon crossover - modifies the parent
|
||||
* @param Indi The parent
|
||||
*/
|
||||
void operator()(Indi& Indi)
|
||||
{
|
||||
// do whatever needs to be done
|
||||
|
||||
// DON'T FORGET if an individual is modified, to invalidate its fitness!!!
|
||||
Indi.invalidate();
|
||||
}
|
||||
|
||||
protected:
|
||||
paramType anyParameter
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue