In eoVector, changed printOn and readFrom to virtual

This commit is contained in:
jmerelo 2001-04-03 10:08:08 +00:00
commit d634d95838
10 changed files with 54 additions and 52 deletions

View file

@ -162,4 +162,4 @@ class eoDominanceMap : public eoUF<const eoPop<EoType>&, void>, public std::vect
vector<typename EoType::Fitness> fitness;
};
#endif
#endif

View file

@ -35,48 +35,48 @@ class eoGenContinue: public eoContinue<EOT>
{
public:
/// Ctor for setting a
eoGenContinue( unsigned long _totalGens)
/// Ctor for setting a
eoGenContinue( unsigned long _totalGens)
: repTotalGenerations( _totalGens ),
thisGenerationPlaceHolder(0),
thisGeneration(thisGenerationPlaceHolder){};
/// Ctor for enabling the save/load the no. of generations counted
eoGenContinue( unsigned long _totalGens, unsigned long& _currentGen)
thisGenerationPlaceHolder(0),
thisGeneration(thisGenerationPlaceHolder){};
/// Ctor for enabling the save/load the no. of generations counted
eoGenContinue( unsigned long _totalGens, unsigned long& _currentGen)
: repTotalGenerations( _totalGens ),
thisGenerationPlaceHolder(0),
thisGeneration(_currentGen){};
/** Returns false when a certain number of generations is
* reached */
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
thisGeneration++;
// cout << " [" << thisGeneration << "] ";
thisGenerationPlaceHolder(0),
thisGeneration(_currentGen){};
/** Returns false when a certain number of generations is
* reached */
virtual bool operator() ( const eoPop<EOT>& _vEO ) {
thisGeneration++;
// cout << " [" << thisGeneration << "] ";
if (thisGeneration >= repTotalGenerations)
{
cout << "STOP in eoGenContinue: Reached maximum number of generations [" << thisGeneration << "/" << repTotalGenerations << "]\n";
return false;
}
return true;
}
/** Sets the number of generations to reach
}
/** Sets the number of generations to reach
and sets the current generation to 0 (the begin)*/
virtual void totalGenerations( unsigned long _tg ) {
virtual void totalGenerations( unsigned long _tg ) {
repTotalGenerations = _tg;
thisGeneration = 0;
};
/** Returns the number of generations to reach*/
virtual unsigned long totalGenerations( )
{
return repTotalGenerations;
};
/** Returns the number of generations to reach*/
virtual unsigned long totalGenerations( )
{
return repTotalGenerations;
};
private:
unsigned long repTotalGenerations;
unsigned long thisGenerationPlaceHolder;
unsigned long& thisGeneration;
unsigned long repTotalGenerations;
unsigned long thisGenerationPlaceHolder;
unsigned long& thisGeneration;
};
#endif

View file

@ -296,4 +296,4 @@ class eoNDSorting_II : public eoNDSorting<EOT>
};
#endif
#endif

View file

@ -244,23 +244,21 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
copy( begin(), end(), ostream_iterator<EOT>( _os, "\n") );
};
/** @name Methods from eoObject */
//@{
/**
* Read object. The EOT class must have a ctor from a stream;
in this case, a strstream is used.
* @param _is A istream.
*/
/** @name Methods from eoObject */
//@{
/**
* Read object. The EOT class must have a ctor from a stream;
in this case, a strstream is used.
* @param _is A istream.
*/
virtual void readFrom(istream& _is)
{
size_t sz;
size_t sz;
_is >> sz;
resize(sz);
for (size_t i = 0; i < sz; ++i)
{
for (size_t i = 0; i < sz; ++i) {
operator[](i).readFrom( _is );
}
}

View file

@ -22,7 +22,7 @@
Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
CVS Info: $Date: 2001-03-21 12:10:13 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.9 2001-03-21 12:10:13 jmerelo Exp $ $Author: jmerelo $
CVS Info: $Date: 2001-04-03 10:08:06 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVector.h,v 1.10 2001-04-03 10:08:06 jmerelo Exp $ $Author: jmerelo $
*/
//-----------------------------------------------------------------------------
@ -74,7 +74,7 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
}
/// printing...
void printOn(ostream& os) const
virtual void printOn(ostream& os) const
{
EO<FitT>::printOn(os);
os << ' ';
@ -85,7 +85,7 @@ class eoVector : public EO<FitT>, public std::vector<GeneType>
}
/// reading...
void readFrom(istream& is)
virtual void readFrom(istream& is)
{
EO<FitT>::readFrom(is);

View file

@ -21,6 +21,8 @@
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.9 2001-04-03 10:08:07 jmerelo Exp $ $Author: jmerelo $
*/
//-----------------------------------------------------------------------------
/** Modified the default behavior, so that it erases existing files.

View file

@ -1,7 +1,7 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoParam.h
// eoMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
This library is free software; you can redistribute it and/or
@ -21,6 +21,8 @@
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
CVS Info: $Date: 2001-04-03 10:08:07 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoMonitor.h,v 1.9 2001-04-03 10:08:07 jmerelo Exp $ $Author: jmerelo $
*/
//-----------------------------------------------------------------------------

View file

@ -1,7 +1,7 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoFileMonitor.h
// eoStdoutMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
/*
This library is free software; you can redistribute it and/or

View file

@ -40,9 +40,9 @@ void main_function(int argc, char **argv)
// all parameters are hard-coded!
const unsigned int SEED = 42; // seed for random number generator
const unsigned int T_SIZE = 3; // size for tournament selection
const unsigned int VEC_SIZE = 8; // Number of bits in genotypes
const unsigned int POP_SIZE = 20; // Size of population
const unsigned int MAX_GEN = 100; // Maximum number of generation before STOP
const unsigned int VEC_SIZE = 16; // Number of bits in genotypes
const unsigned int POP_SIZE = 100; // Size of population
const unsigned int MAX_GEN = 400; // Maximum number of generation before STOP
const float CROSS_RATE = 0.8; // Crossover rate
const double P_MUT_PER_BIT = 0.01; // probability of bit-flip mutation
const float MUT_RATE = 1.0; // mutation rate

View file

@ -1,6 +1,6 @@
.cpp: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../src -Wall -g -o $@ $*.cpp ../../src/libeo.a ../../src/utils/libeoutils.a
.cpp: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../src -Wall -g -pg -o $@ $*.cpp ../../src/libeo.a ../../src/utils/libeoutils.a
.cpp.o: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../src -Wall -g -c $*.cpp
.cpp.o: ; c++ -DPACKAGE=\"eo\" -DVERSION=\"0.9.1\" -I. -I../../src -Wall -g -c -pg $*.cpp
firstGA = FirstRealGA FirstBitGA