Add the notion of currentNeighbor in the moSimpleHCexplorer
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2539 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
05c14f31a6
commit
e06a16213d
3 changed files with 11 additions and 11 deletions
|
|
@ -52,6 +52,7 @@ public:
|
||||||
|
|
||||||
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
||||||
using moNeighborhoodExplorer<Neighbor>::eval;
|
using moNeighborhoodExplorer<Neighbor>::eval;
|
||||||
|
using moNeighborhoodExplorer<Neighbor>::currentNeighbor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -62,14 +63,12 @@ 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;
|
||||||
current=new Neighbor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
~moFirstImprHCexplorer() {
|
~moFirstImprHCexplorer() {
|
||||||
delete current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ protected:
|
||||||
bool isMoved;
|
bool isMoved;
|
||||||
|
|
||||||
// the current neighbor of the exploration : common features of algorithm
|
// the current neighbor of the exploration : common features of algorithm
|
||||||
Neighbor currentNeighbor
|
Neighbor currentNeighbor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public:
|
||||||
|
|
||||||
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
||||||
using moNeighborhoodExplorer<Neighbor>::eval;
|
using moNeighborhoodExplorer<Neighbor>::eval;
|
||||||
|
using moNeighborhoodExplorer<Neighbor>::currentNeighbor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -96,23 +97,23 @@ public:
|
||||||
//Test if _solution has a Neighbor
|
//Test if _solution has a Neighbor
|
||||||
if (neighborhood.hasNeighbor(_solution)) {
|
if (neighborhood.hasNeighbor(_solution)) {
|
||||||
//init the first neighbor
|
//init the first neighbor
|
||||||
neighborhood.init(_solution, current);
|
neighborhood.init(_solution, currentNeighbor);
|
||||||
|
|
||||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||||
eval(_solution, current);
|
eval(_solution, currentNeighbor);
|
||||||
|
|
||||||
//initialize the best neighbor
|
//initialize the best neighbor
|
||||||
best = current;
|
best = currentNeighbor;
|
||||||
|
|
||||||
//test all others neighbors
|
//test all others neighbors
|
||||||
while (neighborhood.cont(_solution)) {
|
while (neighborhood.cont(_solution)) {
|
||||||
//next neighbor
|
//next neighbor
|
||||||
neighborhood.next(_solution, current);
|
neighborhood.next(_solution, currentNeighbor);
|
||||||
//eval
|
//eval
|
||||||
eval(_solution, current);
|
eval(_solution, currentNeighbor);
|
||||||
//if we found a better neighbor, update the best
|
//if we found a better neighbor, update the best
|
||||||
if (neighborComparator(best, current)) {
|
if (neighborComparator(best, currentNeighbor)) {
|
||||||
best = current;
|
best = currentNeighbor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +173,7 @@ private:
|
||||||
|
|
||||||
// the best and the current neighbor
|
// the best and the current neighbor
|
||||||
Neighbor best;
|
Neighbor best;
|
||||||
Neighbor current;
|
// Neighbor current;
|
||||||
|
|
||||||
// true if the move is accepted
|
// true if the move is accepted
|
||||||
bool isAccept ;
|
bool isAccept ;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue