00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _make_PBILdistrib_h
00027 #define _make_PBILdistrib_h
00028
00029 #include <ctime>
00030 #include <ga/eoPBILOrg.h>
00031 #include <utils/eoRNG.h>
00032 #include <utils/eoParser.h>
00033 #include <utils/eoState.h>
00034
00035
00037
00048 template <class EOT>
00049 eoPBILDistrib<EOT> & do_make_PBILdistrib(eoParser & _parser, eoState& _state, EOT)
00050 {
00051
00052 eoValueParam<uint32_t>& seedParam = _parser.createParam(uint32_t(0), "seed", "Random number seed", 'S');
00053 if (seedParam.value() == 0)
00054 seedParam.value() = time(0);
00055
00056
00057 unsigned theSize;
00058
00059 eoParam* ptParam = _parser.getParamWithLongName(std::string("chromSize"));
00060
00061 if (!ptParam)
00062 {
00063 theSize = _parser.createParam(unsigned(10), "chromSize", "The length of the bitstrings", 'n',"Problem").value();
00064 }
00065 else
00066 {
00067 eoValueParam<unsigned>* ptChromSize = dynamic_cast<eoValueParam<unsigned>*>(ptParam);
00068 theSize = ptChromSize->value();
00069 }
00070
00071 eoPBILDistrib<EOT> * ptDistrib = new eoPBILDistrib<EOT>(theSize);
00072 _state.storeFunctor(ptDistrib);
00073
00074
00075 eoValueParam<std::string>& loadNameParam = _parser.createParam(std::string(""), "Load","A save file to restart from",'L', "Persistence" );
00076 if (loadNameParam.value() != "")
00077 {
00078
00079 eoState inState;
00080
00081
00082
00083
00084 inState.registerObject(*ptDistrib);
00085 inState.registerObject(rng);
00086 inState.load(loadNameParam.value());
00087 }
00088 else
00089 {
00090 rng.reseed(seedParam.value());
00091 }
00092
00093
00094 _state.registerObject(_parser);
00095 _state.registerObject(*ptDistrib);
00096 _state.registerObject(rng);
00097
00098 return *ptDistrib;
00099 }
00100
00101 #endif