New style for MO

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@787 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2007-11-16 11:25:54 +00:00
commit 7161febf9c
80 changed files with 2014 additions and 2038 deletions

View file

@ -44,8 +44,6 @@
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
*/
template < class EOT > class moAlgo:public eoMonOp < EOT >
{
};
{};
#endif

View file

@ -47,9 +47,9 @@
template < class M > class moAspirCrit:public eoBF < const M &, const typename
M::EOType::Fitness &,
bool >
{
{
public:
public:
//! Procedure which initialises all that needs a aspiration criterion.
/*!
It can be possible that this procedure do nothing...
@ -57,6 +57,6 @@ public:
virtual void
init () = 0;
};
};
#endif

View file

@ -45,9 +45,9 @@
which enables the best improvement is selected.
*/
template < class M > class moBestImprSelect:public moMoveSelect < M >
{
{
public:
public:
//! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness;
@ -102,7 +102,7 @@ public:
throw EmptySelection ();
}
private:
private:
//! Allowing to know if at least one move has been generated.
bool first_time;
@ -113,6 +113,6 @@ private:
//! The best fitness.
Fitness best_fit;
};
};
#endif

View file

@ -44,7 +44,6 @@
*/
template<class EOT>
class moComparator: public eoBF<const EOT&, const EOT&, bool>
{
};
{};
#endif

View file

@ -45,8 +45,6 @@
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
*/
class moCoolingSchedule:public eoUF < double &, bool >
{
};
{};
#endif

View file

@ -45,9 +45,9 @@
the temperature is greater than a given threshold.
*/
class moExponentialCoolingSchedule: public moCoolingSchedule
{
{
public:
public:
//! Simple constructor
/*!
\param __threshold the threshold.
@ -68,13 +68,13 @@ public:
return (__temp *= ratio) > threshold;
}
private:
private:
//! The temperature threhold.
double threshold;
//! The decreasing factor of the temperature.
double ratio;
};
};
#endif

View file

@ -46,9 +46,9 @@
current solution.
*/
template < class M > class moFirstImprSelect:public moMoveSelect < M >
{
{
public:
public:
//! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness;
@ -110,7 +110,7 @@ public:
throw EmptySelection ();
}
private:
private:
//! Allow to know if at least one move has improved the solution.
bool valid;
@ -124,6 +124,6 @@ private:
//! Best stored fitness.
Fitness best_fit;
};
};
#endif

View file

@ -43,7 +43,7 @@
*/
template<class EOT>
class moFitComparator: public moComparator<EOT>
{
{
public:
//! Function which makes the comparison and gives the result.
@ -56,6 +56,6 @@ class moFitComparator: public moComparator<EOT>
{
return _solution1.fitness()>_solution2.fitness();
}
};
};
#endif

View file

@ -44,9 +44,9 @@
The stop criterion corresponds to a fitness threshold gained.
*/
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
{
{
public:
public:
//! Alias for the fitness.
typedef typename EOT::Fitness Fitness;
@ -67,7 +67,7 @@ public:
*/
bool operator () (const EOT & __sol)
{
if(__sol.invalid())
if (__sol.invalid())
{
return true;
}
@ -82,10 +82,10 @@ public:
void init ()
{}
private:
private:
//! Fitness target.
Fitness fitness;
};
};
#endif

View file

@ -44,18 +44,16 @@
The stop criterion corresponds to a maximum number of iteration.
*/
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
{
{
public:
public:
//! Simple constructor.
/*!
\param __maxNumGen the maximum number of generation.
*/
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
{
}
{}
//! Function that activates the stop criterion.
/*!
@ -82,13 +80,13 @@ public:
numGen = 0;
}
private:
private:
//! Iteration maximum number.
unsigned int maxNumGen;
//! Iteration current number.
unsigned int numGen;
};
};
#endif

View file

@ -48,7 +48,7 @@
Class which describes the algorithm for a hill climbing.
*/
template < class M > class moHC:public moAlgo < typename M::EOType >
{
{
//! Alias for the type.
typedef
@ -62,7 +62,7 @@ template < class M > class moHC:public moAlgo < typename M::EOType >
EOT::Fitness
Fitness;
public:
public:
//! Full constructor.
/*!
@ -74,12 +74,10 @@ public:
\param __move_select a move selector.
\param __full_eval a full evaluation function.
*/
moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
(__move_init, __next_move, __incr_eval, __move_select)),
full_eval (__full_eval)
{
}
{}
//! Light constructor.
/*!
@ -88,12 +86,10 @@ moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEv
\param __move_expl a complete explorer.
\param __full_eval a full evaluation function.
*/
moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
full_eval
(__full_eval)
{
}
{}
//! Function which launches the HC
/*!
@ -145,13 +141,13 @@ moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl
return true;
}
private:
private:
//! Complete exploration of the neighborhood.
moMoveExpl < M > &move_expl;
//! A full evaluation function.
eoEvalFunc < EOT > &full_eval;
};
};
#endif

View file

@ -46,7 +46,7 @@
//! Iterative explorer used by a moHC.
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
{
{
//! Alias for the type.
typedef typename M::EOType EOT;
@ -54,7 +54,7 @@ template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
//! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness;
public:
public:
//! Constructor.
/*!
@ -65,14 +65,12 @@ public:
\param __incr_eval (generally) efficient evaluation function.
\param __move_select the move selector.
*/
moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select):
moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select):
move_init (__move_init),
next_move (__next_move),
incr_eval (__incr_eval), move_select (__move_select)
{
}
{}
//! Procedure which launches the explorer.
/*!
@ -114,7 +112,7 @@ moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
}
}
private:
private:
//! Move initialiser.
moMoveInit < M > &move_init;
@ -128,6 +126,6 @@ private:
//! Move selector.
moMoveSelect < M > &move_select;
};
};
#endif

View file

@ -48,7 +48,7 @@
Class which describes the algorithm for a iterated local search.
*/
template < class M > class moILS:public moAlgo < typename M::EOType >
{
{
//! Alias for the type.
typedef typename M::EOType EOT;
@ -56,7 +56,7 @@ template < class M > class moILS:public moAlgo < typename M::EOType >
//! Alias for the fitness.
typedef typename EOT::Fitness Fitness;
public:
public:
//! Generic constructor
/*!
@ -152,7 +152,7 @@ public:
algo(__sol);
if(acceptance_criterion(__sol, __sol_saved))
if (acceptance_criterion(__sol, __sol_saved))
{
__sol_saved=__sol;
@ -169,7 +169,7 @@ public:
algo(__sol);
if(acceptance_criterion(__sol, __sol_saved))
if (acceptance_criterion(__sol, __sol_saved))
{
__sol_saved=__sol;
}
@ -182,7 +182,7 @@ public:
return true;
}
private:
private:
//! The solution based heuristic.
moAlgo<EOT> &algo;
@ -198,6 +198,6 @@ private:
//! The full evaluation function
eoEvalFunc<EOT> &full_eval;
};
};
#endif

View file

@ -45,9 +45,9 @@
is the best ever considered.
*/
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
{
{
public:
public:
//! Alias for the fitness
typedef typename M::EOType::Fitness Fitness;
@ -97,13 +97,13 @@ public:
}
}
private:
private:
//! Best fitness found until now
Fitness best_fit;
//! Indicates that a fitness has been already saved or not
bool first_time;
};
};
#endif

View file

@ -45,12 +45,12 @@
This class is a move (moMove) generator with a bound for the maximum number of iterations.
*/
template < class M > class moItRandNextMove:public moNextMove < M >
{
{
//! Alias for the type.
typedef typename M::EOType EOT;
public:
public:
//! The constructor.
/*!
@ -62,9 +62,7 @@ public:
moItRandNextMove (moRandMove < M > &__rand_move,
unsigned int __max_iter):rand_move (__rand_move),
max_iter (__max_iter), num_iter (0)
{
}
{}
//! Generation of a new move
/*!
@ -93,7 +91,7 @@ public:
}
}
private:
private:
//! A move generator (generally randomly).
moRandMove < M > &rand_move;
@ -104,6 +102,6 @@ private:
//! Iteration current number.
unsigned int num_iter;
};
};
#endif

View file

@ -45,9 +45,9 @@
*/
template < class M > class moLSCheckPoint:public eoBF < const M &, const typename
M::EOType &, void >
{
{
public:
public:
//! Function which launches the checkpointing
/*!
Each saved function is used on the current move and the current solution.
@ -77,7 +77,7 @@ public:
func.push_back (&__f);
}
private:
private:
//! vector of function
std::vector < eoBF < const
@ -86,6 +86,6 @@ private:
M::EOType &, void >*>
func;
};
};
#endif

View file

@ -45,9 +45,9 @@
the temperature is greater than a threshold.
*/
class moLinearCoolingSchedule: public moCoolingSchedule
{
{
public:
public:
//! Simple constructor
/*!
\param __threshold the threshold.
@ -68,13 +68,13 @@ public:
return (__temp -= quantity) > threshold;
}
private:
private:
//! The temperature threhold.
double threshold;
//! The quantity that allows the temperature to decrease.
double quantity;
};
};
#endif

View file

@ -46,12 +46,12 @@
It describes how a solution can be modified to another one.
*/
template < class EOT > class moMove:public eoUF < EOT &, void >
{
{
public:
public:
//! Alias for the type
typedef EOT EOType;
};
};
#endif

View file

@ -46,9 +46,7 @@
template < class M > class moMoveExpl:public eoBF < const typename
M::EOType &,
typename
M::EOType &, void >
{
};
M::EOType &, void >
{};
#endif

View file

@ -50,8 +50,6 @@ template < class M > class moMoveIncrEval:public eoBF < const M &, const typenam
M::EOType &,
typename
M::EOType::Fitness >
{
};
{};
#endif

View file

@ -45,9 +45,7 @@
Only a description... An object that herits from this class needs to be designed to be used.
*/
template < class M > class moMoveInit:public eoBF < M &, const typename
M::EOType &, void >
{
};
M::EOType &, void >
{};
#endif

View file

@ -44,8 +44,6 @@
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
*/
template < class M > class moMoveLoopExpl:public moMoveExpl < M >
{
};
{};
#endif

View file

@ -44,9 +44,7 @@
This class is used as an exception that can be thrown if a solution selector has completly failed.
*/
class EmptySelection
{
};
{};
//! Class that describes a move selector (moMove).
/*!
@ -56,8 +54,8 @@ class EmptySelection
*/
template < class M > class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &,
void >
{
public:
{
public:
//! Alias for the fitness
typedef
typename
@ -85,6 +83,6 @@ public:
bool
update (const M & __move, const Fitness & __fit) = 0;
};
};
#endif

View file

@ -47,8 +47,6 @@
template < class M > class moNextMove:public eoBF < M &, const typename
M::EOType &,
bool >
{
};
{};
#endif

View file

@ -44,7 +44,7 @@
The simplest : never satisfied.
*/
template < class M > class moNoAspirCrit:public moAspirCrit < M >
{
{
//! Function which describes the aspiration criterion behaviour
/*!
@ -66,8 +66,7 @@ template < class M > class moNoAspirCrit:public moAspirCrit < M >
Nothing...
*/
void init ()
{
}
};
{}
};
#endif

View file

@ -44,9 +44,9 @@
The stop criterion corresponds to a maximum number of iterations without improvement.
*/
template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT >
{
{
public:
public:
//! Alias for the fitness.
typedef typename EOT::Fitness Fitness;
@ -67,12 +67,12 @@ public:
*/
bool operator () (const EOT & __sol)
{
if(__sol.invalid())
if (__sol.invalid())
{
return true;
}
if(firstFitnessSaved)
if (firstFitnessSaved)
{
fitness=__sol.fitness();
counter=0;
@ -82,13 +82,13 @@ public:
counter++;
if( __sol.fitness() > fitness)
if ( __sol.fitness() > fitness)
{
fitness=__sol.fitness();
counter=0;
}
if(counter==maxNumberOfIterationsWithoutImprovement)
if (counter==maxNumberOfIterationsWithoutImprovement)
{
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
}
@ -105,7 +105,7 @@ public:
counter=0;
}
private:
private:
//! Maximum number of iterations without improvement allowed.
unsigned int maxNumberOfIterationsWithoutImprovement;
@ -118,6 +118,6 @@ private:
//! The iteration couter.
unsigned int counter;
};
};
#endif

View file

@ -48,9 +48,9 @@
One of them that enables an improvment of the objective function is choosen.
*/
template < class M > class moRandImprSelect:public moMoveSelect < M >
{
{
public:
public:
//! Alias for the fitness
typedef typename M::EOType::Fitness Fitness;
@ -114,7 +114,7 @@ public:
throw EmptySelection ();
}
private:
private:
//! Fitness of the current solution.
Fitness init_fit;
@ -124,6 +124,6 @@ private:
//! Candidate move vector.
std::vector < M > vect_better_moves;
};
};
#endif

View file

@ -44,8 +44,6 @@
Only a description... An object that herits from this class needs to be designed in order to use a moSA.
*/
template < class M > class moRandMove:public eoUF < M &, void >
{
};
{};
#endif

View file

@ -53,7 +53,7 @@
Class that describes a Simulated Annealing algorithm.
*/
template < class M > class moSA:public moAlgo < typename M::EOType >
{
{
//! Alias for the type
typedef
@ -67,7 +67,7 @@ template < class M > class moSA:public moAlgo < typename M::EOType >
EOT::Fitness
Fitness;
public:
public:
//! SA constructor
/*!
@ -91,9 +91,7 @@ public:
init_temp (__init_temp),
cool_sched (__cool_sched),
full_eval (__full_eval)
{
}
{}
//! function that launches the SA algorithm.
/*!
@ -150,7 +148,7 @@ public:
return true;
}
private:
private:
//! A move generator (generally randomly)
moRandMove < M > &move_rand;
@ -169,6 +167,6 @@ private:
//! A full evaluation function.
eoEvalFunc < EOT > &full_eval; // Full evaluator.
};
};
#endif

View file

@ -45,9 +45,9 @@
//! Class describing a move tabu list with a limited memory.
template <class M>
class moSimpleMoveTabuList: public moTabuList < M >
{
{
public:
public:
//! Alias for the type
typedef typename M::EOType EOT;
@ -73,7 +73,7 @@ public:
typename std::list<M>::iterator it;
it=tabuList.begin();
while(it!=tabuList.end()&&(!((*it)==__move)))
while (it!=tabuList.end()&&(!((*it)==__move)))
{
it++;
}
@ -84,7 +84,7 @@ public:
void
add (const M & __move, const EOT & __sol)
{
if(currentSize!=0)
if (currentSize!=0)
{
// Useful in the case of a move has been kept thanks to the moAspirCrit.
// In this case, the move can already be in the tabuList.
@ -93,7 +93,7 @@ public:
tabuList.push_back(__move);
if(currentSize==maxSize)
if (currentSize==maxSize)
{
tabuList.erase(tabuList.begin());
}
@ -115,7 +115,7 @@ public:
//nothing to do
}
private:
private:
//! Procedure that removes a given move from the tabu list (if it is into, else do nothing).
/*!
@ -127,12 +127,12 @@ private:
typename std::list<M>::iterator it;
it=tabuList.begin();
while(it!=tabuList.end()&&(!((*it)==__move)))
while (it!=tabuList.end()&&(!((*it)==__move)))
{
it++;
}
if(it!=tabuList.end())
if (it!=tabuList.end())
{
tabuList.erase(it);
}
@ -146,6 +146,6 @@ private:
//! The move tabu list.
std::list<M> tabuList;
};
};
#endif

View file

@ -45,9 +45,9 @@
//! Class describing a solution tabu list with limited length.
template <class M>
class moSimpleSolutionTabuList: public moTabuList < M >
{
{
public:
public:
//! Alias for the type
typedef typename M::EOType EOT;
@ -77,7 +77,7 @@ public:
_move(_sol);
it=tabuList.begin();
while(it!=tabuList.end()&&(!((*it)==_sol)))
while (it!=tabuList.end()&&(!((*it)==_sol)))
{
it++;
}
@ -93,7 +93,7 @@ public:
_move(_sol);
if(currentSize!=0)
if (currentSize!=0)
{
// Useful in the case of a solution has been kept thanks to the moAspirCrit.
// In this case, the solution can already be in the tabuList.
@ -102,7 +102,7 @@ public:
tabuList.push_back(_sol);
if(currentSize==maxSize)
if (currentSize==maxSize)
{
tabuList.erase(tabuList.begin());
}
@ -124,7 +124,7 @@ public:
//nothing to do
}
private:
private:
//! Procedure that removes a given solution from the tabu list (if it is into, else does nothing).
/*!
@ -136,12 +136,12 @@ private:
typename std::list<EOT>::iterator it;
it=tabuList.begin();
while(it!=tabuList.end()&&(!((*it)==__sol)))
while (it!=tabuList.end()&&(!((*it)==__sol)))
{
it++;
}
if(it!=tabuList.end())
if (it!=tabuList.end())
{
tabuList.erase(it);
}
@ -155,6 +155,6 @@ private:
//! The solution tabu list.
std::list<EOT> tabuList;
};
};
#endif

View file

@ -45,14 +45,14 @@
It allows to add an initialisation procedure to an object that is a unary function (eoUF).
*/
template < class EOT > class moSolContinue:public eoUF < const EOT &, bool >
{
{
public:
public:
//! Procedure which initialises all that the stop criterion needs
/*!
Generally, it allocates some data structures or initialises some counters.
*/
virtual void init () = 0;
};
};
#endif

View file

@ -44,9 +44,9 @@
The stop criterion corresponds to a maximum number of iterations without improvement (after a minimum number of iterations).
*/
template < class EOT > class moSteadyFitSolContinue:public moSolContinue < EOT >
{
{
public:
public:
//! Alias for the fitness.
typedef typename EOT::Fitness Fitness;
@ -70,22 +70,22 @@ public:
*/
bool operator () (const EOT & __sol)
{
if(!maxNumberOfIterationsReached)
if (!maxNumberOfIterationsReached)
{
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
if(maxNumberOfIterationsReached)
if (maxNumberOfIterationsReached)
{
std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl;
}
return true;
}
if(__sol.invalid())
if (__sol.invalid())
{
return true;
}
if(firstFitnessSaved)
if (firstFitnessSaved)
{
fitness=__sol.fitness();
counter=0;
@ -95,13 +95,13 @@ public:
counter++;
if( __sol.fitness() > fitness )
if ( __sol.fitness() > fitness )
{
fitness=__sol.fitness();
counter=0;
}
if(counter==maxNumberOfIterationsWithoutImprovement)
if (counter==maxNumberOfIterationsWithoutImprovement)
{
std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
}
@ -119,7 +119,7 @@ public:
firstFitnessSaved=true;
}
private:
private:
//! Maximum number of iterations before considering the fitness.
unsigned int maxNumberOfIterations;
@ -138,6 +138,6 @@ private:
//! The iteration couter.
unsigned int counter;
};
};
#endif

View file

@ -52,7 +52,7 @@
Generic algorithm that describes a tabu search.
*/
template < class M > class moTS:public moAlgo < typename M::EOType >
{
{
//!Alias for the type
typedef
@ -66,7 +66,7 @@ template < class M > class moTS:public moAlgo < typename M::EOType >
EOT::Fitness
Fitness;
public:
public:
//!Constructor of a moTS specifying all the boxes
/*!
@ -80,7 +80,7 @@ public:
\param __cont stop criterion
\param __full_eval full evaluation function
*/
moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
(__move_init, __next_move, __incr_eval, __tabu_list,
__aspir_crit)), cont (__cont), full_eval (__full_eval)
{}
@ -93,7 +93,7 @@ moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEv
\param __cont stop criterion
\param __full_eval full evaluation function
*/
moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
cont (__cont),
full_eval (__full_eval)
{}
@ -154,7 +154,7 @@ moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc <
return true;
}
private:
private:
//! Neighborhood explorer
moMoveExpl < M > &move_expl;
@ -164,6 +164,6 @@ private:
//! Full evaluation function
eoEvalFunc < EOT > &full_eval;
};
};
#endif

View file

@ -53,7 +53,7 @@
It is used by a moTS.
*/
template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
{
{
//!Alias for the type
typedef typename M::EOType EOT;
@ -61,7 +61,7 @@ template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
//!Alias for the fitness
typedef typename M::EOType::Fitness Fitness;
public:
public:
//!Constructor
/*!
@ -71,7 +71,7 @@ public:
\param __tabu_list tabu list
\param __aspir_crit aspiration criterion
*/
moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
move_init (__move_init),
next_move (__next_move),
incr_eval (__incr_eval),
@ -133,7 +133,7 @@ moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
tabu_list.add (best_move, __new_sol);
}
private:
private:
//!Move initialisation
moMoveInit < M > &move_init;
@ -152,6 +152,6 @@ private:
//!Aspiration criterion
moAspirCrit < M > &aspir_crit;
};
};
#endif

View file

@ -47,9 +47,9 @@
template < class M > class moTabuList:public eoBF < const M &, const typename
M::EOType &,
bool >
{
{
public:
public:
//! Alias for the type
typedef typename M::EOType EOT;
@ -76,6 +76,6 @@ public:
*/
virtual void
init () = 0;
};
};
#endif

View file

@ -40,7 +40,8 @@
int
main (int __argc, char * __argv [])
{
if (__argc != 2) {
if (__argc != 2)
{
std :: cerr << "Usage : ./hill_climbing [instance]" << std :: endl ;
return 1 ;

View file

@ -38,7 +38,8 @@
#include "city_swap.h"
bool CitySwap :: operator () (Route & __route) {
bool CitySwap :: operator () (Route & __route)
{
std :: swap (__route [rng.random (__route.size ())],
__route [rng.random (__route.size ())]) ;

View file

@ -43,12 +43,13 @@
/** Its swaps two vertices
randomly choosen */
class CitySwap : public eoMonOp <Route> {
class CitySwap : public eoMonOp <Route>
{
public :
public :
bool operator () (Route & __route) ;
} ;
} ;
#endif

View file

@ -67,7 +67,7 @@ EdgeXover :: build_map (const Route & __par1, const Route & __par2)
void
EdgeXover :: remove_entry (unsigned int __vertex, std :: vector <std :: set <unsigned int> > & __map)
{
{
std :: set <unsigned int> & neigh = __map [__vertex] ;
@ -76,7 +76,7 @@ EdgeXover :: remove_entry (unsigned int __vertex, std :: vector <std :: set <uns
__map [* it].erase (__vertex) ;
}
}
}
void
EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
@ -87,7 +87,8 @@ EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
}
void
EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child) {
EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
{
build_map (__par1, __par2) ;
@ -100,7 +101,8 @@ EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
add_vertex (cur_vertex, __child) ;
for (unsigned int i = 1 ; i < len ; i ++) {
for (unsigned int i = 1 ; i < len ; i ++)
{
unsigned int len_min_entry = MAXINT ;

View file

@ -46,13 +46,13 @@
/** Edge Crossover */
class EdgeXover : public eoQuadOp <Route>
{
{
public :
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
private :
void cross (const Route & __par1, const Route & __par2, Route & __child) ; /* Binary */
@ -67,6 +67,6 @@ private :
std :: vector <bool> visited ; /* Vertices that are already visited */
} ;
} ;
#endif

View file

@ -40,7 +40,8 @@
#include "graph.h"
namespace Graph {
namespace Graph
{
static std :: vector <std :: pair <double, double> > vectCoord ; // Coordinates

View file

@ -41,7 +41,7 @@
#include <utility>
namespace Graph
{
{
void load (const char * __file_name) ;
/* Loading cities
(expressed by their coordinates)

View file

@ -43,15 +43,15 @@
/** Order Crossover */
class OrderXover : public eoQuadOp <Route>
{
{
public :
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
private :
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
} ;
} ;
#endif

View file

@ -37,7 +37,8 @@
#include "part_route_eval.h"
#include "graph.h"
PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to) {}
PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to)
{}
void PartRouteEval :: operator () (Route & __route)
{

View file

@ -43,20 +43,20 @@
/** Route Evaluator */
class PartRouteEval : public eoEvalFunc <Route>
{
{
public :
public :
/** Constructor */
PartRouteEval (float __from, float __to) ;
void operator () (Route & __route) ;
private :
private :
float from, to ;
} ;
} ;
#endif

View file

@ -43,12 +43,12 @@
/** It sets the first couple of edges */
class PartTwoOptInit : public moMoveInit <TwoOpt>
{
{
public :
public :
void operator () (TwoOpt & __move, const Route & __route) ;
} ;
} ;
#endif

View file

@ -42,12 +42,12 @@
/** It updates a couple of edges */
class PartTwoOptNext : public moNextMove <TwoOpt>
{
{
public :
public :
bool operator () (TwoOpt & __move, const Route & __route) ;
} ;
} ;
#endif

View file

@ -42,15 +42,16 @@
#include "route.h"
/** Partial Mapped Crossover */
class PartialMappedXover : public eoQuadOp <Route> {
class PartialMappedXover : public eoQuadOp <Route>
{
public :
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
private :
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
} ;
} ;
#endif

View file

@ -43,13 +43,13 @@
/** Route Evaluator */
class RouteEval : public eoEvalFunc <Route>
{
{
public :
public :
void operator () (Route & __route) ;
} ;
} ;
#endif

View file

@ -42,12 +42,12 @@
#include "route.h"
class RouteInit : public eoInit <Route>
{
{
public :
public :
void operator () (Route & __route) ;
} ;
} ;
#endif

View file

@ -37,12 +37,12 @@
#include "two_opt.h"
TwoOpt TwoOpt :: operator ! () const
{
{
TwoOpt move = * this ;
std :: swap (move.first, move.second) ;
return move ;
}
}
void TwoOpt :: operator () (Route & __route)
{
@ -67,6 +67,6 @@ void TwoOpt :: readFrom (std :: istream & __is)
}
void TwoOpt :: printOn (std :: ostream & __os) const
{
{
__os << first << ' ' << second ;
}
}

View file

@ -45,9 +45,9 @@
#include "route.h"
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned>, public eoPersistent
{
{
public :
public :
TwoOpt operator ! () const ;
@ -56,6 +56,6 @@ public :
void readFrom (std :: istream & __is) ;
void printOn (std :: ostream & __os) const ;
} ;
} ;
#endif

View file

@ -41,12 +41,12 @@
#include "two_opt.h"
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
{
{
public :
public :
float operator () (const TwoOpt & __move, const Route & __route) ;
} ;
} ;
#endif

View file

@ -43,12 +43,12 @@
/** It sets the first couple of edges */
class TwoOptInit : public moMoveInit <TwoOpt>
{
{
public :
public :
void operator () (TwoOpt & __move, const Route & __route) ;
} ;
} ;
#endif

View file

@ -42,12 +42,12 @@
/** It updates a couple of edges */
class TwoOptNext : public moNextMove <TwoOpt>
{
{
public :
public :
bool operator () (TwoOpt & __move, const Route & __route) ;
} ;
} ;
#endif

View file

@ -42,12 +42,12 @@
#include "two_opt.h"
class TwoOptRand : public moRandMove <TwoOpt>
{
{
public :
public :
void operator () (TwoOpt & __move) ;
} ;
} ;
#endif

View file

@ -64,9 +64,9 @@ bool TwoOptTabuList :: operator () (const TwoOpt & __move, const Route & __sol)
}
void TwoOptTabuList :: add (const TwoOpt & __move, const Route & __sol)
{
{
tabu_span [__move.first] [__move.second] = tabu_span [__move.second] [__move.first] = TABU_LENGTH ;
}
}
void TwoOptTabuList :: update ()
{

View file

@ -43,8 +43,8 @@
/** The table of tabu movements, i.e. forbidden edges */
class TwoOptTabuList : public moTabuList <TwoOpt>
{
public :
{
public :
bool operator () (const TwoOpt & __move, const Route & __sol) ;
@ -54,10 +54,10 @@ public :
void init () ;
private :
private :
std :: vector <std :: vector <unsigned> > tabu_span ;
} ;
} ;
#endif