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

@ -35,12 +35,12 @@ IF(NOT DEFINED config OR NOT config)
give the path of the install configuration file. ") give the path of the install configuration file. ")
ENDIF(NOT DEFINED config OR NOT config) ENDIF(NOT DEFINED config OR NOT config)
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${ParadisEO-MOEO_SOURCE_DIR}/CTestCustom.cmake
${ParadisEO-MOEO_BINARY_DIR}/CTestCustom.cmake)
# Need the config file whose full path is given thanks to the "config" variable # Need the config file whose full path is given thanks to the "config" variable
INCLUDE(${config}) INCLUDE(${config})
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MO_SRC_DIR}/CTestCustom.cmake
${MO_BIN_DIR}/CTestCustom.cmake)
########################################################################################################################################## ##########################################################################################################################################

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more