Add the notion of currentNeighbor in the moRandonNeutralWalkExplorer
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2542 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
e6baefd199
commit
076417034c
2 changed files with 10 additions and 14 deletions
|
|
@ -151,7 +151,7 @@ public:
|
||||||
virtual bool accept(EOT & _solution) {
|
virtual bool accept(EOT & _solution) {
|
||||||
double alpha=0.0;
|
double alpha=0.0;
|
||||||
if (neighborhood.hasNeighbor(_solution)) {
|
if (neighborhood.hasNeighbor(_solution)) {
|
||||||
if (solNeighborComparator(_solution, currentNeighbor)
|
if (solNeighborComparator(_solution, currentNeighbor))
|
||||||
isAccept = true;
|
isAccept = true;
|
||||||
else {
|
else {
|
||||||
if (_solution.fitness() != 0) {
|
if (_solution.fitness() != 0) {
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public:
|
||||||
|
|
||||||
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
||||||
using moNeighborhoodExplorer<Neighbor>::eval;
|
using moNeighborhoodExplorer<Neighbor>::eval;
|
||||||
|
using moNeighborhoodExplorer<Neighbor>::currentNeighbor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -70,7 +71,6 @@ public:
|
||||||
solNeighborComparator(_solNeighborComparator),
|
solNeighborComparator(_solNeighborComparator),
|
||||||
nbStep(_nbStep) {
|
nbStep(_nbStep) {
|
||||||
isAccept = false;
|
isAccept = false;
|
||||||
current=new Neighbor();
|
|
||||||
if (!neighborhood.isRandom()) {
|
if (!neighborhood.isRandom()) {
|
||||||
std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,6 @@ public:
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
~moRandomNeutralWalkExplorer() {
|
~moRandomNeutralWalkExplorer() {
|
||||||
delete current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,17 +114,17 @@ 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);
|
||||||
|
|
||||||
//test all others neighbors
|
//test all others neighbors
|
||||||
while (! solNeighborComparator.equals(_solution, *current) && neighborhood.cont(_solution)) {
|
while (! solNeighborComparator.equals(_solution, currentNeighbor) && neighborhood.cont(_solution)) {
|
||||||
//next neighbor
|
//next neighbor
|
||||||
neighborhood.next(_solution, (*current));
|
neighborhood.next(_solution, currentNeighbor);
|
||||||
//eval
|
//eval
|
||||||
eval(_solution, (*current));
|
eval(_solution, currentNeighbor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -149,9 +148,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void move(EOT & _solution) {
|
virtual void move(EOT & _solution) {
|
||||||
//move the solution
|
//move the solution
|
||||||
(*current).move(_solution);
|
currentNeighbor.move(_solution);
|
||||||
//update its fitness
|
//update its fitness
|
||||||
_solution.fitness((*current).fitness());
|
_solution.fitness(currentNeighbor.fitness());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,7 +160,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool accept(EOT & _solution) {
|
virtual bool accept(EOT & _solution) {
|
||||||
if (neighborhood.hasNeighbor(_solution))
|
if (neighborhood.hasNeighbor(_solution))
|
||||||
isAccept = solNeighborComparator.equals(_solution, (*current)) ;
|
isAccept = solNeighborComparator.equals(_solution, currentNeighbor) ;
|
||||||
return isAccept;
|
return isAccept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -175,9 +174,6 @@ private:
|
||||||
// maximum number of steps to do
|
// maximum number of steps to do
|
||||||
unsigned int nbStep;
|
unsigned int nbStep;
|
||||||
|
|
||||||
//Pointer on the best and the current neighbor
|
|
||||||
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