Changed MGE to the contrib dir. No need to change the prefix, I guess
This commit is contained in:
parent
e32c52d332
commit
17dc4f9d10
6 changed files with 81 additions and 14 deletions
|
|
@ -18,7 +18,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
|
||||||
CVS Info: $Date: 2001-05-10 12:16:00 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/MGE/Attic/VirusOp.h,v 1.1 2001-05-10 12:16:00 jmerelo Exp $ $Author: jmerelo $
|
CVS Info: $Date: 2001-05-17 10:08:25 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/VirusOp.h,v 1.1 2001-05-17 10:08:25 jmerelo Exp $ $Author: jmerelo $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VirusOp_h
|
#ifndef VirusOp_h
|
||||||
|
|
@ -33,9 +33,7 @@ CVS Info: $Date: 2001-05-10 12:16:00 $ $Header: /home/nojhan/dev/eodev/eodev_cvs
|
||||||
#include <utils/eoRNG.h>
|
#include <utils/eoRNG.h>
|
||||||
#include <MGE/eoVirus.h>
|
#include <MGE/eoVirus.h>
|
||||||
|
|
||||||
/** eoBitFlip --> changes 1 bit
|
/** VirusBitFlip --> changes 1 bit
|
||||||
\class eoBitBitFlip eoBitOp.h ga/eoBitOp.h
|
|
||||||
\ingroup bitstring
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<class FitT>
|
template<class FitT>
|
||||||
|
|
@ -83,6 +81,46 @@ class VirusMutation: public eoMonOp<eoVirus<FitT> > {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Works for 1-bit virus; shifts the one to the right or left
|
||||||
|
template<class FitT>
|
||||||
|
class VirusShiftMutation: public eoMonOp<eoVirus<FitT> > {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Ctor
|
||||||
|
VirusShiftMutation( ) {};
|
||||||
|
|
||||||
|
/// The class name.
|
||||||
|
virtual string className() const { return "VirusShiftMutation"; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change one bit.
|
||||||
|
* @param chrom The cromosome which one bit is going to be changed.
|
||||||
|
*/
|
||||||
|
bool operator()(eoVirus<FitT>& _chrom) {
|
||||||
|
// Search for virus bits
|
||||||
|
eoBooleanGenerator gen;
|
||||||
|
for ( unsigned i = 0; i < _chrom.size(); i ++ ) {
|
||||||
|
if ( _chrom.virusBit(i) ) {
|
||||||
|
if ( gen() ) {
|
||||||
|
if ( i + 1 < _chrom.size() ) {
|
||||||
|
_chrom.virusBitSet(i+1,true);
|
||||||
|
_chrom.virusBitSet(i, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( i - 1 > 0 ) {
|
||||||
|
_chrom.virusBitSet(i-1,true);
|
||||||
|
_chrom.virusBitSet(i, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class FitT>
|
template<class FitT>
|
||||||
class VirusTransmission: public eoBinOp<eoVirus<FitT> > {
|
class VirusTransmission: public eoBinOp<eoVirus<FitT> > {
|
||||||
public:
|
public:
|
||||||
|
|
@ -61,4 +61,26 @@ private :
|
||||||
eoSTLF<bool> generator;
|
eoSTLF<bool> generator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Inits the virus with one bit to the left set to one
|
||||||
|
template <class FitT>
|
||||||
|
class eoInitVirus1bit: public eoInit< eoVirus<FitT> > {
|
||||||
|
public:
|
||||||
|
|
||||||
|
eoInitVirus1bit(unsigned _combien, eoRndGenerator<bool>& _generator )
|
||||||
|
: combien(_combien), generator(_generator) {}
|
||||||
|
|
||||||
|
virtual void operator()( eoVirus<FitT>& chrom)
|
||||||
|
{
|
||||||
|
chrom.resize(combien);
|
||||||
|
chrom.virResize(combien);
|
||||||
|
std::generate(chrom.begin(), chrom.end(), generator);
|
||||||
|
chrom.virusBitSet(0, true );
|
||||||
|
chrom.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private :
|
||||||
|
unsigned combien;
|
||||||
|
/// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics
|
||||||
|
eoSTLF<bool> generator;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -18,7 +18,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
|
||||||
CVS Info: $Date: 2001-05-10 12:16:00 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/MGE/Attic/eoVirus.h,v 1.1 2001-05-10 12:16:00 jmerelo Exp $ $Author: jmerelo $
|
CVS Info: $Date: 2001-05-17 10:08:25 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/contrib/MGE/eoVirus.h,v 1.1 2001-05-17 10:08:25 jmerelo Exp $ $Author: jmerelo $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef eoVirus_h
|
#ifndef eoVirus_h
|
||||||
|
|
@ -8,12 +8,13 @@ DEPS = $(top_builddir)/src/utils/libeoutils.a $(top_builddir)/src/libeo.a
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
INCLUDES = -I$(top_builddir)/src
|
INCLUDES = -I$(top_builddir)/src -I$(top_builddir)/contrib
|
||||||
LDADDS = $(top_builddir)/src/utils/libeoutils.a $(top_builddir)/src/libeo.a
|
LDADDS = $(top_builddir)/src/utils/libeoutils.a $(top_builddir)/src/libeo.a
|
||||||
CXXFLAGS = -g -Wall
|
CXXFLAGS = -g -Wall
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
check_PROGRAMS = t-eoParetoFitness t-eoPareto t-eofitness t-eoRandom t-eobin t-eoVirus t-MGE t-MGE-control t-eoStateAndParser t-eoCheckpointing t-eoSSGA \
|
check_PROGRAMS = t-eoParetoFitness t-eoPareto t-eofitness t-eoRandom t-eobin t-eoVirus\
|
||||||
|
t-MGE t-MGE1bit t-MGE-control t-eoStateAndParser t-eoCheckpointing t-eoSSGA \
|
||||||
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal t-eoVector t-eoESAll
|
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal t-eoVector t-eoESAll
|
||||||
TESTS=run_tests t-eoVector t-eoRandom t-eoSSGA t-eoPareto t-eoParetoFitness
|
TESTS=run_tests t-eoVector t-eoRandom t-eoSSGA t-eoPareto t-eoParetoFitness
|
||||||
# removing temporarily t-eoESFull
|
# removing temporarily t-eoESFull
|
||||||
|
|
@ -45,6 +46,12 @@ t_eoVirus_LDADD = $(LDADDS)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
t_MGE1bit_SOURCES = t-MGE1bit.cpp binary_value.h
|
||||||
|
t_MGE1bit_DEPENDENCIES = $(DEPS)
|
||||||
|
t_MGE1bit_LDADD = $(LDADDS)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
t_MGE_SOURCES = t-MGE.cpp binary_value.h
|
t_MGE_SOURCES = t-MGE.cpp binary_value.h
|
||||||
t_MGE_DEPENDENCIES = $(DEPS)
|
t_MGE_DEPENDENCIES = $(DEPS)
|
||||||
t_MGE_LDADD = $(LDADDS)
|
t_MGE_LDADD = $(LDADDS)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ int main()
|
||||||
eoPop<Chrom> pop;
|
eoPop<Chrom> pop;
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
RoyalRoad<Chrom> rr( 4 );
|
RoyalRoad<Chrom> rr( 8 );
|
||||||
eoEvalFuncCounter<Chrom> eval( rr );
|
eoEvalFuncCounter<Chrom> eval( rr );
|
||||||
|
|
||||||
eoInitVirus<float> random(CHROM_SIZE, gen);
|
eoInitVirus<float> random(CHROM_SIZE, gen);
|
||||||
|
|
@ -56,8 +56,8 @@ int main()
|
||||||
eoUBitXover<Chrom> xover;
|
eoUBitXover<Chrom> xover;
|
||||||
eoProportionalOp<Chrom> propSel;
|
eoProportionalOp<Chrom> propSel;
|
||||||
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
|
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
|
||||||
propSel.add(vm, 0.8);
|
propSel.add(vm, 0.2);
|
||||||
propSel.add(xover, 0.1);
|
propSel.add(xover, 0.8);
|
||||||
|
|
||||||
// Replace a single one
|
// Replace a single one
|
||||||
eoCommaReplacement<Chrom> replace;
|
eoCommaReplacement<Chrom> replace;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ int main()
|
||||||
eoPop<Chrom> pop;
|
eoPop<Chrom> pop;
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
RoyalRoad<Chrom> rr( 4 );
|
RoyalRoad<Chrom> rr( 8 );
|
||||||
eoEvalFuncCounter<Chrom> eval( rr );
|
eoEvalFuncCounter<Chrom> eval( rr );
|
||||||
|
|
||||||
eoInitVirus<float> random(CHROM_SIZE, gen);
|
eoInitVirus<float> random(CHROM_SIZE, gen);
|
||||||
|
|
@ -58,10 +58,10 @@ int main()
|
||||||
eoUBitXover<Chrom> xover;
|
eoUBitXover<Chrom> xover;
|
||||||
eoProportionalOp<Chrom> propSel;
|
eoProportionalOp<Chrom> propSel;
|
||||||
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
|
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
|
||||||
propSel.add(vm, 0.8);
|
propSel.add(vm, 0.1);
|
||||||
propSel.add(vf, 0.05);
|
propSel.add(vf, 0.05);
|
||||||
propSel.add(vt, 0.05);
|
propSel.add(vt, 0.05);
|
||||||
propSel.add(xover, 0.1);
|
propSel.add(xover, 0.8);
|
||||||
|
|
||||||
// Replace a single one
|
// Replace a single one
|
||||||
eoCommaReplacement<Chrom> replace;
|
eoCommaReplacement<Chrom> replace;
|
||||||
|
|
|
||||||
Reference in a new issue