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
|
|
@ -45,8 +45,7 @@
|
||||||
* the main algorithm of the local search
|
* the main algorithm of the local search
|
||||||
*/
|
*/
|
||||||
template<class Neighbor>
|
template<class Neighbor>
|
||||||
class moLocalSearch: public eoMonOp<typename Neighbor::EOT>
|
class moLocalSearch: public eoMonOp<typename Neighbor::EOT> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood;
|
typedef moNeighborhood<Neighbor> Neighborhood;
|
||||||
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
|
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
|
||||||
|
|
@ -58,7 +57,11 @@ public:
|
||||||
* @param _cont an external continuator (can be a checkpoint!)
|
* @param _cont an external continuator (can be a checkpoint!)
|
||||||
* @param _fullEval a full evaluation function
|
* @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
|
* Run the local search on a solution
|
||||||
|
|
@ -76,7 +79,6 @@ public:
|
||||||
cont->init(_solution);
|
cont->init(_solution);
|
||||||
|
|
||||||
bool b;
|
bool b;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// explore the neighborhood of the solution
|
// explore the neighborhood of the solution
|
||||||
searchExplorer(_solution);
|
searchExplorer(_solution);
|
||||||
|
|
@ -84,8 +86,7 @@ public:
|
||||||
if (searchExplorer.accept(_solution)) {
|
if (searchExplorer.accept(_solution)) {
|
||||||
searchExplorer.move(_solution);
|
searchExplorer.move(_solution);
|
||||||
searchExplorer.moveApplied(true);
|
searchExplorer.moveApplied(true);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
searchExplorer.moveApplied(false);
|
searchExplorer.moveApplied(false);
|
||||||
|
|
||||||
// update the parameter of the search (for ex. Temperature of the SA)
|
// update the parameter of the search (for ex. Temperature of the SA)
|
||||||
|
|
@ -93,13 +94,13 @@ public:
|
||||||
|
|
||||||
b = (*cont)(_solution);
|
b = (*cont)(_solution);
|
||||||
}while (b && searchExplorer.isContinue(_solution));
|
}while (b && searchExplorer.isContinue(_solution));
|
||||||
|
|
||||||
searchExplorer.terminate(_solution);
|
searchExplorer.terminate(_solution);
|
||||||
|
|
||||||
cont->lastCall(_solution);
|
cont->lastCall(_solution);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an external continuator
|
* Set an external continuator
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue