Added a new xover to varlenxover
This commit is contained in:
parent
d8fe00183a
commit
8ff63ff776
2 changed files with 32 additions and 2 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
Marc.Schoenauer@polytechnique.fr
|
Marc.Schoenauer@polytechnique.fr
|
||||||
mak@dhi.dk
|
mak@dhi.dk
|
||||||
CVS Info: $Date: 2001-03-21 13:09:47 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.5 2001-03-21 13:09:47 jmerelo Exp $ $Author: jmerelo $
|
CVS Info: $Date: 2001-03-21 13:35:09 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.6 2001-03-21 13:35:09 jmerelo Exp $ $Author: jmerelo $
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -147,6 +147,36 @@ private:
|
||||||
unsigned Min, Max;
|
unsigned Min, Max;
|
||||||
eoAtomExchange<AtomType> & atomExchange;
|
eoAtomExchange<AtomType> & atomExchange;
|
||||||
};
|
};
|
||||||
|
/** Exchange Crossover using an AtomExchange
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class EOT>
|
||||||
|
class eoInnerExchangeQuadOp : public eoQuadOp<EOT>
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
|
||||||
|
typedef typename EOT::AtomType AtomType;
|
||||||
|
|
||||||
|
// default ctor: requires bounds on number of genes + a rate
|
||||||
|
eoInnerExchangeQuadOp( eoQuadOp<AtomType>& _op, float _rate = 0.5):
|
||||||
|
op(_op), rate( _rate ) {}
|
||||||
|
|
||||||
|
bool operator()(EOT & _eo1, EOT & _eo2)
|
||||||
|
{
|
||||||
|
unsigned size1 = _eo1.size(), size2 = _eo2.size(), minsize = ( size1 > size2)?size2:size1;
|
||||||
|
bool changed = false;
|
||||||
|
for ( unsigned i = 0; i < minsize; i ++ ) {
|
||||||
|
if ( rng.flip( rate ) ) {
|
||||||
|
bool changedHere = op( _eo1[i], _eo2[i] );
|
||||||
|
changed |= changedHere;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed; // should we test that? Yes, but no time now
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
float rate;
|
||||||
|
eoQuadOp<AtomType> & op;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
CVS Info: $Date: 2001-02-13 22:35:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoParser.h,v 1.7 2001-02-13 22:35:07 jmerelo Exp $ $Author: jmerelo $ $Log$
|
CVS Info: $Date: 2001-03-21 13:35:10 $ $Version$ $Author: jmerelo $
|
||||||
*/
|
*/
|
||||||
#ifndef eoParser_h
|
#ifndef eoParser_h
|
||||||
#define eoParser_h
|
#define eoParser_h
|
||||||
|
|
|
||||||
Reference in a new issue