Well, what do you know, major commit.
Changed the signature of eoMon, eoBin and eoQuadOp to return a bool, without invalidating fitness. Added a set of invalidators to take over that job (see for instance eoSGA and eoSGATransform how this can transparantly used) Derived eoState from eoFunctorStore (for convenience, from a design perspective this may sound wrong) Added a wrap_op function that does the wrapping for you (see eoOpContainer how this made this functor exceedingly less hairy). Checked all the tests removed the eoGeneric*Op family (not needed anymore) and of course changed all the operators to reflect the change (and found a few that didn't invalidate the fitness, thus really pointing out the advantage of the current approach)
This commit is contained in:
parent
17d55ae92b
commit
3a9b5a0e7e
30 changed files with 651 additions and 564 deletions
75
eo/src/obsolete/eoGenericBinOp.h
Normal file
75
eo/src/obsolete/eoGenericBinOp.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoGenericBinOp.h
|
||||
// (c) GeNeura Team, 2000 - EEAAX 1999 - Maarten Keijzer 2000
|
||||
/*
|
||||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoGenericBinOp_h
|
||||
#define _eoGenericBinOp_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
/** Contains base classes for generic binary operators for eoFixedLength
|
||||
and eoVariableLength (They also derive from the eoOp) as well as
|
||||
the corresponding converters to actual Ops.
|
||||
*/
|
||||
|
||||
/** eoGenericBinOp is the generic binary operator:
|
||||
it takes two arguments, modifies the first one, and returns a boolean
|
||||
indicating if the argument has actually been modified
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGenericBinOp: public eoOp<EOT>, public eoBF<EOT &, const EOT &, bool>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGenericBinOp()
|
||||
: eoOp<EOT>( eoOp<EOT>::binary ) {};
|
||||
virtual string className() const {return "eoGenericBinOp";};
|
||||
};
|
||||
|
||||
/** Converter from eoGenericBinOp to eoBinOp
|
||||
the only thinig to do is to transform the boolean into invalidation
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGeneric2TrueBinOp: public eoBinOp<EOT>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGeneric2TrueBinOp(eoGenericBinOp<EOT> & _binOp)
|
||||
: binOp( _binOp ) {};
|
||||
virtual string className() const {return "eoGeneric2TrueBinOp";}
|
||||
|
||||
virtual void operator()(EOT & _eo1, const EOT & _eo2)
|
||||
{
|
||||
if (binOp(_eo1, _eo2))
|
||||
_eo1.invalidate();
|
||||
}
|
||||
|
||||
private:
|
||||
eoGenericBinOp<EOT> & binOp;
|
||||
};
|
||||
|
||||
#endif
|
||||
75
eo/src/obsolete/eoGenericMonOp.h
Normal file
75
eo/src/obsolete/eoGenericMonOp.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoGenericMonOp.h
|
||||
// (c) GeNeura Team, 2000 - EEAAX 1999 - Maarten Keijzer 2000
|
||||
/*
|
||||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoGenericMonOp_h
|
||||
#define _eoGenericMonOp_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
/** Contains base classes for generic operators for eoFixedLength
|
||||
and eoVariableLength (They also derive from the eoOp) as well as
|
||||
the corresponding converters to actual Ops.
|
||||
*/
|
||||
|
||||
/** eoGenericMonOp is the generic unary operator:
|
||||
it takes one argument, and returns a boolean indicating if the argument
|
||||
has been modified
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGenericMonOp: public eoOp<EOT>, public eoUF<EOT&, bool>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGenericMonOp()
|
||||
: eoOp<EOT>( eoOp<EOT>::unary ) {};
|
||||
virtual string className() const {return "eoGenericMonOp";};
|
||||
};
|
||||
|
||||
/** COnverter from eoGenericMonOp to eoMonOp
|
||||
the only thinig to do is to transform the boolean into invalidation
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGeneric2TrueMonOp: public eoMonOp<EOT>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGeneric2TrueMonOp(eoGenericMonOp<EOT> & _monOp)
|
||||
: monOp( _monOp ) {};
|
||||
virtual string className() const {return "eoGeneric2trueMonOp";}
|
||||
|
||||
virtual void operator()(EOT & _eo)
|
||||
{
|
||||
if (monOp(_eo))
|
||||
_eo.invalidate();
|
||||
}
|
||||
|
||||
private:
|
||||
eoGenericMonOp<EOT> & monOp;
|
||||
};
|
||||
|
||||
#endif
|
||||
83
eo/src/obsolete/eoGenericQuadOp.h
Normal file
83
eo/src/obsolete/eoGenericQuadOp.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoGenericQuadOp.h
|
||||
// (c) GeNeura Team, 2000 - EEAAX 1999 - Maarten Keijzer 2000
|
||||
/*
|
||||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoGenericQuadOp_h
|
||||
#define _eoGenericQuadOp_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
/** Contains base classes for generic quadratic operators for eoFixedLength
|
||||
and eoVariableLength (They also derive from the eoOp) as well as
|
||||
the corresponding converters to actual Ops.
|
||||
*/
|
||||
|
||||
/** eoGenericQuadOp is the generic quadratic operator:
|
||||
it takes two arguments, modifies the first one, and returns a boolean
|
||||
indicating if the arguments have actually been modified
|
||||
|
||||
WARNING: even if only 1 argument is modified, it should return true,
|
||||
and both fitnesses will be invalidated. It is assumed that
|
||||
quadratic operators do some exchange of genetic material, so
|
||||
if one is modified, the other is, too!
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGenericQuadOp: public eoOp<EOT>, public eoBF<EOT &, EOT &, bool>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGenericQuadOp()
|
||||
: eoOp<EOT>( eoOp<EOT>::quadratic ) {};
|
||||
virtual string className() const {return "eoGenericQuadOp";};
|
||||
};
|
||||
|
||||
/** Converter from eoGenericQuadOp to eoQuadOp
|
||||
the only thinig to do is to transform the boolean into invalidation
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoGeneric2TrueQuadOp: public eoQuadOp<EOT>
|
||||
{
|
||||
public:
|
||||
/// Ctor
|
||||
eoGeneric2TrueQuadOp(eoGenericQuadOp<EOT> & _quadOp)
|
||||
: quadOp( _quadOp ) {};
|
||||
virtual string className() const {return "eoGeneric2TrueQuadOp";}
|
||||
|
||||
virtual void operator()(EOT & _eo1, EOT & _eo2)
|
||||
{
|
||||
if (quadOp(_eo1, _eo2))
|
||||
{
|
||||
_eo1.invalidate();
|
||||
_eo2.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
eoGenericQuadOp<EOT> & quadOp;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue