first improvement ajouter
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1669 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1bd2d3e18b
commit
b361a1784b
10 changed files with 453 additions and 12 deletions
|
|
@ -36,6 +36,8 @@
|
|||
#define _moSimpleHCexplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a simple Hill-climbing
|
||||
|
|
@ -49,7 +51,6 @@ public:
|
|||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
using moNeighborhoodExplorer<Neighborhood>::comparator;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -57,7 +58,7 @@ public:
|
|||
* @param _eval the evaluation function
|
||||
* @param _comparator a neighbor comparator
|
||||
*/
|
||||
moSimpleHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _comparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval, _comparator){
|
||||
moSimpleHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
best=new Neighbor();
|
||||
|
|
@ -111,7 +112,7 @@ public:
|
|||
//eval
|
||||
eval(_solution, (*current));
|
||||
//if we found a better neighbor, update the best
|
||||
if (comparator((*current), (*best))) {
|
||||
if (neighborComparator((*best), (*current))) {
|
||||
(*best) = (*current);
|
||||
}
|
||||
}
|
||||
|
|
@ -149,12 +150,15 @@ public:
|
|||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
isAccept = (_solution.fitness() < (*best).fitness()) ;
|
||||
isAccept = solNeighborComparator(_solution, (*best)) ;
|
||||
}
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* best;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue