default param are declared as 'private' and not created in the ctor

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@327 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-06-19 07:58:09 +00:00
commit 2db2c71cfb

View file

@ -28,21 +28,17 @@ public:
* @param _comparator the comparator (used to compare 2 individuals) * @param _comparator the comparator (used to compare 2 individuals)
* @param _tRate the tournament rate * @param _tRate the tournament rate
*/ */
moeoStochTournamentSelect (moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) : moeoStochTournamentSelect (moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) : comparator (_comparator), tRate (_tRate)
comparator (_comparator), tRate (_tRate)
{ {
// consistency checks // consistency checks
if (tRate < 0.5) if (tRate < 0.5)
{ {
std:: std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
cerr <<
"Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
tRate = 0.55; tRate = 0.55;
} }
if (tRate > 1) if (tRate > 1)
{ {
std:: std::cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
tRate = 1; tRate = 1;
} }
} }
@ -51,22 +47,17 @@ public:
* Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default. * Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
* @param _tRate the tournament rate * @param _tRate the tournament rate
*/ */
moeoStochTournamentSelect (double _tRate = 1.0) moeoStochTournamentSelect (double _tRate = 1.0) : comparator (defaultComparator), tRate (_tRate)
:comparator (*(new moeoFitnessThenDiversityComparator < MOEOT > ())), tRate (_tRate)
{ {
// consistency checks // consistency checks
if (tRate < 0.5) if (tRate < 0.5)
{ {
std:: std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
cerr <<
"Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
tRate = 0.55; tRate = 0.55;
} }
if (tRate > 1) if (tRate > 1)
{ {
std:: std::cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
tRate = 1; tRate = 1;
} }
} }
@ -83,11 +74,12 @@ public:
} }
protected: protected:
/** the diversity assignment strategy */ /** the comparator (used to compare 2 individuals) */
moeoComparator < MOEOT > & comparator; moeoComparator < MOEOT > & comparator;
/** a fitness then diversity comparator can be used as default */
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/** the tournament rate */ /** the tournament rate */
double tRate; double tRate;