Corrected a bug in the selector and replacement tournamemt parameter reading:
if you did not give the tournament sizes, the program either crashed or went in some endless loop. I also simplified the reading of those eoParamPram parameters!
This commit is contained in:
parent
beba7bd5c9
commit
03045f2d58
1 changed files with 63 additions and 17 deletions
|
|
@ -80,23 +80,43 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParameterLoader& _parser, eoState& _state, e
|
||||||
eoSelectOne<EOT>* select ;
|
eoSelectOne<EOT>* select ;
|
||||||
if (ppSelect.first == string("DetTour"))
|
if (ppSelect.first == string("DetTour"))
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned detSize;
|
||||||
istrstream is(ppSelect.second[0].c_str()); // size of det tournament
|
|
||||||
is >> size;
|
if (!ppSelect.second.size()) // no parameter added
|
||||||
select = new eoDetTournamentSelect<EOT>(size);
|
{
|
||||||
|
cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
|
||||||
|
detSize = 2;
|
||||||
|
// put back 2 in parameter for consistency (and status file)
|
||||||
|
ppSelect.second.push_back(string("2"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as DetTour(T)
|
||||||
|
detSize = atoi(ppSelect.second[0].c_str());
|
||||||
|
select = new eoDetTournamentSelect<EOT>(detSize);
|
||||||
}
|
}
|
||||||
else if (ppSelect.first == string("StochTour"))
|
else if (ppSelect.first == string("StochTour"))
|
||||||
{
|
{
|
||||||
double p;
|
double p;
|
||||||
istrstream is(ppSelect.second[0].c_str()); // proba of binary tournament
|
if (!ppSelect.second.size()) // no parameter added
|
||||||
is >> p;
|
{
|
||||||
|
cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
|
||||||
|
p = 1;
|
||||||
|
// put back p in parameter for consistency (and status file)
|
||||||
|
ppSelect.second.push_back(string("1"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as DetTour(T)
|
||||||
|
p = atof(ppSelect.second[0].c_str());
|
||||||
|
|
||||||
select = new eoStochTournamentSelect<EOT>(p);
|
select = new eoStochTournamentSelect<EOT>(p);
|
||||||
}
|
}
|
||||||
else if (ppSelect.first == string("Sequential")) // one after the other
|
else if (ppSelect.first == string("Sequential")) // one after the other
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
if (ppSelect.second.size() == 0) // no argument -> default = ordered
|
if (ppSelect.second.size() == 0) // no argument -> default = ordered
|
||||||
b=true;
|
{
|
||||||
|
b=true;
|
||||||
|
// put back in parameter for consistency (and status file)
|
||||||
|
ppSelect.second.push_back(string("ordered"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
b = !(ppSelect.second[0] == string("unordered"));
|
b = !(ppSelect.second[0] == string("unordered"));
|
||||||
select = new eoSequentialSelect<EOT>(b);
|
select = new eoSequentialSelect<EOT>(b);
|
||||||
|
|
@ -136,10 +156,19 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParameterLoader& _parser, eoState& _state, e
|
||||||
}
|
}
|
||||||
else if (ppReplace.first == string("EPTour"))
|
else if (ppReplace.first == string("EPTour"))
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned detSize;
|
||||||
istrstream is(ppReplace.second[0].c_str()); // size of EP tournament
|
|
||||||
is >> size;
|
if (!ppReplace.second.size()) // no parameter added
|
||||||
replace = new eoEPReplacement<EOT>(size);
|
{
|
||||||
|
cerr << "WARNING, no parameter passed to EPTour, using 6" << endl;
|
||||||
|
detSize = 6;
|
||||||
|
// put back in parameter for consistency (and status file)
|
||||||
|
ppReplace.second.push_back(string("6"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as EPTour(T)
|
||||||
|
detSize = atoi(ppSelect.second[0].c_str());
|
||||||
|
|
||||||
|
replace = new eoEPReplacement<EOT>(detSize);
|
||||||
}
|
}
|
||||||
else if (ppReplace.first == string("SSGAWorst"))
|
else if (ppReplace.first == string("SSGAWorst"))
|
||||||
{
|
{
|
||||||
|
|
@ -147,16 +176,33 @@ eoAlgo<EOT> & do_make_algo_scalar(eoParameterLoader& _parser, eoState& _state, e
|
||||||
}
|
}
|
||||||
else if (ppReplace.first == string("SSGADet"))
|
else if (ppReplace.first == string("SSGADet"))
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned detSize;
|
||||||
istrstream is(ppReplace.second[0].c_str()); // size of Det. tournament
|
|
||||||
is >> size;
|
if (!ppReplace.second.size()) // no parameter added
|
||||||
replace = new eoSSGADetTournamentReplacement<EOT>(size);
|
{
|
||||||
|
cerr << "WARNING, no parameter passed to SSGADet, using 2" << endl;
|
||||||
|
detSize = 2;
|
||||||
|
// put back in parameter for consistency (and status file)
|
||||||
|
ppReplace.second.push_back(string("2"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as SSGADet(T)
|
||||||
|
detSize = atoi(ppSelect.second[0].c_str());
|
||||||
|
|
||||||
|
replace = new eoSSGADetTournamentReplacement<EOT>(detSize);
|
||||||
}
|
}
|
||||||
else if (ppReplace.first == string("SSGAStoch"))
|
else if (ppReplace.first == string("SSGAStoch"))
|
||||||
{
|
{
|
||||||
double p;
|
double p;
|
||||||
istrstream is(ppReplace.second[0].c_str()); // proba of binary tournament
|
if (!ppReplace.second.size()) // no parameter added
|
||||||
is >> p;
|
{
|
||||||
|
cerr << "WARNING, no parameter passed to SSGAStoch, using 1" << endl;
|
||||||
|
p = 1;
|
||||||
|
// put back in parameter for consistency (and status file)
|
||||||
|
ppReplace.second.push_back(string("1"));
|
||||||
|
}
|
||||||
|
else // parameter passed by user as SSGADet(T)
|
||||||
|
p = atof(ppSelect.second[0].c_str());
|
||||||
|
|
||||||
replace = new eoSSGAStochTournamentReplacement<EOT>(p);
|
replace = new eoSSGAStochTournamentReplacement<EOT>(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Reference in a new issue