Modified the className() method so that the Atom underlying operator is listed

This commit is contained in:
evomarc 2001-09-04 06:51:59 +00:00
commit f69b785b39
2 changed files with 43 additions and 4 deletions

View file

@ -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: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 $ CVS Info: $Date: 2001-09-04 06:51:59 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.7 2001-09-04 06:51:59 evomarc Exp $ $Author: evomarc $
*/ */
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -45,6 +45,7 @@ class eoAtomExchange : public eoBF<unsigned, Atom &, bool>
public: public:
// a function to initlialize - to be called before every crossover // a function to initlialize - to be called before every crossover
virtual void randomize(unsigned int, unsigned int){} virtual void randomize(unsigned int, unsigned int){}
virtual string className() const=0;
}; };
/** Uniform crossover - well, not really for FixedLength */ /** Uniform crossover - well, not really for FixedLength */
@ -68,6 +69,9 @@ public:
{ {
return mask[_i]; return mask[_i];
} }
virtual string className() const {return "eoUniformAtomExchange";}
private: private:
double rate; double rate;
vector<bool> mask; vector<bool> mask;
@ -143,11 +147,21 @@ public :
_eo2.swap(tmp2); _eo2.swap(tmp2);
return true; // should we test that? Yes, but no time now return true; // should we test that? Yes, but no time now
} }
virtual string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoVlAtomExchangeQuadOp(" << atomExchange.className() << ")" << ends;
return string(s);
}
private: private:
unsigned Min, Max; unsigned Min, Max;
eoAtomExchange<AtomType> & atomExchange; eoAtomExchange<AtomType> & atomExchange;
}; };
/** Exchange Crossover using an AtomExchange
/** Crossover using an AtomCrossover (probably irrelevant in Variable Length)
*/ */
template <class EOT> template <class EOT>
@ -173,6 +187,14 @@ public :
} }
return changed; // should we test that? Yes, but no time now return changed; // should we test that? Yes, but no time now
} }
virtual string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoInnerExchangeQuadOp(" << atomExchange.className() << ")" << ends;
return string(s);
}
private: private:
float rate; float rate;
eoQuadOp<AtomType> & op; eoQuadOp<AtomType> & op;

View file

@ -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-07-11 06:26:11 $ $Version$ $Author: evomarc $ CVS Info: $Date: 2001-09-04 06:51:59 $ $Version$ $Author: evomarc $
*/ */
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -71,6 +71,9 @@ public :
_eo.insert(_eo.begin()+pos, atom); _eo.insert(_eo.begin()+pos, atom);
return true; return true;
} }
virtual string className() const { return "eoVlAddMutation"; }
private: private:
unsigned nMax; unsigned nMax;
eoInit<AtomType> & atomInit; eoInit<AtomType> & atomInit;
@ -79,7 +82,11 @@ private:
/** A helper class for choosing which site to delete */ /** A helper class for choosing which site to delete */
template <class EOT> template <class EOT>
class eoGeneDelChooser : public eoUF<EOT &, unsigned int> class eoGeneDelChooser : public eoUF<EOT &, unsigned int>
{}; {
public:
virtual string className() const =0;
};
/** Uniform choice of gene to delete */ /** Uniform choice of gene to delete */
template <class EOT> template <class EOT>
@ -91,6 +98,7 @@ public:
{ {
return eo::rng.random(_eo.size()); return eo::rng.random(_eo.size());
} }
virtual string className() const { return "eoUniformGeneChooser"; }
}; };
/** Deletion of a gene /** Deletion of a gene
@ -130,6 +138,15 @@ public :
_eo.erase(_eo.begin()+pos); _eo.erase(_eo.begin()+pos);
return true; return true;
} }
virtual string className() const
{
char s[1024];
ostrstream os(s, 1022);
os << "eoVlDelMutation(" << chooser.className() << ")" << ends;
return string(s);
}
private: private:
unsigned nMin; unsigned nMin;
eoUniformGeneChooser<EOT> uChooser; eoUniformGeneChooser<EOT> uChooser;