From d634d95838d0cd0777e4c73732eba32aa092bd19 Mon Sep 17 00:00:00 2001 From: jmerelo Date: Tue, 3 Apr 2001 10:08:08 +0000 Subject: [PATCH] In eoVector, changed printOn and readFrom to virtual --- eo/src/eoDominanceMap.h | 2 +- eo/src/eoGenContinue.h | 58 +++++++++++++++--------------- eo/src/eoNDSorting.h | 2 +- eo/src/eoPop.h | 20 +++++------ eo/src/eoVector.h | 6 ++-- eo/src/utils/eoFileMonitor.h | 2 ++ eo/src/utils/eoMonitor.h | 4 ++- eo/src/utils/eoStdoutMonitor.h | 2 +- eo/tutorial/Lesson1/FirstBitGA.cpp | 6 ++-- eo/tutorial/Lesson1/Makefile | 4 +-- 10 files changed, 54 insertions(+), 52 deletions(-) diff --git a/eo/src/eoDominanceMap.h b/eo/src/eoDominanceMap.h index 582501be6..01b76e2d7 100644 --- a/eo/src/eoDominanceMap.h +++ b/eo/src/eoDominanceMap.h @@ -162,4 +162,4 @@ class eoDominanceMap : public eoUF&, void>, public std::vect vector fitness; }; -#endif \ No newline at end of file +#endif diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index c1219450c..201d15ac0 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -35,48 +35,48 @@ class eoGenContinue: public eoContinue { 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& _vEO ) { - thisGeneration++; - // cout << " [" << thisGeneration << "] "; + thisGenerationPlaceHolder(0), + thisGeneration(_currentGen){}; + + /** Returns false when a certain number of generations is + * reached */ + virtual bool operator() ( const eoPop& _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 diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index 56be9077d..dea76083b 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -296,4 +296,4 @@ class eoNDSorting_II : public eoNDSorting }; -#endif \ No newline at end of file +#endif diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index 8731258c5..caebf929e 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -244,23 +244,21 @@ class eoPop: public vector, public eoObject, public eoPersistent copy( begin(), end(), ostream_iterator( _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 ); } } diff --git a/eo/src/eoVector.h b/eo/src/eoVector.h index 2be9e8e06..2895999ca 100644 --- a/eo/src/eoVector.h +++ b/eo/src/eoVector.h @@ -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, public std::vector } /// printing... - void printOn(ostream& os) const + virtual void printOn(ostream& os) const { EO::printOn(os); os << ' '; @@ -85,7 +85,7 @@ class eoVector : public EO, public std::vector } /// reading... - void readFrom(istream& is) + virtual void readFrom(istream& is) { EO::readFrom(is); diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index d4a217908..514f106cc 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -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. diff --git a/eo/src/utils/eoMonitor.h b/eo/src/utils/eoMonitor.h index 1af487288..d71a2a0ff 100644 --- a/eo/src/utils/eoMonitor.h +++ b/eo/src/utils/eoMonitor.h @@ -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 $ + */ //----------------------------------------------------------------------------- diff --git a/eo/src/utils/eoStdoutMonitor.h b/eo/src/utils/eoStdoutMonitor.h index 63332ded5..2cab5e81e 100644 --- a/eo/src/utils/eoStdoutMonitor.h +++ b/eo/src/utils/eoStdoutMonitor.h @@ -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 diff --git a/eo/tutorial/Lesson1/FirstBitGA.cpp b/eo/tutorial/Lesson1/FirstBitGA.cpp index c1a41870e..4ff0ff0c9 100644 --- a/eo/tutorial/Lesson1/FirstBitGA.cpp +++ b/eo/tutorial/Lesson1/FirstBitGA.cpp @@ -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 diff --git a/eo/tutorial/Lesson1/Makefile b/eo/tutorial/Lesson1/Makefile index e6b995e8b..23fb9a6c5 100644 --- a/eo/tutorial/Lesson1/Makefile +++ b/eo/tutorial/Lesson1/Makefile @@ -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