From 56b69b80e0c43ec79601da7c2ddc1d8a034dc797 Mon Sep 17 00:00:00 2001 From: marieeleonore Date: Mon, 8 Nov 2010 16:07:55 +0000 Subject: [PATCH] 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 --- .../src/continuator/moBestSoFarStat.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/trunk/paradiseo-mo/src/continuator/moBestSoFarStat.h b/trunk/paradiseo-mo/src/continuator/moBestSoFarStat.h index 6d1d61878..fa5797139 100644 --- a/trunk/paradiseo-mo/src/continuator/moBestSoFarStat.h +++ b/trunk/paradiseo-mo/src/continuator/moBestSoFarStat.h @@ -48,8 +48,9 @@ public : /** * Default Constructor + * @param _reInitSol when true the best so far is reinitialized */ - moBestSoFarStat(): moStat(EOT(), "best") { + moBestSoFarStat(bool _reInitSol = true): moStat(EOT(), "best"), reInitSol(_reInitSol), firstTime(true) { } /** @@ -57,7 +58,13 @@ public : * @param _sol the first solution */ virtual void init(EOT & _sol) { - value() = _sol; + if (reInitSol) + value() = _sol; + else if (firstTime) + { + value() = _sol; + firstTime = false; + } } /** @@ -66,7 +73,9 @@ public : */ virtual void operator()(EOT & _sol) { if (value().fitness() < _sol.fitness()) + { value() = _sol; + } } /** @@ -76,6 +85,10 @@ public : return "moBestSoFarStat"; } +protected: + bool reInitSol; + bool firstTime; + }; #endif