Adding the generic operators for FIXED-LENGTH ORDERED genotypes eoFlOrXxxOp.h
This commit is contained in:
parent
b643ec2be3
commit
3a8d9dd7a9
4 changed files with 602 additions and 0 deletions
219
eo/src/eoFlOrBinOp.h
Normal file
219
eo/src/eoFlOrBinOp.h
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoFlOrBinOp.h
|
||||
// (c) Marc Schoenauer - Maarten Keijzer 2000-2003
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Marc.Schoenauer@inria.fr
|
||||
mkeijzer@cs.vu.nl
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoFlOrBinOp_h
|
||||
#define _eoFlOrBinOp_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <eoOp.h>
|
||||
|
||||
/** Generic eoBinOps on fixed length genotypes.
|
||||
* Contains exchange crossovers (1pt and uniform)
|
||||
* and crossovers that applies an Atom crossover
|
||||
* to all components with given rate, or
|
||||
* to a fixed prescribed nb of components
|
||||
*
|
||||
* Example: the standard bitstring 1-point and uniform crossovers
|
||||
* could be implemented as resp. eoFlOr1ptBinOp and eoFlOrUniformBinOp
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrAllAtomBinOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** Bin Crossover using an Atom Crossover
|
||||
* that is applied to a ALL components with given rate
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrAllAtomBinOp : public eoBinOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom BinOp */
|
||||
eoFlOrAllAtomBinOp( eoBinOp<AtomType>& _op, float _rate = 1.0):
|
||||
op(_op), rate( _rate ) {}
|
||||
|
||||
/** applies Atom crossover to ALL components with given rate */
|
||||
bool operator()(EOT & _eo1, const EOT & _eo2)
|
||||
{
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
bool changed = false;
|
||||
for ( unsigned i = 0; i < _eo1.size(); i++ ) {
|
||||
if ( rng.flip( rate ) ) {
|
||||
bool changedHere = op( _eo1[i], _eo2[i] );
|
||||
changed |= changedHere;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrAllAtomBinOp"; }
|
||||
|
||||
private:
|
||||
double rate;
|
||||
eoBinOp<AtomType> & op;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrKAtomBinOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** Bin Crossover using an Atom Crossover
|
||||
* that is applied to a FIXED NB of components
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrKAtomBinOp : public eoBinOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom BinOp and an unsigned */
|
||||
eoFlOrAtomBinOp( eoBinOp<AtomType>& _op, unsigned _k = 1):
|
||||
op(_op), k( _k ) {}
|
||||
|
||||
/** applies the Atom BinOp to some components */
|
||||
bool operator()(EOT & _eo1, const EOT & _eo2)
|
||||
{
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
for ( unsigned i = 0; i < k; i++ ) // TODO: check that we don't do twice the same
|
||||
{
|
||||
unsigned where = eo::rng.random(_eo1.size());
|
||||
bool changedHere = op( _eo1[where], _eo2[where] );
|
||||
changed |= changedHere;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrKAtomBinOp"; }
|
||||
|
||||
private:
|
||||
unsigned k;
|
||||
eoBinOp<AtomType> & op;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrUniformBinOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** The uniform crossover - exchanges atoms uniformly ! */
|
||||
template <class EOT>
|
||||
class eoFlOrUniformBinOp : public eoBinOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires a rate - 0.5 by default */
|
||||
eoFlOrUniformBinOp(double _rate=0.5) : eoBinOp<EOT>(_size),
|
||||
rate(_rate) {}
|
||||
|
||||
/** excahnges atoms at given rate */
|
||||
bool operator()(EOT & _eo1, const EOT & _eo2)
|
||||
{
|
||||
unsigned i;
|
||||
Atom tmp;
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
bool hasChanged = false;
|
||||
for (unsigned i=0; i<_eo1.size(); i++)
|
||||
{
|
||||
if ( (_eo1[i]!=_eo2[i]) && (eo::rng.filp(rate)) )
|
||||
{
|
||||
_eo1[i] = _eo2[i];
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrUniformBinOp"; }
|
||||
|
||||
private:
|
||||
double rate;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOr1ptBinOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** The 1pt crossover (just in case someone wants it some day!) */
|
||||
template <class EOT>
|
||||
class eoFlOr1ptBinOp : public eoBinOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: no argument */
|
||||
eoVlUniformBinOp() {}
|
||||
|
||||
/** exchanges first and second parts of the vectors of Atoms */
|
||||
bool operator()(EOT & _eo1, EOT & _eo2)
|
||||
{
|
||||
unsigned i;
|
||||
Atom tmp;
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
bool hasChanged = false;
|
||||
unsigned where = eo::rng.random(_eo1.size()-1);
|
||||
for (unsigned i=where+1; i<_eo1.size(); i++)
|
||||
{
|
||||
if ( (_eo1[i]!=_eo2[i]) )
|
||||
{
|
||||
_eo1[i] = _eo2[i];
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOr1ptBinOp"; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
124
eo/src/eoFlOrMonOp.h
Normal file
124
eo/src/eoFlOrMonOp.h
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoFlOrMonOp.h
|
||||
// (c) Marc Schoenauer - Maarten Keijzer 2000-2003
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@cs.vu.nl
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoFlOrMonOp_h
|
||||
#define _eoFlOrMonOp_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <eoOp.h>
|
||||
#include <eoInit.h>
|
||||
|
||||
/** Base classes for generic mutations on fixed length chromosomes.
|
||||
* COntains 2 classes that both use an atomic mutation
|
||||
* eoFlOrAllMutation applies the atom mutation to all components with given rate
|
||||
* eoFlOrKMutation applies the atom mutation to a fixed nb of components
|
||||
*
|
||||
* Remark: the standard bit-flip mutation is an eoFlOrAllMutation
|
||||
* with atom mutation == bitflipping
|
||||
*/
|
||||
|
||||
/** applies an atomic mutation to all the components with a given rate
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrAllMutation : public eoMonOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom mutation and a rate */
|
||||
eoFlOrAllMutation(eoMonOp<AtomType> & _atomMutation, double _rate=1.0) :
|
||||
atomMutation(_atomMutation), rate(_rate) {}
|
||||
|
||||
/** applies the atom mutation to all components with given rate */
|
||||
bool operator()(EOT & _eo)
|
||||
{
|
||||
bool modified=false;
|
||||
for (unsigned i=0; i<_eo.size(); i++)
|
||||
if (eo::rng.flip(rate))
|
||||
if (atomMutation(_eo[i]))
|
||||
modified = true;
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
/** inherited className() */
|
||||
virtual string className() const
|
||||
{
|
||||
char s[1024];
|
||||
ostrstream os(s, 1022);
|
||||
os << "eoFlOrAllMutation(" << atomMutation.className() << ")";
|
||||
return string(s);
|
||||
}
|
||||
|
||||
private:
|
||||
eoMonOp<AtomType> & atomMutation; // the atom mutation
|
||||
double rate; // the mutation rate PER ATOM
|
||||
};
|
||||
|
||||
/** Applies an atomic mutation to a fixed
|
||||
number of components (1 by default)
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrKMutation : public eoMonOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom mutation */
|
||||
eoFlOrKMutation(eoMonOp<AtomType> & _atomMutation, unsigned _nb=1) :
|
||||
nb(_nb), atomMutation(_atomMutation) {}
|
||||
|
||||
|
||||
/** applies the atom mutation to K randomly selected components */
|
||||
bool operator()(EOT & _eo)
|
||||
{
|
||||
bool modified=false;
|
||||
for (unsigned k=0; k<nb; k++)
|
||||
{
|
||||
unsigned i = rng.random(_eo.size()); // we don't test for duplicates...
|
||||
if (atomMutation(_eo[i]))
|
||||
modified = true;
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
/** inherited className() */
|
||||
virtual string className() const
|
||||
{
|
||||
char s[1024];
|
||||
ostrstream os(s, 1022);
|
||||
os << "eoFlOrKMutation(" << atomMutation.className() << ")" << ends;
|
||||
return string(s);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned nb; // the number of atoms to mutate
|
||||
eoMonOp<AtomType> & atomMutation; // the atom mutation
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
213
eo/src/eoFlOrQuadOp.h
Normal file
213
eo/src/eoFlOrQuadOp.h
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoFlOrQuadOp.h
|
||||
// (c) Marc Schoenauer - Maarten Keijzer 2000-2003
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@cs.vu.nl
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoFlOrQuadOp_h
|
||||
#define _eoFlOrQuadOp_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <eoOp.h>
|
||||
|
||||
/** Generic eoQuadOps on fixed length genotypes.
|
||||
* Contains exchange crossovers (1pt and uniform)
|
||||
* and crossovers that applies an Atom crossover
|
||||
* to all components with given rate, or
|
||||
* to a fixed prescribed nb of components
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrAllAtomQuadOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Quad Crossover using an Atom Crossover
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrAllAtomQuadOp : public eoQuadOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom QuadOp */
|
||||
eoFlOrAllAtomQuadOp( eoQuadOp<AtomType>& _op, double _rate = 1):
|
||||
op(_op), rate( _rate ) {}
|
||||
|
||||
/** applies Atom crossover to ALL components with given rate */
|
||||
bool operator()(EOT & _eo1, EOT & _eo2)
|
||||
{
|
||||
bool changed = false;
|
||||
for ( unsigned i = 0; i < _eo1.size(); i++ ) {
|
||||
if ( rng.flip( rate ) ) {
|
||||
bool changedHere = op( _eo1[i], _eo2[i] );
|
||||
changed |= changedHere;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrAllAtomQuadOp"; }
|
||||
|
||||
private:
|
||||
double rate;
|
||||
eoQuadOp<AtomType> & op;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrKAtomQuadOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** Quad Crossover using an Atom Crossover
|
||||
* that is applied to a FIXED NB of components
|
||||
*/
|
||||
template <class EOT>
|
||||
class eoFlOrKAtomQuadOp : public eoQuadOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires an Atom QuadOp and an unsigned */
|
||||
eoFlOrAtomQuadOp( eoQuadOp<AtomType>& _op, unsigned _k = 1):
|
||||
op(_op), k( _k ) {}
|
||||
|
||||
/** applies the Atom QuadOp to some components */
|
||||
bool operator()(EOT & _eo1, const EOT & _eo2)
|
||||
{
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
for ( unsigned i = 0; i < k; i++ ) // TODO: check that we don't do twice the same
|
||||
{
|
||||
unsigned where = eo::rng.random(_eo1.size());
|
||||
bool changedHere = op( _eo1[where], _eo2[where] );
|
||||
changed |= changedHere;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrKAtomQuadOp"; }
|
||||
|
||||
private:
|
||||
unsigned k;
|
||||
eoQuadOp<AtomType> & op;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOrUniformQuadOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** The uniform crossover - exchanges atoms uniformly ! */
|
||||
template <class EOT>
|
||||
class eoFlOrUniformQuadOp : public eoQuadOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: requires a rate - 0.5 by default */
|
||||
eoVlUniformQuadOp(double _rate=0.5) : eoQuadOp<EOT>(_size),
|
||||
rate(_rate) {}
|
||||
|
||||
/** excahnges atoms at given rate */
|
||||
bool operator()(EOT & _eo1, EOT & _eo2)
|
||||
{
|
||||
unsigned i;
|
||||
Atom tmp;
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
bool hasChanged = false;
|
||||
for (unsigned i=0; i<_eo1.size(); i++)
|
||||
{
|
||||
if ( (_eo1[i]!=_eo2[i]) && (eo::rng.filp(rate)) )
|
||||
{
|
||||
tmp = _eo1[i];
|
||||
_eo1[i] = _eo2[i];
|
||||
_eo2[i] = tmp;
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOrUniformQuadOp"; }
|
||||
|
||||
private:
|
||||
double rate;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eoFlOr1ptQuadOp
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** The 1pt crossover (just in case someone wants it some day!) */
|
||||
template <class EOT>
|
||||
class eoFlOr1ptQuadOp : public eoQuadOp<EOT>
|
||||
{
|
||||
public :
|
||||
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
/** default ctor: no argument */
|
||||
eoVlUniformQuadOp() {}
|
||||
|
||||
/** exchanges first and second parts of the vectors of Atoms */
|
||||
bool operator()(EOT & _eo1, EOT & _eo2)
|
||||
{
|
||||
unsigned i;
|
||||
Atom tmp;
|
||||
if (_eo1.size() != _eo2.size())
|
||||
{
|
||||
string s = "Operand size don't match in " + className();
|
||||
throw runtime_error(s);
|
||||
}
|
||||
bool hasChanged = false;
|
||||
unsigned where = eo::rng.random(_eo1.size()-1);
|
||||
for (unsigned i=where+1; i<_eo1.size(); i++)
|
||||
{
|
||||
if ( (_eo1[i]!=_eo2[i]) )
|
||||
{
|
||||
tmp = _eo1[i];
|
||||
_eo1[i] = _eo2[i];
|
||||
_eo2[i] = tmp;
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
/** inherited className()*/
|
||||
virtual string className() const { return "eoFlOr1ptQuadOp"; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
46
eo/src/ga/eoBoolFlip.h
Normal file
46
eo/src/ga/eoBoolFlip.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoBoolFlip.h
|
||||
// (c) Marc Schoenauer, 2003
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Marc.Schoenauer@inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoBoolFlip_h
|
||||
#define _eoBoolFlip_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
/** a simple boolean mutation - to be used in generic eoOp's
|
||||
*/
|
||||
class eoBoolFlip : public eoMonOp<bool> {
|
||||
public:
|
||||
/** simply flips the boolean argument */
|
||||
bool operator()(bool & _b)
|
||||
{
|
||||
_b = !_b;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** inherited className() */
|
||||
virtual string className() const {return "boolFlip";}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in a new issue