git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1983 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
ff4f2bf4a1
commit
261fb95ed1
1 changed files with 111 additions and 110 deletions
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef _moLocalSearch_h
|
||||
#define _moLocalSearch_h
|
||||
|
|
@ -45,12 +45,11 @@
|
|||
* the main algorithm of the local search
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moLocalSearch: public eoMonOp<typename Neighbor::EOT>
|
||||
{
|
||||
class moLocalSearch: public eoMonOp<typename Neighbor::EOT> {
|
||||
public:
|
||||
typedef moNeighborhood<Neighbor> Neighborhood;
|
||||
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor of a moLocalSearch
|
||||
|
|
@ -58,13 +57,17 @@ public:
|
|||
* @param _cont an external continuator (can be a checkpoint!)
|
||||
* @param _fullEval a full evaluation function
|
||||
*/
|
||||
moLocalSearch(NeighborhoodExplorer& _searchExpl, moContinuator<Neighbor> & _cont, eoEvalFunc<EOT>& _fullEval) : searchExplorer(_searchExpl), cont(&_cont), fullEval(_fullEval) { } ;
|
||||
moLocalSearch(NeighborhoodExplorer& _searchExpl,
|
||||
moContinuator<Neighbor> & _cont, eoEvalFunc<EOT>& _fullEval) :
|
||||
searchExplorer(_searchExpl), cont(&_cont), fullEval(_fullEval) {
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
* Run the local search on a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual bool operator() (EOT & _solution) {
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
|
||||
if (_solution.invalid())
|
||||
fullEval(_solution);
|
||||
|
|
@ -76,7 +79,6 @@ public:
|
|||
cont->init(_solution);
|
||||
|
||||
bool b;
|
||||
|
||||
do {
|
||||
// explore the neighborhood of the solution
|
||||
searchExplorer(_solution);
|
||||
|
|
@ -84,29 +86,28 @@ public:
|
|||
if (searchExplorer.accept(_solution)) {
|
||||
searchExplorer.move(_solution);
|
||||
searchExplorer.moveApplied(true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
searchExplorer.moveApplied(false);
|
||||
|
||||
// update the parameter of the search (for ex. Temperature of the SA)
|
||||
searchExplorer.updateParam(_solution);
|
||||
|
||||
b=(*cont)(_solution);
|
||||
} while (b && searchExplorer.isContinue(_solution));
|
||||
|
||||
b = (*cont)(_solution);
|
||||
}while (b && searchExplorer.isContinue(_solution));
|
||||
searchExplorer.terminate(_solution);
|
||||
|
||||
cont->lastCall(_solution);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
/**
|
||||
* Set an external continuator
|
||||
* @param _cont the external continuator
|
||||
*/
|
||||
void setContinuator(moContinuator<Neighbor> & _cont) {
|
||||
cont = &_cont ;
|
||||
cont = &_cont;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,15 +117,15 @@ public:
|
|||
* @return the external continuator
|
||||
*/
|
||||
moContinuator<Neighbor>* getContinuator() const {
|
||||
return cont ;
|
||||
return cont;
|
||||
}
|
||||
|
||||
protected:
|
||||
// make the exploration of the neighborhood according to a local search heuristic
|
||||
moNeighborhoodExplorer<Neighbor>& searchExplorer ;
|
||||
moNeighborhoodExplorer<Neighbor>& searchExplorer;
|
||||
|
||||
// external continuator
|
||||
moContinuator<Neighbor> * cont ;
|
||||
moContinuator<Neighbor> * cont;
|
||||
|
||||
//full evaluation function
|
||||
eoEvalFunc<EOT>& fullEval;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue