//----------------------------------------------------------------------------- // to avoid long name warnings #ifdef _MSC_VER #pragma warning(disable:4786) #endif #include // runtime_error //----------------------------------------------------------------------------- // tt.cpp: // //----------------------------------------------------------------------------- // general #include #include //----------------------------------------------------------------------------- struct Dummy : public EO { typedef double Type; void printOn(ostream & _os) const { _os << " - "; EO::printOn(_os); } }; struct eoDummyPop : public eoPop { public : eoDummyPop(int s=0) { resize(s); } }; //----------------------------------------------------------------------------- int the_main(int argc, char **argv) { eoParser parser(argc, argv); eoValueParam parentSizeParam = parser.createParam(10, "parentSize", "Parent size",'P'); unsigned int pSize = parentSizeParam.value(); eoValueParam offsrpringRateParam = parser.createParam(1.0, "offsrpringRate", "Offsrpring rate",'O'); double oRate = offsrpringRateParam.value(); eoValueParam interpretAsRateParam = parser.createParam(true, "interpretAsRate", "interpret rate as Rate (False = as Number)",'b'); bool interpretAsRate = interpretAsRateParam.value(); eoValueParam tournamentSizeParam = parser.createParam(2, "tournamentSize", "Deterministic tournament size",'T'); unsigned int tSize = tournamentSizeParam.value(); eoValueParam tournamentRateParam = parser.createParam(0.75, "tournamentRate", "Stochastic tournament rate",'R'); double tRate = tournamentRateParam.value(); if (parser.userNeedsHelp()) { parser.printHelp(cout); exit(1); } unsigned i; cout << "Testing the Selections\nParents size = " << pSize << ", offspring rate = " << oRate << "interpreted as " << (interpretAsRate ? "Rate" : "Number") << endl; rng.reseed(42); eoDummyPop parents(pSize); eoDummyPop offspring(0); // initialize so we can recognize them later! for (i=0; i detSelect(oRate, interpretAsRate); // here we go // Deterministic cout << "eoDetSelect\n"; cout << "===========\n"; detSelect(parents, offspring); cout << "Selected offsprings (origonally all even\n" << offspring << endl; return 1; } int main(int argc, char **argv) { try { the_main(argc, argv); } catch(exception& e) { cout << "Exception: " << e.what() << endl; } return 1; }