Add the notion of currentNeighbor in the moSAExplorer
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2543 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
076417034c
commit
9cf796d2e0
1 changed files with 7 additions and 9 deletions
|
|
@ -59,6 +59,7 @@ public:
|
||||||
|
|
||||||
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
using moNeighborhoodExplorer<Neighbor>::neighborhood;
|
||||||
using moNeighborhoodExplorer<Neighbor>::eval;
|
using moNeighborhoodExplorer<Neighbor>::eval;
|
||||||
|
using moNeighborhoodExplorer<Neighbor>::currentNeighbor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -112,10 +113,10 @@ public:
|
||||||
//Test if _solution has a Neighbor
|
//Test if _solution has a Neighbor
|
||||||
if (neighborhood.hasNeighbor(_solution)) {
|
if (neighborhood.hasNeighbor(_solution)) {
|
||||||
//init on the first neighbor: supposed to be random solution in the neighborhood
|
//init on the first neighbor: supposed to be random solution in the neighborhood
|
||||||
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);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//if _solution hasn't neighbor,
|
//if _solution hasn't neighbor,
|
||||||
|
|
@ -138,9 +139,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());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,10 +153,10 @@ public:
|
||||||
double alpha=0.0;
|
double alpha=0.0;
|
||||||
double fit1, fit2;
|
double fit1, fit2;
|
||||||
if (neighborhood.hasNeighbor(_solution)) {
|
if (neighborhood.hasNeighbor(_solution)) {
|
||||||
if (solNeighborComparator(_solution, current)) // accept if the current neighbor is better than the solution
|
if (solNeighborComparator(_solution, currentNeighbor)) // accept if the current neighbor is better than the solution
|
||||||
isAccept = true;
|
isAccept = true;
|
||||||
else {
|
else {
|
||||||
fit1=(double)current.fitness();
|
fit1=(double)currentNeighbor.fitness();
|
||||||
fit2=(double)_solution.fitness();
|
fit2=(double)_solution.fitness();
|
||||||
if (fit1 < fit2) // this is a maximization
|
if (fit1 < fit2) // this is a maximization
|
||||||
alpha = exp((fit1 - fit2) / temperature );
|
alpha = exp((fit1 - fit2) / temperature );
|
||||||
|
|
@ -183,9 +184,6 @@ private:
|
||||||
|
|
||||||
double temperature;
|
double temperature;
|
||||||
|
|
||||||
//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