add reinit flag in the constructor and the init
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1997 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
8e6c4805ee
commit
56b69b80e0
1 changed files with 15 additions and 2 deletions
|
|
@ -48,8 +48,9 @@ public :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
* @param _reInitSol when true the best so far is reinitialized
|
||||||
*/
|
*/
|
||||||
moBestSoFarStat(): moStat<EOT, EOT>(EOT(), "best") {
|
moBestSoFarStat(bool _reInitSol = true): moStat<EOT, EOT>(EOT(), "best"), reInitSol(_reInitSol), firstTime(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,7 +58,13 @@ public :
|
||||||
* @param _sol the first solution
|
* @param _sol the first solution
|
||||||
*/
|
*/
|
||||||
virtual void init(EOT & _sol) {
|
virtual void init(EOT & _sol) {
|
||||||
|
if (reInitSol)
|
||||||
value() = _sol;
|
value() = _sol;
|
||||||
|
else if (firstTime)
|
||||||
|
{
|
||||||
|
value() = _sol;
|
||||||
|
firstTime = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,8 +73,10 @@ public :
|
||||||
*/
|
*/
|
||||||
virtual void operator()(EOT & _sol) {
|
virtual void operator()(EOT & _sol) {
|
||||||
if (value().fitness() < _sol.fitness())
|
if (value().fitness() < _sol.fitness())
|
||||||
|
{
|
||||||
value() = _sol;
|
value() = _sol;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the class
|
* @return name of the class
|
||||||
|
|
@ -76,6 +85,10 @@ public :
|
||||||
return "moBestSoFarStat";
|
return "moBestSoFarStat";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool reInitSol;
|
||||||
|
bool firstTime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue