Replace Templates NHE and Neighborhood

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1732 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-04-07 15:52:47 +00:00
commit 5f7d120a6e
48 changed files with 236 additions and 227 deletions

View file

@ -37,23 +37,24 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <continuator/moContinuator.h>
#include <neighborhood/moNeighborhood.h>
#include <eoEvalFunc.h>
/**
* the main algorithm of the local search
*/
template<class NHE>
class moLocalSearch: public eoMonOp<typename NHE::EOT>
template<class Neighbor>
class moLocalSearch: public eoMonOp<typename Neighbor::EOT>
{
public:
typedef NHE NeighborhoodExplorer ;
typedef typename NeighborhoodExplorer::EOT EOT ;
typedef typename NeighborhoodExplorer::Neighborhood Neighborhood ;
typedef moNeighborhood<Neighbor> Neighborhood;
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
typedef typename Neighbor::EOT EOT ;
/**
* Constructor of a moLocalSearch needs a NeighborhooExplorer and a Continuator
*/
moLocalSearch(moNeighborhoodExplorer<Neighborhood>& _searchExpl, moContinuator<Neighborhood> & _continuator, eoEvalFunc<EOT>& _fullEval) : searchExplorer(_searchExpl), continuator(_continuator), fullEval(_fullEval) { } ;
moLocalSearch(NeighborhoodExplorer& _searchExpl, moContinuator<Neighbor> & _continuator, eoEvalFunc<EOT>& _fullEval) : searchExplorer(_searchExpl), continuator(_continuator), fullEval(_fullEval) { } ;
/**
* Run the local search on a solution
@ -98,10 +99,10 @@ public:
private:
// make the exploration of the neighborhood according to a local search heuristic
moNeighborhoodExplorer<Neighborhood>& searchExplorer ;
moNeighborhoodExplorer<Neighbor>& searchExplorer ;
// external continuator
moContinuator<Neighborhood>& continuator ;
moContinuator<Neighbor>& continuator ;
//full evaluation function
eoEvalFunc<EOT>& fullEval;

View file

@ -39,23 +39,23 @@
#include <utils/eoMonitor.h>
#include <continuator/moStatBase.h>
#include <utils/eoUpdater.h>
#include <neighborhood/moNeighborhood.h>
/**
* Continuator allowing to add others (continuators, stats, monitors or updaters)
*/
template <class NH>
class moCheckpoint : public moContinuator<NH> {
template <class Neighbor>
class moCheckpoint : public moContinuator<Neighbor> {
public :
typedef NH Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
/**
* Default constructor (moCheckpoint must have at least one continuator)
* @param _cont a continuator
* @param _interval frequency to compute statistical operators
*/
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0) {
moCheckpoint(moContinuator<Neighbor>& _cont, unsigned int _interval=1):interval(_interval), counter(0) {
continuators.push_back(&_cont);
}
@ -63,7 +63,7 @@ public :
* add a continuator to the checkpoint
* @param _cont a continuator
*/
void add(moContinuator<Neighborhood>& _cont) {
void add(moContinuator<Neighbor>& _cont) {
continuators.push_back(&_cont);
}
@ -153,7 +153,7 @@ public :
private :
/** continuators vector */
std::vector<moContinuator<Neighborhood>*> continuators;
std::vector<moContinuator<Neighbor>*> continuators;
/** statistic operators vector */
std::vector<moStatBase<EOT>*> stats;
/** monitors vector */

View file

@ -36,16 +36,17 @@
#define _moContinuator_h
#include <eoFunctor.h>
#include <neighborhood/moNeighborhood.h>
/**
* To make specific continuator from a solution
*/
template< class NH >
class moContinuator : public eoUF<typename NH::EOT &, bool>
template< class Neighbor >
class moContinuator : public eoUF<typename Neighbor::EOT &, bool>
{
public:
typedef NH Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
/**
* Init Continuator parameters

View file

@ -31,15 +31,15 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#define _moIterContinuator_h
#include <continuator/moContinuator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Continue until a maximum fixed number of iterations is reached
*/
template< class NH >
class moIterContinuator : public moContinuator<NH>
template< class Neighbor >
class moIterContinuator : public moContinuator<Neighbor>
{
public:
typedef typename NH::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
/**
* @param _maxIter number maximum of iterations

View file

@ -37,15 +37,15 @@
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
#include <neighborhood/moNeighborhood.h>
/**
* From moNeighborhoodStat, to compute the max fitness in the neighborhood
*/
template< class Neighborhood >
class moMaxNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
template< class Neighbor >
class moMaxNeighborStat : public moStat<typename Neighbor::EOT, typename Neighbor::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
@ -54,7 +54,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moMaxNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/**
@ -74,7 +74,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -37,15 +37,15 @@
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
#include <neighborhood/moNeighborhood.h>
/**
* From moNeighborhoodStat, to compute the min fitness in the neighborhood
*/
template< class Neighborhood >
class moMinNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
template< class Neighbor >
class moMinNeighborStat : public moStat<typename Neighbor::EOT, typename Neighbor::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
@ -54,7 +54,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moMinNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/**
@ -74,7 +74,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -37,18 +37,18 @@
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
#include <neighborhood/moNeighborhood.h>
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with (strictly) lower fitness than the current solution
*
*/
template< class Neighborhood >
class moNbInfNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
template< class Neighbor >
class moNbInfNeighborStat : public moStat<typename Neighbor::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
@ -57,7 +57,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moNbInfNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat) {}
/**
@ -77,7 +77,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -37,18 +37,18 @@
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
#include <neighborhood/moNeighborhood.h>
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with higher fitness than the current solution
*
*/
template< class Neighborhood >
class moNbSupNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
template< class Neighbor >
class moNbSupNeighborStat : public moStat<typename Neighbor::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
@ -57,7 +57,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moNbSupNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat) {}
/**
@ -77,7 +77,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -40,17 +40,18 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* All possible statitic on the neighborhood fitness
* to combine with other specific statistic to print them
*/
template< class Neighborhood >
class moNeighborhoodStat : public moStat<typename Neighborhood::EOT, bool>
template< class Neighbor >
class moNeighborhoodStat : public moStat<typename Neighbor::EOT, bool>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, bool >::value;

View file

@ -43,11 +43,11 @@
* which is the number of solutions in the neighborhood
* with equals fitness
*/
template< class Neighborhood >
class moNeutralDegreeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
template< class Neighbor >
class moNeutralDegreeNeighborStat : public moStat<typename Neighbor::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
@ -56,7 +56,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat) {}
/**
@ -76,7 +76,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -41,11 +41,11 @@
/**
* From moNeighborhoodStat, to compute the average and the standard deviation of fitness in the neighborhood
*/
template< class Neighborhood >
class moSecondMomentNeighborStat : public moStat<typename Neighborhood::EOT, std::pair<double, double> >
template< class Neighbor >
class moSecondMomentNeighborStat : public moStat<typename Neighbor::EOT, std::pair<double, double> >
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, std::pair<double, double> >::value;
@ -54,7 +54,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moSecondMomentNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat) {}
/**
@ -75,7 +75,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -42,11 +42,11 @@
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
*
*/
template< class Neighborhood >
class moSizeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
template< class Neighbor >
class moSizeNeighborStat : public moStat<typename Neighbor::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
@ -55,7 +55,7 @@ public :
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moSizeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat) {}
/**
@ -75,7 +75,7 @@ public :
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
moNeighborhoodStat<Neighbor> & nhStat;
};
#endif

View file

@ -40,11 +40,11 @@
/**
* Continuator always return True
*/
template< class NH >
class moTrueContinuator : public moContinuator<NH>
template< class Neighbor >
class moTrueContinuator : public moContinuator<Neighbor>
{
public:
typedef typename NH::EOT EOT ;
typedef typename Neighbor::EOT EOT ;
// empty constructor
moTrueContinuator() {} ;

View file

@ -38,19 +38,20 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a first imporvement heuristic
*/
template< class Neighborhood >
class moFirstImprExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor>
class moFirstImprExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -59,7 +60,7 @@ public:
* @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator a solution vs neighbor comparator
*/
moFirstImprExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
moFirstImprExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
isAccept = false;
current=new Neighbor();
}

View file

@ -38,23 +38,24 @@
#include <explorer/moSimpleHCneutralExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a neutral Hill-climbing
*/
template< class Neighborhood >
class moHCneutralExplorer : public moSimpleHCneutralExplorer<Neighborhood>
template< class Neighbor >
class moHCneutralExplorer : public moSimpleHCneutralExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moSimpleHCneutralExplorer<Neighborhood>::solNeighborComparator;
using moSimpleHCneutralExplorer<Neighborhood>::isAccept;
using moSimpleHCneutralExplorer<Neighborhood>::bestVector;
using moSimpleHCneutralExplorer<Neighborhood>::initParam;
using moSimpleHCneutralExplorer<Neighborhood>::updateParam;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moSimpleHCneutralExplorer<Neighbor>::solNeighborComparator;
using moSimpleHCneutralExplorer<Neighbor>::isAccept;
using moSimpleHCneutralExplorer<Neighbor>::bestVector;
using moSimpleHCneutralExplorer<Neighbor>::initParam;
using moSimpleHCneutralExplorer<Neighbor>::updateParam;
/**
* Constructor
@ -69,7 +70,7 @@ public:
moNeighborComparator<Neighbor>& _neighborComparator,
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
unsigned _nbStep) :
moSimpleHCneutralExplorer<Neighborhood>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
moSimpleHCneutralExplorer<Neighbor>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
nbStep(_nbStep) {
//Some cycle is possible with equals fitness solutions if the neighborhood is not random
if (!neighborhood.isRandom()) {
@ -87,7 +88,7 @@ public:
* initial number of step
*/
virtual void initParam(EOT & solution) {
moSimpleHCneutralExplorer<Neighborhood>::initParam(solution);
moSimpleHCneutralExplorer<Neighbor>::initParam(solution);
step = 0;
};
@ -96,7 +97,7 @@ public:
* one more step
*/
virtual void updateParam(EOT & solution) {
moSimpleHCneutralExplorer<Neighborhood>::updateParam(solution);
moSimpleHCneutralExplorer<Neighbor>::updateParam(solution);
step++;
};

View file

@ -47,13 +47,12 @@
/**
* Explorer for an Iterated Local Search
*/
template< class NHE >
class moILSexplorer : public moNeighborhoodExplorer<moDummyNeighborhood<moDummyNeighbor<typename NHE::Neighborhood::EOT, typename NHE::Neighborhood::EOT::Fitness> > >
template< class Neighbor >
class moILSexplorer : public moNeighborhoodExplorer< moDummyNeighbor<typename Neighbor::EOT, typename Neighbor::EOT::Fitness> >
{
public:
typedef typename NHE::Neighborhood Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef moNeighborhood<Neighbor> Neighborhood ;
typedef typename Neighbor::EOT EOT ;
typedef moDummyNeighbor<EOT,typename EOT::Fitness> dummyNeighbor;
typedef moDummyNeighborhood<dummyNeighbor> dummyNeighborhood;
@ -63,7 +62,7 @@ public:
* @param _perturb a perturbation operator
* @param _acceptCrit a acceptance criteria
*/
moILSexplorer(moLocalSearch<NHE>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : moNeighborhoodExplorer<dummyNeighborhood>(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){
moILSexplorer(moLocalSearch<Neighbor>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : moNeighborhoodExplorer<dummyNeighbor>(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){
firstIteration=true;
}
@ -161,7 +160,7 @@ private:
//Usefull to use the momory of tabuSearch
Neighbor emptyNeighbor;
EOT current;
moLocalSearch<NHE>& ls;
moLocalSearch<Neighbor>& ls;
moPerturbation<Neighbor> & perturb;
moAcceptanceCriterion<Neighbor>& acceptCrit;

View file

@ -40,6 +40,7 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
#include <utils/eoRNG.h>
@ -48,15 +49,15 @@
* Only the symetric case is considered when Q(x,y) = Q(y,x)
* Fitness must be > 0
*/
template< class Neighborhood >
class moMetropolisHastingExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moMetropolisHastingExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -66,7 +67,7 @@ public:
* @param _solNeighborComparator a solution vs neighbor comparator
* @param _nbStep maximum number of step to do
*/
moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) {
moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) {
isAccept = false;
current=new Neighbor();
if (!neighborhood.isRandom()) {

View file

@ -47,14 +47,13 @@
/**
* Explore the neighborhood
*/
template< class NH >
class moNeighborhoodExplorer : public eoUF<typename NH::EOT&, void>
template< class Neighbor >
class moNeighborhoodExplorer : public eoUF<typename Neighbor::EOT&, void>
{
public:
typedef NH Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood;
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::Neighbor Neighbor ;
moNeighborhoodExplorer():neighborhood(dummyNeighborhood), eval(dummyEval), isMoved(false) {}

View file

@ -37,6 +37,7 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a random neutral walk
@ -44,15 +45,15 @@
* To sample the neutral networks by random walk, there is no memory
* neighborhood must be explored in random order
*/
template< class Neighborhood >
class moRandomNeutralWalkExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moRandomNeutralWalkExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT;
typedef moNeighborhood<Neighbor> Neighborhood;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -64,7 +65,7 @@ public:
moRandomNeutralWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval,
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
unsigned _nbStep):
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval),
moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval),
solNeighborComparator(_solNeighborComparator),
nbStep(_nbStep) {
isAccept = false;

View file

@ -38,19 +38,20 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a random walk explorer
*/
template< class Neighborhood >
class moRandomWalkExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moRandomWalkExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -58,7 +59,7 @@ public:
* @param _eval the evaluation function
* @param _nbStep maximum number of step to do
*/
moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, unsigned _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), nbStep(_nbStep) {
moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, unsigned _nbStep) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), nbStep(_nbStep) {
isAccept = false;
current=new Neighbor();
// number of step done

View file

@ -40,6 +40,7 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moSolNeighborComparator.h>
#include <coolingSchedule/moCoolingSchedule.h>
#include <neighborhood/moNeighborhood.h>
#include <utils/eoRNG.h>
@ -49,15 +50,15 @@
* Fitness must be > 0
*
*/
template< class Neighborhood >
class moSAexplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moSAexplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -67,7 +68,7 @@ public:
* @param _solNeighborComparator a solution vs neighbor comparator
* @param _nbStep maximum number of step to do
*/
moSAexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moSolNeighborComparator<Neighbor>& _solNeighborComparator, moCoolingSchedule<EOT>& _coolingSchedule) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) {
moSAexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moSolNeighborComparator<Neighbor>& _solNeighborComparator, moCoolingSchedule<EOT>& _coolingSchedule) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) {
isAccept = false;
if (!neighborhood.isRandom()) {

View file

@ -38,19 +38,20 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a simple Hill-climbing
*/
template< class Neighborhood >
class moSimpleHCexplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moSimpleHCexplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -59,7 +60,7 @@ public:
* @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator solution vs neighbor comparator
*/
moSimpleHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
moSimpleHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
isAccept = false;
current=new Neighbor();
best=new Neighbor();

View file

@ -38,21 +38,22 @@
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
#include <vector>
#include <utils/eoRNG.h>
/**
* Explorer for a simple neutral Hill-climbing
*/
template< class Neighborhood >
class moSimpleHCneutralExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moSimpleHCneutralExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
@ -65,7 +66,7 @@ public:
moEval<Neighbor>& _eval,
moNeighborComparator<Neighbor>& _neighborComparator,
moSolNeighborComparator<Neighbor>& _solNeighborComparator) :
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval),
moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval),
neighborComparator(_neighborComparator),
solNeighborComparator(_solNeighborComparator) {
isAccept = false;

View file

@ -42,17 +42,17 @@
#include <memory/moTabuList.h>
#include <memory/moIntensification.h>
#include <memory/moDiversification.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a Tabu Search
*/
template< class Neighborhood >
class moTSExplorer : public moNeighborhoodExplorer<Neighborhood>
template< class Neighbor >
class moTSExplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
/**
* Constructor
@ -74,7 +74,7 @@ public:
moDiversification<Neighbor> & _diversification,
moAspiration<Neighbor> & _aspiration
) :
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator),
moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator),
tabuList(_tabuList), intensification(_intensification), diversification(_diversification), aspiration(_aspiration)
{
isAccept = false;
@ -226,8 +226,8 @@ public:
protected:
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
using moNeighborhoodExplorer<Neighborhood>::eval;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
// comparator between solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;