Add a new fonctionnaity to moFirstImprHC : it is possible to stop only with an external continuator

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2707 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
verel 2012-03-21 17:58:18 +00:00
commit 35ae23c616
3 changed files with 26 additions and 2 deletions

View file

@ -90,6 +90,14 @@ public:
explorer(_neighborhood, _eval, _compN, _compSN) explorer(_neighborhood, _eval, _compN, _compSN)
{} {}
/**
* to never stop the hill climbing
*
*/
virtual void alwaysContinue() {
explorer.alwaysContinue();
}
/** /**
* Return the class id. * Return the class id.
* @return the class name as a std::string * @return the class name as a std::string

View file

@ -44,7 +44,7 @@ public:
/** /**
* Constructor * Constructor
* @param _max maximum running time * @param _max maximum running time (in second)
* @param _verbose verbose mode true/false -> on/off * @param _verbose verbose mode true/false -> on/off
*/ */
moTimeContinuator(time_t _max, bool _verbose = true): max(_max), verbose(_verbose) { moTimeContinuator(time_t _max, bool _verbose = true): max(_max), verbose(_verbose) {

View file

@ -64,6 +64,7 @@ public:
*/ */
moFirstImprHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) { moFirstImprHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
isAccept = false; isAccept = false;
stop = true;
} }
/** /**
@ -72,6 +73,14 @@ public:
~moFirstImprHCexplorer() { ~moFirstImprHCexplorer() {
} }
/**
* to never stop the hill climbing
*
*/
virtual void alwaysContinue() {
stop = false;
}
/** /**
* initParam: NOTHING TO DO * initParam: NOTHING TO DO
* @param _solution unused solution * @param _solution unused solution
@ -122,12 +131,15 @@ public:
}; };
/** /**
* continue if a move is accepted * continue if a move is accepted, or according to the flag 'stop'
* @param _solution the solution * @param _solution the solution
* @return true if an ameliorated neighbor was found * @return true if an ameliorated neighbor was found
*/ */
virtual bool isContinue(EOT & _solution) { virtual bool isContinue(EOT & _solution) {
if (stop)
return isAccept ; return isAccept ;
else
return true;
}; };
/** /**
@ -149,6 +161,10 @@ private:
// true if the move is accepted // true if the move is accepted
bool isAccept ; bool isAccept ;
// if true the HC stop when to improving solution is found
// if false : never stop, always continue (external continuator)
bool stop ;
}; };