Moving function InitRamdom to eoParserUtils.h

This commit is contained in:
victor 1999-12-17 12:04:06 +00:00
commit 5a735c3915
4 changed files with 883 additions and 852 deletions

View file

@ -5,20 +5,22 @@
###############################################################################
lib_LIBRARIES = libeo.a
libeo_a_SOURCES = eoPrintable.cpp eoPersistent.cpp
libeo_a_SOURCES = eoPrintable.cpp eoPersistent.cpp eoParserUtils.cpp
libeoincdir = $(includedir)/eo
libeoinc_HEADERS = EO.h eo eo1d.h eo2d.h eo2dVector.h eoAged.h eoAlgo.h\
eoAtomBitFlip.h eoAtomCreep.h eoAtomMutation.h eoAtomMutator.h \
eoAtomRandom.h eoBin.h eoBitOp.h eoBitOpFactory.h eoBreeder.h\
eoData.h eoDetTournament.h eoDup.h eoESChrom.h eoESFullChrom.h eoESFullMut.h eoEasyEA.h\
eoData.h eoDetTournament.h eoDup.h eoESChrom.h eoESFullChrom.h \
eoESFullMut.h eoEasyEA.h\
eoEvalFunc.h eoEvalFuncPtr.h eoFitTerm.h eoFitness.h\
eoGenTerm.h eoGeneration.h eoID.h eoInclusion.h eoInsertion.h\
eoKill.h eoLottery.h eoMerge.h eoMultiBinOp.h eoMultiMonOp.h eoMutation.h eoNegExp.h\
eoKill.h eoLottery.h eoMerge.h eoMultiBinOp.h eoMultiMonOp.h \
eoMutation.h eoNegExp.h\
eoNonUniform.h eoNormal.h eoObject.h eoOp.h eoOpSelector.h\
eoParser.h eoPersistent.h eoPop.h eoPopOps.h eoPrintable.h\
eoProblem.h eoProportionalOpSel.h eoRNG.h eoRnd.h eoString.h\
eoStochTournament.h eoTerm.h eoTranspose.h eoUniform.h \
eoUniformSelect.h eoUniformXOver.h eoVector.h eoXOver2.h
eoUniformSelect.h eoUniformXOver.h eoVector.h eoXOver2.h \
eoParserUtils.h

File diff suppressed because it is too large Load diff

32
eo/src/eoParserUtils.cpp Normal file
View file

@ -0,0 +1,32 @@
// See eoParserUtils.h
#include <iostream.h>
#include <eoParserUtils.h>
/// Reproducible random seed
//----------------------------------
void InitRandom( Parser & parser) {
//----------------------------------
unsigned long _seed;
try {
_seed = parser.getUnsignedLong("-S", "--seed", "0",
"Seed for Random number generator" );
}
catch (UException & e)
{
cout << e.what() << endl;
parser.printHelp();
exit(1);
}
if (_seed == 0) { // use clock to get a "random" seed
_seed = (unsigned long)( time( 0 ) );
ostrstream s;
s << _seed;
parser.setParamValue("--seed", s.str()); // so it will be printed out in the status file, and canbe later re-used to re-run EXACTLY the same run
}
rng.reseed(_seed);
return;
}

24
eo/src/eoParserUtils.h Normal file
View file

@ -0,0 +1,24 @@
/*-------------------------------------------------------
File..........: eoParserUtils.h
Author........: Geneura Team, Marc Shoenauer
(this file: Victor Rivas, vrivas@ujaen.es)
Date..........: 17-Dec-1999
Description...: Some useful things that use eoParser.
Modifications.:
------------------- 1 -------------------
Author.......:
Date.........:
Description..:
*/
#ifndef EO_PARSER_UTILS
#define EO_PARSER_UTILS
#include <eoRNG.h>
#include <eoParser.h>
/// Reproducible random seed
//----------------------------------
void InitRandom( Parser & parser);
//----------------------------------
#endif