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:
parent
38500f2bc9
commit
35ae23c616
3 changed files with 26 additions and 2 deletions
|
|
@ -90,6 +90,14 @@ public:
|
|||
explorer(_neighborhood, _eval, _compN, _compSN)
|
||||
{}
|
||||
|
||||
/**
|
||||
* to never stop the hill climbing
|
||||
*
|
||||
*/
|
||||
virtual void alwaysContinue() {
|
||||
explorer.alwaysContinue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _max maximum running time
|
||||
* @param _max maximum running time (in second)
|
||||
* @param _verbose verbose mode true/false -> on/off
|
||||
*/
|
||||
moTimeContinuator(time_t _max, bool _verbose = true): max(_max), verbose(_verbose) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
isAccept = false;
|
||||
stop = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +73,14 @@ public:
|
|||
~moFirstImprHCexplorer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* to never stop the hill climbing
|
||||
*
|
||||
*/
|
||||
virtual void alwaysContinue() {
|
||||
stop = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* initParam: NOTHING TO DO
|
||||
* @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
|
||||
* @return true if an ameliorated neighbor was found
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
if (stop)
|
||||
return isAccept ;
|
||||
else
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -149,6 +161,10 @@ private:
|
|||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
|
||||
// if true the HC stop when to improving solution is found
|
||||
// if false : never stop, always continue (external continuator)
|
||||
bool stop ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue