Passage du code dans un pretty printer
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1813 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
cc31901008
commit
3d8057ac4d
88 changed files with 2726 additions and 2720 deletions
|
|
@ -37,7 +37,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
* Abstract class for Acceptance criteria
|
* Abstract class for Acceptance criteria
|
||||||
*/
|
*/
|
||||||
template< class Neighbor >
|
template< class Neighbor >
|
||||||
class moAcceptanceCriterion : public eoBF<typename Neighbor::EOT&, typename Neighbor::EOT&, bool>, virtual public moMemory<Neighbor>{
|
class moAcceptanceCriterion : public eoBF<typename Neighbor::EOT&, typename Neighbor::EOT&, bool>, virtual public moMemory<Neighbor> {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,20 +37,20 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
* Acceptance Criterion for extreme diversification : always accept new solution
|
* Acceptance Criterion for extreme diversification : always accept new solution
|
||||||
*/
|
*/
|
||||||
template< class Neighbor >
|
template< class Neighbor >
|
||||||
class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{
|
class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always accept the new solution
|
* Always accept the new solution
|
||||||
* @param _sol1 the previous solution
|
* @param _sol1 the previous solution
|
||||||
* @param _sol2 the new solution after local search
|
* @param _sol2 the new solution after local search
|
||||||
* @return always true
|
* @return always true
|
||||||
*/
|
*/
|
||||||
bool operator()(EOT& _sol1, EOT& _sol2){
|
bool operator()(EOT& _sol1, EOT& _sol2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,25 +38,25 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
* Acceptance Criterion for extreme intensification : accept if the new solution is better than previous one
|
* Acceptance Criterion for extreme intensification : accept if the new solution is better than previous one
|
||||||
*/
|
*/
|
||||||
template< class Neighbor >
|
template< class Neighbor >
|
||||||
class moBetterAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{
|
class moBetterAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
moBetterAcceptCrit(moSolComparator<EOT>& _comparator):comparator(_comparator){}
|
moBetterAcceptCrit(moSolComparator<EOT>& _comparator):comparator(_comparator) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept if the new solution is better than previous one
|
* Accept if the new solution is better than previous one
|
||||||
* @param _sol1 the previous solution
|
* @param _sol1 the previous solution
|
||||||
* @param _sol2 the new solution after local search
|
* @param _sol2 the new solution after local search
|
||||||
* @return true if the new solution is better than previous one
|
* @return true if the new solution is better than previous one
|
||||||
*/
|
*/
|
||||||
bool operator()(EOT& _sol1, EOT& _sol2){
|
bool operator()(EOT& _sol1, EOT& _sol2) {
|
||||||
return comparator(_sol1, _sol2);
|
return comparator(_sol1, _sol2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
moSolComparator<EOT>& comparator;
|
moSolComparator<EOT>& comparator;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,29 +43,29 @@ template<class Neighbor>
|
||||||
class moDummyLS: public moLocalSearch<Neighbor>
|
class moDummyLS: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor
|
* Simple constructor
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
*/
|
*/
|
||||||
moDummyLS(eoEvalFunc<EOT>& _fullEval):
|
moDummyLS(eoEvalFunc<EOT>& _fullEval):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval)
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the class
|
* @return name of the class
|
||||||
*/
|
*/
|
||||||
virtual std::string className(void) const {
|
virtual std::string className(void) const {
|
||||||
return "moDummyLS";
|
return "moDummyLS";
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// the explorer of the simple HC
|
// the explorer of the simple HC
|
||||||
moDummyExplorer<Neighbor> explorer;
|
moDummyExplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -50,55 +50,55 @@ template<class Neighbor>
|
||||||
class moFirstImprHC: public moLocalSearch<Neighbor>
|
class moFirstImprHC: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic constructor for a hill-climber
|
* Basic constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
*/
|
*/
|
||||||
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a hill-climber
|
* General constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _compN a neighbor vs neighbor comparator
|
* @param _compN a neighbor vs neighbor comparator
|
||||||
* @param _compSN a solution vs neighbor comparator
|
* @param _compSN a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
moFirstImprHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _compN, _compSN)
|
explorer(_neighborhood, _eval, _compN, _compSN)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// compare the fitness values of neighbors: true is strictly greater
|
// compare the fitness values of neighbors: true is strictly greater
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
// the explorer of the first improvement HC
|
// the explorer of the first improvement HC
|
||||||
moFirstImprHCexplorer<Neighbor> explorer;
|
moFirstImprHCexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class moILS: public moLocalSearch<moDummyNeighbor<typename Neighbor::EOT> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -59,12 +59,12 @@ public:
|
||||||
* @param _op the operator used to perturb solution
|
* @param _op the operator used to perturb solution
|
||||||
* @param _nbIteration the time limit for search
|
* @param _nbIteration the time limit for search
|
||||||
*/
|
*/
|
||||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, unsigned int _nbIteration):
|
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, unsigned int _nbIteration):
|
||||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, iterCont, _fullEval),
|
moLocalSearch<moDummyNeighbor<EOT> >(explorer, iterCont, _fullEval),
|
||||||
iterCont(_nbIteration),
|
iterCont(_nbIteration),
|
||||||
defaultPerturb(_op, _fullEval),
|
defaultPerturb(_op, _fullEval),
|
||||||
explorer(_ls, defaultPerturb, defaultAccept)
|
explorer(_ls, defaultPerturb, defaultAccept)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for Iterated Local Search
|
* Simple constructor for Iterated Local Search
|
||||||
|
|
@ -73,12 +73,12 @@ public:
|
||||||
* @param _op the operator used to perturb solution
|
* @param _op the operator used to perturb solution
|
||||||
* @param _cont a continuator
|
* @param _cont a continuator
|
||||||
*/
|
*/
|
||||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, moContinuator<moDummyNeighbor<EOT> >& _cont):
|
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, moContinuator<moDummyNeighbor<EOT> >& _cont):
|
||||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
||||||
iterCont(0),
|
iterCont(0),
|
||||||
defaultPerturb(_op, _fullEval),
|
defaultPerturb(_op, _fullEval),
|
||||||
explorer(_ls, defaultPerturb, defaultAccept)
|
explorer(_ls, defaultPerturb, defaultAccept)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for Iterated Local Search
|
* General constructor for Iterated Local Search
|
||||||
|
|
@ -88,23 +88,25 @@ public:
|
||||||
* @param _perturb a perturbation operator
|
* @param _perturb a perturbation operator
|
||||||
* @param _accept a acceptance criteria
|
* @param _accept a acceptance criteria
|
||||||
*/
|
*/
|
||||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, moContinuator<moDummyNeighbor<EOT> >& _cont, moMonOpPerturb<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _accept):
|
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, moContinuator<moDummyNeighbor<EOT> >& _cont, moMonOpPerturb<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _accept):
|
||||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
||||||
iterCont(0),
|
iterCont(0),
|
||||||
defaultPerturb(dummyOp, _fullEval),
|
defaultPerturb(dummyOp, _fullEval),
|
||||||
explorer(_ls, _perturb, _accept)
|
explorer(_ls, _perturb, _accept)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class dummmyMonOp: public eoMonOp<EOT>{
|
class dummmyMonOp: public eoMonOp<EOT> {
|
||||||
public:
|
public:
|
||||||
bool operator()(EOT&){return false;}
|
bool operator()(EOT&) {
|
||||||
}dummyOp;
|
return false;
|
||||||
moIterContinuator<moDummyNeighbor<EOT> > iterCont;
|
}
|
||||||
moMonOpPerturb<Neighbor> defaultPerturb;
|
}dummyOp;
|
||||||
moAlwaysAcceptCrit<Neighbor> defaultAccept;
|
moIterContinuator<moDummyNeighbor<EOT> > iterCont;
|
||||||
moILSexplorer<Neighbor> explorer;
|
moMonOpPerturb<Neighbor> defaultPerturb;
|
||||||
|
moAlwaysAcceptCrit<Neighbor> defaultAccept;
|
||||||
|
moILSexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ template<class Neighbor>
|
||||||
class moLocalSearch: public eoMonOp<typename Neighbor::EOT>
|
class moLocalSearch: public eoMonOp<typename Neighbor::EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood;
|
typedef moNeighborhood<Neighbor> Neighborhood;
|
||||||
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
|
typedef moNeighborhoodExplorer<Neighbor> NeighborhoodExplorer;
|
||||||
typedef typename Neighbor::EOT EOT ;
|
typedef typename Neighbor::EOT EOT ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of a moLocalSearch
|
* Constructor of a moLocalSearch
|
||||||
|
|
@ -105,9 +105,9 @@ public:
|
||||||
* Set an external continuator
|
* Set an external continuator
|
||||||
* @param _cont the external continuator
|
* @param _cont the external continuator
|
||||||
*/
|
*/
|
||||||
void setContinuator(moContinuator<Neighbor> & _cont) {
|
void setContinuator(moContinuator<Neighbor> & _cont) {
|
||||||
cont = &_cont ;
|
cont = &_cont ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* external continuator object
|
* external continuator object
|
||||||
|
|
@ -115,9 +115,9 @@ public:
|
||||||
* @overload
|
* @overload
|
||||||
* @return the external continuator
|
* @return the external continuator
|
||||||
*/
|
*/
|
||||||
moContinuator<Neighbor>* getContinuator() const {
|
moContinuator<Neighbor>* getContinuator() const {
|
||||||
return cont ;
|
return cont ;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// make the exploration of the neighborhood according to a local search heuristic
|
// make the exploration of the neighborhood according to a local search heuristic
|
||||||
|
|
|
||||||
|
|
@ -53,58 +53,58 @@ template<class Neighbor>
|
||||||
class moMetropolisHasting: public moLocalSearch<Neighbor>
|
class moMetropolisHasting: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic constructor of the Metropolis-Hasting
|
* Basic constructor of the Metropolis-Hasting
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
*/
|
*/
|
||||||
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep):
|
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor of the Metropolis-Hasting
|
* Simple constructor of the Metropolis-Hasting
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont):
|
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor of the Metropolis-Hasting
|
* General constructor of the Metropolis-Hasting
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _compN a neighbor vs neighbor comparator
|
* @param _compN a neighbor vs neighbor comparator
|
||||||
* @param _compSN a solution vs neighbor comparator
|
* @param _compSN a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
moMetropolisHasting(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _compN, _compSN, _nbStep)
|
explorer(_neighborhood, _eval, _compN, _compSN, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// compare the fitness values of neighbors: true is strictly greater
|
// compare the fitness values of neighbors: true is strictly greater
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
// the explorer of the HC with neutral move (equals fitness move)
|
// the explorer of the HC with neutral move (equals fitness move)
|
||||||
moMetropolisHastingExplorer<Neighbor> explorer;
|
moMetropolisHastingExplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,58 +49,58 @@ template<class Neighbor>
|
||||||
class moNeutralHC: public moLocalSearch<Neighbor>
|
class moNeutralHC: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic constructor for a hill-climber
|
* Basic constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
*/
|
*/
|
||||||
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep):
|
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont):
|
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a hill-climber
|
* General constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStep maximum step to do
|
* @param _nbStep maximum step to do
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _compN a neighbor vs neighbor comparator
|
* @param _compN a neighbor vs neighbor comparator
|
||||||
* @param _compSN a solution vs neighbor comparator
|
* @param _compSN a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
moNeutralHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned int _nbStep, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _compN, _compSN, _nbStep)
|
explorer(_neighborhood, _eval, _compN, _compSN, _nbStep)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// compare the fitness values of neighbors: true is strictly greater
|
// compare the fitness values of neighbors: true is strictly greater
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
// the explorer of the HC with neutral move (equals fitness move)
|
// the explorer of the HC with neutral move (equals fitness move)
|
||||||
moNeutralHCexplorer<Neighbor> explorer;
|
moNeutralHCexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -50,55 +50,55 @@ template<class Neighbor>
|
||||||
class moRandomBestHC: public moLocalSearch<Neighbor>
|
class moRandomBestHC: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic constructor for a hill-climber
|
* Basic constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
*/
|
*/
|
||||||
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a hill-climber
|
* General constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _compN a neighbor vs neighbor comparator
|
* @param _compN a neighbor vs neighbor comparator
|
||||||
* @param _compSN a solution vs neighbor comparator
|
* @param _compSN a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
moRandomBestHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _compN, _compSN)
|
explorer(_neighborhood, _eval, _compN, _compSN)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// compare the fitness values of neighbors: true is strictly greater
|
// compare the fitness values of neighbors: true is strictly greater
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
// the explorer of the HC with random choice of the best solution
|
// the explorer of the HC with random choice of the best solution
|
||||||
moRandomBestHCexplorer<Neighbor> explorer;
|
moRandomBestHCexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,55 +48,55 @@ template<class Neighbor>
|
||||||
class moRandomNeutralWalk: public moLocalSearch<Neighbor>
|
class moRandomNeutralWalk: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic constructor for a random walk
|
* Basic constructor for a random walk
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStepMax number of step of the walk
|
* @param _nbStepMax number of step of the walk
|
||||||
*/
|
*/
|
||||||
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax):
|
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultSolNeighborComp, _nbStepMax)
|
explorer(_neighborhood, _eval, defaultSolNeighborComp, _nbStepMax)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a random walk
|
* Simple constructor for a random walk
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStepMax number of step of the walk
|
* @param _nbStepMax number of step of the walk
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont):
|
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultSolNeighborComp, _nbStepMax)
|
explorer(_neighborhood, _eval, defaultSolNeighborComp, _nbStepMax)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a random walk
|
* General constructor for a random walk
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStepMax number of step of the walk
|
* @param _nbStepMax number of step of the walk
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _comp a solution vs neighbor comparator
|
* @param _comp a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont, moSolNeighborComparator<Neighbor>& _comp):
|
moRandomNeutralWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont, moSolNeighborComparator<Neighbor>& _comp):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _comp, _nbStepMax)
|
explorer(_neighborhood, _eval, _comp, _nbStepMax)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// the explorer of the random walk
|
// the explorer of the random walk
|
||||||
moRandomNeutralWalkExplorer<Neighbor> explorer;
|
moRandomNeutralWalkExplorer<Neighbor> explorer;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,43 +48,43 @@ template<class Neighbor>
|
||||||
class moRandomSearch: public moLocalSearch<Neighbor>
|
class moRandomSearch: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a random search
|
* Simple constructor for a random search
|
||||||
* @param _init the solution initializer, to explore at random the search space
|
* @param _init the solution initializer, to explore at random the search space
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _nbSolMax number of solutions
|
* @param _nbSolMax number of solutions
|
||||||
*/
|
*/
|
||||||
moRandomSearch(eoInit<EOT> & _init, eoEvalFunc<EOT>& _fullEval, unsigned _nbSolMax):
|
moRandomSearch(eoInit<EOT> & _init, eoEvalFunc<EOT>& _fullEval, unsigned _nbSolMax):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a random search
|
* General constructor for a random search
|
||||||
* @param _init the solution initializer, to explore at random the search space
|
* @param _init the solution initializer, to explore at random the search space
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _nbSolMax number of solutions
|
* @param _nbSolMax number of solutions
|
||||||
* @param _cont external continuator
|
* @param _cont external continuator
|
||||||
*/
|
*/
|
||||||
moRandomSearch(eoInit<EOT> & _init, eoEvalFunc<EOT>& _fullEval, unsigned _nbSolMax, moContinuator<Neighbor>& _cont):
|
moRandomSearch(eoInit<EOT> & _init, eoEvalFunc<EOT>& _fullEval, unsigned _nbSolMax, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
explorer(_init, _fullEval, _nbSolMax>0?_nbSolMax - 1:0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the class
|
* @return name of the class
|
||||||
*/
|
*/
|
||||||
virtual std::string className(void) const {
|
virtual std::string className(void) const {
|
||||||
return "moRandomSearch";
|
return "moRandomSearch";
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// the explorer of the random walk
|
// the explorer of the random walk
|
||||||
moRandomSearchExplorer<Neighbor> explorer;
|
moRandomSearchExplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,39 +48,39 @@ template<class Neighbor>
|
||||||
class moRandomWalk: public moLocalSearch<Neighbor>
|
class moRandomWalk: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a random walk
|
* Simple constructor for a random walk
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStepMax number of step of the walk
|
* @param _nbStepMax number of step of the walk
|
||||||
*/
|
*/
|
||||||
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax):
|
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _nbStepMax)
|
explorer(_neighborhood, _eval, _nbStepMax)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a random walk
|
* General constructor for a random walk
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _nbStepMax number of step of the walk
|
* @param _nbStepMax number of step of the walk
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont):
|
moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, unsigned _nbStepMax, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _nbStepMax)
|
explorer(_neighborhood, _eval, _nbStepMax)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// the explorer of the random walk
|
// the explorer of the random walk
|
||||||
moRandomWalkExplorer<Neighbor> explorer;
|
moRandomWalkExplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class moSA: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,11 +60,11 @@ public:
|
||||||
* @param _span number of iteration with equal temperature for cooling schedule (default = 100)
|
* @param _span number of iteration with equal temperature for cooling schedule (default = 100)
|
||||||
* @param _finalT final temperature, threshold of the stopping criteria for cooling schedule (default = 0.01)
|
* @param _finalT final temperature, threshold of the stopping criteria for cooling schedule (default = 0.01)
|
||||||
*/
|
*/
|
||||||
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, double _initT=10, double _alpha=0.9, unsigned _span=100, double _finalT=0.01):
|
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, double _initT=10, double _alpha=0.9, unsigned _span=100, double _finalT=0.01):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
defaultCool(_initT, _alpha, _span, _finalT),
|
defaultCool(_initT, _alpha, _span, _finalT),
|
||||||
explorer(_neighborhood, _eval, defaultSolNeighborComp, defaultCool)
|
explorer(_neighborhood, _eval, defaultSolNeighborComp, defaultCool)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a simulated annealing
|
* Simple constructor for a simulated annealing
|
||||||
|
|
@ -73,11 +73,11 @@ public:
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cool a cooling schedule
|
* @param _cool a cooling schedule
|
||||||
*/
|
*/
|
||||||
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moCoolingSchedule<EOT>& _cool):
|
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moCoolingSchedule<EOT>& _cool):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
defaultCool(0, 0, 0, 0),
|
defaultCool(0, 0, 0, 0),
|
||||||
explorer(_neighborhood, _eval, defaultSolNeighborComp, _cool)
|
explorer(_neighborhood, _eval, defaultSolNeighborComp, _cool)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a simulated annealing
|
* General constructor for a simulated annealing
|
||||||
|
|
@ -88,19 +88,19 @@ public:
|
||||||
* @param _comp a solution vs neighbor comparator
|
* @param _comp a solution vs neighbor comparator
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moCoolingSchedule<EOT>& _cool, moSolNeighborComparator<Neighbor>& _comp, moContinuator<Neighbor>& _cont):
|
moSA(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moCoolingSchedule<EOT>& _cool, moSolNeighborComparator<Neighbor>& _comp, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
defaultCool(0, 0, 0, 0),
|
defaultCool(0, 0, 0, 0),
|
||||||
explorer(_neighborhood, _eval, _comp, _cool)
|
explorer(_neighborhood, _eval, _comp, _cool)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
moSimpleCoolingSchedule<EOT> defaultCool;
|
moSimpleCoolingSchedule<EOT> defaultCool;
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
moSAexplorer<Neighbor> explorer;
|
moSAexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -50,55 +50,55 @@ template<class Neighbor>
|
||||||
class moSimpleHC: public moLocalSearch<Neighbor>
|
class moSimpleHC: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
*/
|
*/
|
||||||
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval):
|
||||||
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, trueCont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
*/
|
*/
|
||||||
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a hill-climber
|
* Simple constructor for a hill-climber
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
* @param _fullEval the full evaluation function
|
* @param _fullEval the full evaluation function
|
||||||
* @param _eval neighbor's evaluation function
|
* @param _eval neighbor's evaluation function
|
||||||
* @param _cont an external continuator
|
* @param _cont an external continuator
|
||||||
* @param _compN a neighbor vs neighbor comparator
|
* @param _compN a neighbor vs neighbor comparator
|
||||||
* @param _compSN a solution vs neighbor comparator
|
* @param _compSN a solution vs neighbor comparator
|
||||||
*/
|
*/
|
||||||
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
moSimpleHC(Neighborhood& _neighborhood, eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval, moContinuator<Neighbor>& _cont, moNeighborComparator<Neighbor>& _compN, moSolNeighborComparator<Neighbor>& _compSN):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
explorer(_neighborhood, _eval, _compN, _compSN)
|
explorer(_neighborhood, _eval, _compN, _compSN)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// always true continuator
|
// always true continuator
|
||||||
moTrueContinuator<Neighbor> trueCont;
|
moTrueContinuator<Neighbor> trueCont;
|
||||||
// compare the fitness values of neighbors: true is strictly greater
|
// compare the fitness values of neighbors: true is strictly greater
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
// compare the fitness values of the solution and the neighbor: true if strictly greater
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
// the explorer of the simple HC
|
// the explorer of the simple HC
|
||||||
moSimpleHCexplorer<Neighbor> explorer;
|
moSimpleHCexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class moTS: public moLocalSearch<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,17 +62,17 @@ public:
|
||||||
* @param _time the time limit for stopping criteria
|
* @param _time the time limit for stopping criteria
|
||||||
* @param _tabuListSize the size of the tabu list
|
* @param _tabuListSize the size of the tabu list
|
||||||
*/
|
*/
|
||||||
moTS(Neighborhood& _neighborhood,
|
moTS(Neighborhood& _neighborhood,
|
||||||
eoEvalFunc<EOT>& _fullEval,
|
eoEvalFunc<EOT>& _fullEval,
|
||||||
moEval<Neighbor>& _eval,
|
moEval<Neighbor>& _eval,
|
||||||
unsigned int _time,
|
unsigned int _time,
|
||||||
unsigned int _tabuListSize
|
unsigned int _tabuListSize
|
||||||
):
|
):
|
||||||
moLocalSearch<Neighbor>(explorer, timeCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, timeCont, _fullEval),
|
||||||
timeCont(_time),
|
timeCont(_time),
|
||||||
tabuList(_tabuListSize,0),
|
tabuList(_tabuListSize,0),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, tabuList, dummyIntensification, dummyDiversification, defaultAspiration)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, tabuList, dummyIntensification, dummyDiversification, defaultAspiration)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor for a tabu search
|
* Simple constructor for a tabu search
|
||||||
|
|
@ -82,16 +82,16 @@ public:
|
||||||
* @param _time the time limit for stopping criteria
|
* @param _time the time limit for stopping criteria
|
||||||
* @param _tabuList the tabu list
|
* @param _tabuList the tabu list
|
||||||
*/
|
*/
|
||||||
moTS(Neighborhood& _neighborhood,
|
moTS(Neighborhood& _neighborhood,
|
||||||
eoEvalFunc<EOT>& _fullEval,
|
eoEvalFunc<EOT>& _fullEval,
|
||||||
moEval<Neighbor>& _eval,
|
moEval<Neighbor>& _eval,
|
||||||
unsigned int _time,
|
unsigned int _time,
|
||||||
moTabuList<Neighbor>& _tabuList):
|
moTabuList<Neighbor>& _tabuList):
|
||||||
moLocalSearch<Neighbor>(explorer, timeCont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, timeCont, _fullEval),
|
||||||
timeCont(_time),
|
timeCont(_time),
|
||||||
tabuList(0,0),
|
tabuList(0,0),
|
||||||
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _tabuList, dummyIntensification, dummyDiversification, defaultAspiration)
|
explorer(_neighborhood, _eval, defaultNeighborComp, defaultSolNeighborComp, _tabuList, dummyIntensification, dummyDiversification, defaultAspiration)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General constructor for a tabu search
|
* General constructor for a tabu search
|
||||||
|
|
@ -106,31 +106,31 @@ public:
|
||||||
* @param _diversification the diversification strategy
|
* @param _diversification the diversification strategy
|
||||||
* @param _aspiration the aspiration Criteria
|
* @param _aspiration the aspiration Criteria
|
||||||
*/
|
*/
|
||||||
moTS(Neighborhood& _neighborhood,
|
moTS(Neighborhood& _neighborhood,
|
||||||
eoEvalFunc<EOT>& _fullEval,
|
eoEvalFunc<EOT>& _fullEval,
|
||||||
moEval<Neighbor>& _eval,
|
moEval<Neighbor>& _eval,
|
||||||
moNeighborComparator<Neighbor>& _neighborComp,
|
moNeighborComparator<Neighbor>& _neighborComp,
|
||||||
moSolNeighborComparator<Neighbor>& _solNeighborComp,
|
moSolNeighborComparator<Neighbor>& _solNeighborComp,
|
||||||
moContinuator<Neighbor>& _cont,
|
moContinuator<Neighbor>& _cont,
|
||||||
moTabuList<Neighbor>& _tabuList,
|
moTabuList<Neighbor>& _tabuList,
|
||||||
moIntensification<Neighbor>& _intensification,
|
moIntensification<Neighbor>& _intensification,
|
||||||
moDiversification<Neighbor>& _diversification,
|
moDiversification<Neighbor>& _diversification,
|
||||||
moAspiration<Neighbor>& _aspiration):
|
moAspiration<Neighbor>& _aspiration):
|
||||||
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
moLocalSearch<Neighbor>(explorer, _cont, _fullEval),
|
||||||
timeCont(0),
|
timeCont(0),
|
||||||
tabuList(0,0),
|
tabuList(0,0),
|
||||||
explorer(_neighborhood, _eval, _neighborComp, _solNeighborComp, _tabuList, _intensification, _diversification, _aspiration)
|
explorer(_neighborhood, _eval, _neighborComp, _solNeighborComp, _tabuList, _intensification, _diversification, _aspiration)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
moTimeContinuator<Neighbor> timeCont;
|
moTimeContinuator<Neighbor> timeCont;
|
||||||
moNeighborComparator<Neighbor> defaultNeighborComp;
|
moNeighborComparator<Neighbor> defaultNeighborComp;
|
||||||
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
|
||||||
moNeighborVectorTabuList<Neighbor> tabuList;
|
moNeighborVectorTabuList<Neighbor> tabuList;
|
||||||
moDummyIntensification<Neighbor> dummyIntensification;
|
moDummyIntensification<Neighbor> dummyIntensification;
|
||||||
moDummyDiversification<Neighbor> dummyDiversification;
|
moDummyDiversification<Neighbor> dummyDiversification;
|
||||||
moBestImprAspiration<Neighbor> defaultAspiration;
|
moBestImprAspiration<Neighbor> defaultAspiration;
|
||||||
moTSexplorer<Neighbor> explorer;
|
moTSexplorer<Neighbor> explorer;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,11 @@ class moComparator : public eoBF<const T1 & , const T2 & , bool>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param _ref1 a reference on a variable of type T1
|
* @param _ref1 a reference on a variable of type T1
|
||||||
* @param _ref2 a reference on a variable of type T2
|
* @param _ref2 a reference on a variable of type T2
|
||||||
* @return true if _ref1 and _ref2 are equals
|
* @return true if _ref1 and _ref2 are equals
|
||||||
*/
|
*/
|
||||||
virtual bool equals(const T1& _ref1, const T2& _ref2) = 0;
|
virtual bool equals(const T1& _ref1, const T2& _ref2) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -44,37 +44,37 @@ template <class EOT>
|
||||||
class moBestSoFarStat : public moStat<EOT, EOT&>
|
class moBestSoFarStat : public moStat<EOT, EOT&>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
using moStat< EOT , EOT& >::value;
|
using moStat< EOT , EOT& >::value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
moBestSoFarStat(): moStat<EOT, EOT&>(EOT(), "best") {
|
moBestSoFarStat(): moStat<EOT, EOT&>(EOT(), "best") {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization of the best solution on the first one
|
* Initialization of the best solution on the first one
|
||||||
* @param _sol the first solution
|
* @param _sol the first solution
|
||||||
*/
|
*/
|
||||||
virtual void init(EOT & _sol) {
|
virtual void init(EOT & _sol) {
|
||||||
value() = _sol;
|
value() = _sol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the best solution
|
* Update the best solution
|
||||||
* @param _sol the current solution
|
* @param _sol the current solution
|
||||||
*/
|
*/
|
||||||
virtual void operator()(EOT & _sol) {
|
virtual void operator()(EOT & _sol) {
|
||||||
if (value().fitness() < _sol.fitness())
|
if (value().fitness() < _sol.fitness())
|
||||||
value() = _sol;
|
value() = _sol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the class
|
* @return name of the class
|
||||||
*/
|
*/
|
||||||
virtual std::string className(void) const {
|
virtual std::string className(void) const {
|
||||||
return "moBestSoFarStat";
|
return "moBestSoFarStat";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,52 +42,52 @@ template< class Neighbor >
|
||||||
class moCombinedContinuator : public moContinuator<Neighbor>
|
class moCombinedContinuator : public moContinuator<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Neighbor::EOT EOT ;
|
typedef typename Neighbor::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
|
||||||
*/
|
*/
|
||||||
moCombinedContinuator(moContinuator<Neighbor>& _cont) {
|
moCombinedContinuator(moContinuator<Neighbor>& _cont) {
|
||||||
continuators.push_back(&_cont);
|
continuators.push_back(&_cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a continuator to the combined continuator
|
* add a continuator to the combined continuator
|
||||||
* @param _cont a continuator
|
* @param _cont a continuator
|
||||||
*/
|
*/
|
||||||
void add(moContinuator<Neighbor>& _cont) {
|
void add(moContinuator<Neighbor>& _cont) {
|
||||||
continuators.push_back(&_cont);
|
continuators.push_back(&_cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init all continuators
|
* init all continuators
|
||||||
* @param _solution a solution
|
* @param _solution a solution
|
||||||
*/
|
*/
|
||||||
virtual void init(EOT & _solution) {
|
virtual void init(EOT & _solution) {
|
||||||
for(unsigned int i = 0; i < continuators.size(); ++i)
|
for (unsigned int i = 0; i < continuators.size(); ++i)
|
||||||
continuators[i]->init(_solution);
|
continuators[i]->init(_solution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@param _solution a solution
|
*@param _solution a solution
|
||||||
*@return true all the continuators are true
|
*@return true all the continuators are true
|
||||||
*/
|
*/
|
||||||
virtual bool operator()(EOT & _solution) {
|
virtual bool operator()(EOT & _solution) {
|
||||||
bool bContinue = true;
|
bool bContinue = true;
|
||||||
|
|
||||||
// some data may be update in each continuator.
|
// some data may be update in each continuator.
|
||||||
// So, all continuators are tested
|
// So, all continuators are tested
|
||||||
for(unsigned int i = 0; i < continuators.size(); ++i)
|
for (unsigned int i = 0; i < continuators.size(); ++i)
|
||||||
if ( !(*continuators[i])(_solution) )
|
if ( !(*continuators[i])(_solution) )
|
||||||
bContinue = false;
|
bContinue = false;
|
||||||
|
|
||||||
return bContinue;
|
return bContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** continuators vector */
|
/** continuators vector */
|
||||||
std::vector< moContinuator<Neighbor>* > continuators;
|
std::vector< moContinuator<Neighbor>* > continuators;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,36 +44,36 @@ template <class EOT>
|
||||||
class moCounterStat : public moStat<EOT, unsigned int>
|
class moCounterStat : public moStat<EOT, unsigned int>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
using moStat< EOT, unsigned int>::value;
|
using moStat< EOT, unsigned int>::value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
moCounterStat(): moStat<EOT, unsigned int>(0, "counter") {
|
moCounterStat(): moStat<EOT, unsigned int>(0, "counter") {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give the number of iteration
|
* Give the number of iteration
|
||||||
* @param _sol a solution
|
* @param _sol a solution
|
||||||
*/
|
*/
|
||||||
virtual void init(EOT & _sol) {
|
virtual void init(EOT & _sol) {
|
||||||
value() = 0;
|
value() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give the number of iteration
|
* Give the number of iteration
|
||||||
* @param _sol a solution
|
* @param _sol a solution
|
||||||
*/
|
*/
|
||||||
virtual void operator()(EOT & _sol) {
|
virtual void operator()(EOT & _sol) {
|
||||||
value() = value() + 1;
|
value() = value() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of the class
|
* @return name of the class
|
||||||
*/
|
*/
|
||||||
virtual std::string className(void) const {
|
virtual std::string className(void) const {
|
||||||
return "moCounterStat";
|
return "moCounterStat";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue