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:
parent
47298125ec
commit
7161febf9c
80 changed files with 2014 additions and 2038 deletions
|
|
@ -44,8 +44,6 @@
|
||||||
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
|
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moAlgo:public eoMonOp < EOT >
|
template < class EOT > class moAlgo:public eoMonOp < EOT >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@
|
||||||
template < class M > class moAspirCrit:public eoBF < const M &, const typename
|
template < class M > class moAspirCrit:public eoBF < const M &, const typename
|
||||||
M::EOType::Fitness &,
|
M::EOType::Fitness &,
|
||||||
bool >
|
bool >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Procedure which initialises all that needs a aspiration criterion.
|
//! Procedure which initialises all that needs a aspiration criterion.
|
||||||
/*!
|
/*!
|
||||||
It can be possible that this procedure do nothing...
|
It can be possible that this procedure do nothing...
|
||||||
|
|
@ -57,6 +57,6 @@ public:
|
||||||
virtual void
|
virtual void
|
||||||
init () = 0;
|
init () = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
which enables the best improvement is selected.
|
which enables the best improvement is selected.
|
||||||
*/
|
*/
|
||||||
template < class M > class moBestImprSelect:public moMoveSelect < M >
|
template < class M > class moBestImprSelect:public moMoveSelect < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
@ -102,7 +102,7 @@ public:
|
||||||
throw EmptySelection ();
|
throw EmptySelection ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Allowing to know if at least one move has been generated.
|
//! Allowing to know if at least one move has been generated.
|
||||||
bool first_time;
|
bool first_time;
|
||||||
|
|
@ -113,6 +113,6 @@ private:
|
||||||
//! The best fitness.
|
//! The best fitness.
|
||||||
Fitness best_fit;
|
Fitness best_fit;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@
|
||||||
*/
|
*/
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class moComparator: public eoBF<const EOT&, const EOT&, bool>
|
class moComparator: public eoBF<const EOT&, const EOT&, bool>
|
||||||
{
|
{};
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@
|
||||||
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
|
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
|
||||||
*/
|
*/
|
||||||
class moCoolingSchedule:public eoUF < double &, bool >
|
class moCoolingSchedule:public eoUF < double &, bool >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
the temperature is greater than a given threshold.
|
the temperature is greater than a given threshold.
|
||||||
*/
|
*/
|
||||||
class moExponentialCoolingSchedule: public moCoolingSchedule
|
class moExponentialCoolingSchedule: public moCoolingSchedule
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Simple constructor
|
//! Simple constructor
|
||||||
/*!
|
/*!
|
||||||
\param __threshold the threshold.
|
\param __threshold the threshold.
|
||||||
|
|
@ -68,13 +68,13 @@ public:
|
||||||
return (__temp *= ratio) > threshold;
|
return (__temp *= ratio) > threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! The temperature threhold.
|
//! The temperature threhold.
|
||||||
double threshold;
|
double threshold;
|
||||||
|
|
||||||
//! The decreasing factor of the temperature.
|
//! The decreasing factor of the temperature.
|
||||||
double ratio;
|
double ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@
|
||||||
current solution.
|
current solution.
|
||||||
*/
|
*/
|
||||||
template < class M > class moFirstImprSelect:public moMoveSelect < M >
|
template < class M > class moFirstImprSelect:public moMoveSelect < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
@ -110,7 +110,7 @@ public:
|
||||||
throw EmptySelection ();
|
throw EmptySelection ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Allow to know if at least one move has improved the solution.
|
//! Allow to know if at least one move has improved the solution.
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
@ -124,6 +124,6 @@ private:
|
||||||
//! Best stored fitness.
|
//! Best stored fitness.
|
||||||
Fitness best_fit;
|
Fitness best_fit;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
*/
|
*/
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class moFitComparator: public moComparator<EOT>
|
class moFitComparator: public moComparator<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Function which makes the comparison and gives the result.
|
//! Function which makes the comparison and gives the result.
|
||||||
|
|
@ -56,6 +56,6 @@ class moFitComparator: public moComparator<EOT>
|
||||||
{
|
{
|
||||||
return _solution1.fitness()>_solution2.fitness();
|
return _solution1.fitness()>_solution2.fitness();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@
|
||||||
The stop criterion corresponds to a fitness threshold gained.
|
The stop criterion corresponds to a fitness threshold gained.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
|
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename EOT::Fitness Fitness;
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
@ -67,7 +67,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & __sol)
|
||||||
{
|
{
|
||||||
if(__sol.invalid())
|
if (__sol.invalid())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -82,10 +82,10 @@ public:
|
||||||
void init ()
|
void init ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Fitness target.
|
//! Fitness target.
|
||||||
Fitness fitness;
|
Fitness fitness;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,18 +44,16 @@
|
||||||
The stop criterion corresponds to a maximum number of iteration.
|
The stop criterion corresponds to a maximum number of iteration.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
|
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Simple constructor.
|
//! Simple constructor.
|
||||||
/*!
|
/*!
|
||||||
\param __maxNumGen the maximum number of generation.
|
\param __maxNumGen the maximum number of generation.
|
||||||
*/
|
*/
|
||||||
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
|
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Function that activates the stop criterion.
|
//! Function that activates the stop criterion.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -82,13 +80,13 @@ public:
|
||||||
numGen = 0;
|
numGen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Iteration maximum number.
|
//! Iteration maximum number.
|
||||||
unsigned int maxNumGen;
|
unsigned int maxNumGen;
|
||||||
|
|
||||||
//! Iteration current number.
|
//! Iteration current number.
|
||||||
unsigned int numGen;
|
unsigned int numGen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
Class which describes the algorithm for a hill climbing.
|
Class which describes the algorithm for a hill climbing.
|
||||||
*/
|
*/
|
||||||
template < class M > class moHC:public moAlgo < typename M::EOType >
|
template < class M > class moHC:public moAlgo < typename M::EOType >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Alias for the type.
|
//! Alias for the type.
|
||||||
typedef
|
typedef
|
||||||
|
|
@ -62,7 +62,7 @@ template < class M > class moHC:public moAlgo < typename M::EOType >
|
||||||
EOT::Fitness
|
EOT::Fitness
|
||||||
Fitness;
|
Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Full constructor.
|
//! Full constructor.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -74,12 +74,10 @@ public:
|
||||||
\param __move_select a move selector.
|
\param __move_select a move selector.
|
||||||
\param __full_eval a full evaluation function.
|
\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)),
|
(__move_init, __next_move, __incr_eval, __move_select)),
|
||||||
full_eval (__full_eval)
|
full_eval (__full_eval)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Light constructor.
|
//! Light constructor.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -88,12 +86,10 @@ moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEv
|
||||||
\param __move_expl a complete explorer.
|
\param __move_expl a complete explorer.
|
||||||
\param __full_eval a full evaluation function.
|
\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
|
||||||
(__full_eval)
|
(__full_eval)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Function which launches the HC
|
//! Function which launches the HC
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -145,13 +141,13 @@ moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Complete exploration of the neighborhood.
|
//! Complete exploration of the neighborhood.
|
||||||
moMoveExpl < M > &move_expl;
|
moMoveExpl < M > &move_expl;
|
||||||
|
|
||||||
//! A full evaluation function.
|
//! A full evaluation function.
|
||||||
eoEvalFunc < EOT > &full_eval;
|
eoEvalFunc < EOT > &full_eval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
//! Iterative explorer used by a moHC.
|
//! Iterative explorer used by a moHC.
|
||||||
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Alias for the type.
|
//! Alias for the type.
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
@ -54,7 +54,7 @@ template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -65,14 +65,12 @@ public:
|
||||||
\param __incr_eval (generally) efficient evaluation function.
|
\param __incr_eval (generally) efficient evaluation function.
|
||||||
\param __move_select the move selector.
|
\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),
|
move_init (__move_init),
|
||||||
next_move (__next_move),
|
next_move (__next_move),
|
||||||
incr_eval (__incr_eval), move_select (__move_select)
|
incr_eval (__incr_eval), move_select (__move_select)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which launches the explorer.
|
//! Procedure which launches the explorer.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -114,7 +112,7 @@ moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Move initialiser.
|
//! Move initialiser.
|
||||||
moMoveInit < M > &move_init;
|
moMoveInit < M > &move_init;
|
||||||
|
|
@ -128,6 +126,6 @@ private:
|
||||||
//! Move selector.
|
//! Move selector.
|
||||||
moMoveSelect < M > &move_select;
|
moMoveSelect < M > &move_select;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
Class which describes the algorithm for a iterated local search.
|
Class which describes the algorithm for a iterated local search.
|
||||||
*/
|
*/
|
||||||
template < class M > class moILS:public moAlgo < typename M::EOType >
|
template < class M > class moILS:public moAlgo < typename M::EOType >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Alias for the type.
|
//! Alias for the type.
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
@ -56,7 +56,7 @@ template < class M > class moILS:public moAlgo < typename M::EOType >
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename EOT::Fitness Fitness;
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Generic constructor
|
//! Generic constructor
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -152,7 +152,7 @@ public:
|
||||||
|
|
||||||
algo(__sol);
|
algo(__sol);
|
||||||
|
|
||||||
if(acceptance_criterion(__sol, __sol_saved))
|
if (acceptance_criterion(__sol, __sol_saved))
|
||||||
{
|
{
|
||||||
__sol_saved=__sol;
|
__sol_saved=__sol;
|
||||||
|
|
||||||
|
|
@ -169,7 +169,7 @@ public:
|
||||||
|
|
||||||
algo(__sol);
|
algo(__sol);
|
||||||
|
|
||||||
if(acceptance_criterion(__sol, __sol_saved))
|
if (acceptance_criterion(__sol, __sol_saved))
|
||||||
{
|
{
|
||||||
__sol_saved=__sol;
|
__sol_saved=__sol;
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +182,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! The solution based heuristic.
|
//! The solution based heuristic.
|
||||||
moAlgo<EOT> &algo;
|
moAlgo<EOT> &algo;
|
||||||
|
|
@ -198,6 +198,6 @@ private:
|
||||||
|
|
||||||
//! The full evaluation function
|
//! The full evaluation function
|
||||||
eoEvalFunc<EOT> &full_eval;
|
eoEvalFunc<EOT> &full_eval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
is the best ever considered.
|
is the best ever considered.
|
||||||
*/
|
*/
|
||||||
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
|
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness
|
//! Alias for the fitness
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
@ -97,13 +97,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Best fitness found until now
|
//! Best fitness found until now
|
||||||
Fitness best_fit;
|
Fitness best_fit;
|
||||||
|
|
||||||
//! Indicates that a fitness has been already saved or not
|
//! Indicates that a fitness has been already saved or not
|
||||||
bool first_time;
|
bool first_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,12 @@
|
||||||
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
||||||
*/
|
*/
|
||||||
template < class M > class moItRandNextMove:public moNextMove < M >
|
template < class M > class moItRandNextMove:public moNextMove < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Alias for the type.
|
//! Alias for the type.
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! The constructor.
|
//! The constructor.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -62,9 +62,7 @@ public:
|
||||||
moItRandNextMove (moRandMove < M > &__rand_move,
|
moItRandNextMove (moRandMove < M > &__rand_move,
|
||||||
unsigned int __max_iter):rand_move (__rand_move),
|
unsigned int __max_iter):rand_move (__rand_move),
|
||||||
max_iter (__max_iter), num_iter (0)
|
max_iter (__max_iter), num_iter (0)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Generation of a new move
|
//! Generation of a new move
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -93,7 +91,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! A move generator (generally randomly).
|
//! A move generator (generally randomly).
|
||||||
moRandMove < M > &rand_move;
|
moRandMove < M > &rand_move;
|
||||||
|
|
@ -104,6 +102,6 @@ private:
|
||||||
//! Iteration current number.
|
//! Iteration current number.
|
||||||
unsigned int num_iter;
|
unsigned int num_iter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
*/
|
*/
|
||||||
template < class M > class moLSCheckPoint:public eoBF < const M &, const typename
|
template < class M > class moLSCheckPoint:public eoBF < const M &, const typename
|
||||||
M::EOType &, void >
|
M::EOType &, void >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Function which launches the checkpointing
|
//! Function which launches the checkpointing
|
||||||
/*!
|
/*!
|
||||||
Each saved function is used on the current move and the current solution.
|
Each saved function is used on the current move and the current solution.
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
func.push_back (&__f);
|
func.push_back (&__f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! vector of function
|
//! vector of function
|
||||||
std::vector < eoBF < const
|
std::vector < eoBF < const
|
||||||
|
|
@ -86,6 +86,6 @@ private:
|
||||||
M::EOType &, void >*>
|
M::EOType &, void >*>
|
||||||
func;
|
func;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
the temperature is greater than a threshold.
|
the temperature is greater than a threshold.
|
||||||
*/
|
*/
|
||||||
class moLinearCoolingSchedule: public moCoolingSchedule
|
class moLinearCoolingSchedule: public moCoolingSchedule
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Simple constructor
|
//! Simple constructor
|
||||||
/*!
|
/*!
|
||||||
\param __threshold the threshold.
|
\param __threshold the threshold.
|
||||||
|
|
@ -68,13 +68,13 @@ public:
|
||||||
return (__temp -= quantity) > threshold;
|
return (__temp -= quantity) > threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! The temperature threhold.
|
//! The temperature threhold.
|
||||||
double threshold;
|
double threshold;
|
||||||
|
|
||||||
//! The quantity that allows the temperature to decrease.
|
//! The quantity that allows the temperature to decrease.
|
||||||
double quantity;
|
double quantity;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,12 @@
|
||||||
It describes how a solution can be modified to another one.
|
It describes how a solution can be modified to another one.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moMove:public eoUF < EOT &, void >
|
template < class EOT > class moMove:public eoUF < EOT &, void >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Alias for the type
|
//! Alias for the type
|
||||||
typedef EOT EOType;
|
typedef EOT EOType;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,7 @@
|
||||||
template < class M > class moMoveExpl:public eoBF < const typename
|
template < class M > class moMoveExpl:public eoBF < const typename
|
||||||
M::EOType &,
|
M::EOType &,
|
||||||
typename
|
typename
|
||||||
M::EOType &, void >
|
M::EOType &, void >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ template < class M > class moMoveIncrEval:public eoBF < const M &, const typenam
|
||||||
M::EOType &,
|
M::EOType &,
|
||||||
typename
|
typename
|
||||||
M::EOType::Fitness >
|
M::EOType::Fitness >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,7 @@
|
||||||
Only a description... An object that herits from this class needs to be designed to be used.
|
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
|
template < class M > class moMoveInit:public eoBF < M &, const typename
|
||||||
M::EOType &, void >
|
M::EOType &, void >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,6 @@
|
||||||
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
|
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
|
||||||
*/
|
*/
|
||||||
template < class M > class moMoveLoopExpl:public moMoveExpl < M >
|
template < class M > class moMoveLoopExpl:public moMoveExpl < M >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,7 @@
|
||||||
This class is used as an exception that can be thrown if a solution selector has completly failed.
|
This class is used as an exception that can be thrown if a solution selector has completly failed.
|
||||||
*/
|
*/
|
||||||
class EmptySelection
|
class EmptySelection
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Class that describes a move selector (moMove).
|
//! 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 &,
|
template < class M > class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &,
|
||||||
void >
|
void >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Alias for the fitness
|
//! Alias for the fitness
|
||||||
typedef
|
typedef
|
||||||
typename
|
typename
|
||||||
|
|
@ -85,6 +83,6 @@ public:
|
||||||
bool
|
bool
|
||||||
update (const M & __move, const Fitness & __fit) = 0;
|
update (const M & __move, const Fitness & __fit) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@
|
||||||
template < class M > class moNextMove:public eoBF < M &, const typename
|
template < class M > class moNextMove:public eoBF < M &, const typename
|
||||||
M::EOType &,
|
M::EOType &,
|
||||||
bool >
|
bool >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
The simplest : never satisfied.
|
The simplest : never satisfied.
|
||||||
*/
|
*/
|
||||||
template < class M > class moNoAspirCrit:public moAspirCrit < M >
|
template < class M > class moNoAspirCrit:public moAspirCrit < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Function which describes the aspiration criterion behaviour
|
//! Function which describes the aspiration criterion behaviour
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -66,8 +66,7 @@ template < class M > class moNoAspirCrit:public moAspirCrit < M >
|
||||||
Nothing...
|
Nothing...
|
||||||
*/
|
*/
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@
|
||||||
The stop criterion corresponds to a maximum number of iterations without improvement.
|
The stop criterion corresponds to a maximum number of iterations without improvement.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT >
|
template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename EOT::Fitness Fitness;
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
@ -67,12 +67,12 @@ public:
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & __sol)
|
||||||
{
|
{
|
||||||
if(__sol.invalid())
|
if (__sol.invalid())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstFitnessSaved)
|
if (firstFitnessSaved)
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
fitness=__sol.fitness();
|
||||||
counter=0;
|
counter=0;
|
||||||
|
|
@ -82,13 +82,13 @@ public:
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
if( __sol.fitness() > fitness)
|
if ( __sol.fitness() > fitness)
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
fitness=__sol.fitness();
|
||||||
counter=0;
|
counter=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(counter==maxNumberOfIterationsWithoutImprovement)
|
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||||
{
|
{
|
||||||
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +105,7 @@ public:
|
||||||
counter=0;
|
counter=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Maximum number of iterations without improvement allowed.
|
//! Maximum number of iterations without improvement allowed.
|
||||||
unsigned int maxNumberOfIterationsWithoutImprovement;
|
unsigned int maxNumberOfIterationsWithoutImprovement;
|
||||||
|
|
@ -118,6 +118,6 @@ private:
|
||||||
|
|
||||||
//! The iteration couter.
|
//! The iteration couter.
|
||||||
unsigned int counter;
|
unsigned int counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@
|
||||||
One of them that enables an improvment of the objective function is choosen.
|
One of them that enables an improvment of the objective function is choosen.
|
||||||
*/
|
*/
|
||||||
template < class M > class moRandImprSelect:public moMoveSelect < M >
|
template < class M > class moRandImprSelect:public moMoveSelect < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness
|
//! Alias for the fitness
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
@ -114,7 +114,7 @@ public:
|
||||||
throw EmptySelection ();
|
throw EmptySelection ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Fitness of the current solution.
|
//! Fitness of the current solution.
|
||||||
Fitness init_fit;
|
Fitness init_fit;
|
||||||
|
|
@ -124,6 +124,6 @@ private:
|
||||||
|
|
||||||
//! Candidate move vector.
|
//! Candidate move vector.
|
||||||
std::vector < M > vect_better_moves;
|
std::vector < M > vect_better_moves;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,6 @@
|
||||||
Only a description... An object that herits from this class needs to be designed in order to use a moSA.
|
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 >
|
template < class M > class moRandMove:public eoUF < M &, void >
|
||||||
{
|
{};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
Class that describes a Simulated Annealing algorithm.
|
Class that describes a Simulated Annealing algorithm.
|
||||||
*/
|
*/
|
||||||
template < class M > class moSA:public moAlgo < typename M::EOType >
|
template < class M > class moSA:public moAlgo < typename M::EOType >
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Alias for the type
|
//! Alias for the type
|
||||||
typedef
|
typedef
|
||||||
|
|
@ -67,7 +67,7 @@ template < class M > class moSA:public moAlgo < typename M::EOType >
|
||||||
EOT::Fitness
|
EOT::Fitness
|
||||||
Fitness;
|
Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! SA constructor
|
//! SA constructor
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -91,9 +91,7 @@ public:
|
||||||
init_temp (__init_temp),
|
init_temp (__init_temp),
|
||||||
cool_sched (__cool_sched),
|
cool_sched (__cool_sched),
|
||||||
full_eval (__full_eval)
|
full_eval (__full_eval)
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! function that launches the SA algorithm.
|
//! function that launches the SA algorithm.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -150,7 +148,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! A move generator (generally randomly)
|
//! A move generator (generally randomly)
|
||||||
moRandMove < M > &move_rand;
|
moRandMove < M > &move_rand;
|
||||||
|
|
@ -169,6 +167,6 @@ private:
|
||||||
|
|
||||||
//! A full evaluation function.
|
//! A full evaluation function.
|
||||||
eoEvalFunc < EOT > &full_eval; // Full evaluator.
|
eoEvalFunc < EOT > &full_eval; // Full evaluator.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
//! Class describing a move tabu list with a limited memory.
|
//! Class describing a move tabu list with a limited memory.
|
||||||
template <class M>
|
template <class M>
|
||||||
class moSimpleMoveTabuList: public moTabuList < M >
|
class moSimpleMoveTabuList: public moTabuList < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the type
|
//! Alias for the type
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
typename std::list<M>::iterator it;
|
typename std::list<M>::iterator it;
|
||||||
|
|
||||||
it=tabuList.begin();
|
it=tabuList.begin();
|
||||||
while(it!=tabuList.end()&&(!((*it)==__move)))
|
while (it!=tabuList.end()&&(!((*it)==__move)))
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +84,7 @@ public:
|
||||||
void
|
void
|
||||||
add (const M & __move, const EOT & __sol)
|
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.
|
// 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.
|
// In this case, the move can already be in the tabuList.
|
||||||
|
|
@ -93,7 +93,7 @@ public:
|
||||||
|
|
||||||
tabuList.push_back(__move);
|
tabuList.push_back(__move);
|
||||||
|
|
||||||
if(currentSize==maxSize)
|
if (currentSize==maxSize)
|
||||||
{
|
{
|
||||||
tabuList.erase(tabuList.begin());
|
tabuList.erase(tabuList.begin());
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +115,7 @@ public:
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Procedure that removes a given move from the tabu list (if it is into, else do nothing).
|
//! 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;
|
typename std::list<M>::iterator it;
|
||||||
|
|
||||||
it=tabuList.begin();
|
it=tabuList.begin();
|
||||||
while(it!=tabuList.end()&&(!((*it)==__move)))
|
while (it!=tabuList.end()&&(!((*it)==__move)))
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(it!=tabuList.end())
|
if (it!=tabuList.end())
|
||||||
{
|
{
|
||||||
tabuList.erase(it);
|
tabuList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
@ -146,6 +146,6 @@ private:
|
||||||
|
|
||||||
//! The move tabu list.
|
//! The move tabu list.
|
||||||
std::list<M> tabuList;
|
std::list<M> tabuList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
//! Class describing a solution tabu list with limited length.
|
//! Class describing a solution tabu list with limited length.
|
||||||
template <class M>
|
template <class M>
|
||||||
class moSimpleSolutionTabuList: public moTabuList < M >
|
class moSimpleSolutionTabuList: public moTabuList < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the type
|
//! Alias for the type
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
_move(_sol);
|
_move(_sol);
|
||||||
|
|
||||||
it=tabuList.begin();
|
it=tabuList.begin();
|
||||||
while(it!=tabuList.end()&&(!((*it)==_sol)))
|
while (it!=tabuList.end()&&(!((*it)==_sol)))
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ public:
|
||||||
|
|
||||||
_move(_sol);
|
_move(_sol);
|
||||||
|
|
||||||
if(currentSize!=0)
|
if (currentSize!=0)
|
||||||
{
|
{
|
||||||
// Useful in the case of a solution has been kept thanks to the moAspirCrit.
|
// 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.
|
// In this case, the solution can already be in the tabuList.
|
||||||
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
tabuList.push_back(_sol);
|
tabuList.push_back(_sol);
|
||||||
|
|
||||||
if(currentSize==maxSize)
|
if (currentSize==maxSize)
|
||||||
{
|
{
|
||||||
tabuList.erase(tabuList.begin());
|
tabuList.erase(tabuList.begin());
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ public:
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Procedure that removes a given solution from the tabu list (if it is into, else does nothing).
|
//! 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;
|
typename std::list<EOT>::iterator it;
|
||||||
|
|
||||||
it=tabuList.begin();
|
it=tabuList.begin();
|
||||||
while(it!=tabuList.end()&&(!((*it)==__sol)))
|
while (it!=tabuList.end()&&(!((*it)==__sol)))
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(it!=tabuList.end())
|
if (it!=tabuList.end())
|
||||||
{
|
{
|
||||||
tabuList.erase(it);
|
tabuList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
@ -155,6 +155,6 @@ private:
|
||||||
|
|
||||||
//! The solution tabu list.
|
//! The solution tabu list.
|
||||||
std::list<EOT> tabuList;
|
std::list<EOT> tabuList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,14 @@
|
||||||
It allows to add an initialisation procedure to an object that is a unary function (eoUF).
|
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 >
|
template < class EOT > class moSolContinue:public eoUF < const EOT &, bool >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Procedure which initialises all that the stop criterion needs
|
//! Procedure which initialises all that the stop criterion needs
|
||||||
/*!
|
/*!
|
||||||
Generally, it allocates some data structures or initialises some counters.
|
Generally, it allocates some data structures or initialises some counters.
|
||||||
*/
|
*/
|
||||||
virtual void init () = 0;
|
virtual void init () = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@
|
||||||
The stop criterion corresponds to a maximum number of iterations without improvement (after a minimum number of iterations).
|
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 >
|
template < class EOT > class moSteadyFitSolContinue:public moSolContinue < EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Alias for the fitness.
|
||||||
typedef typename EOT::Fitness Fitness;
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
@ -70,22 +70,22 @@ public:
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & __sol)
|
||||||
{
|
{
|
||||||
if(!maxNumberOfIterationsReached)
|
if (!maxNumberOfIterationsReached)
|
||||||
{
|
{
|
||||||
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
||||||
if(maxNumberOfIterationsReached)
|
if (maxNumberOfIterationsReached)
|
||||||
{
|
{
|
||||||
std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(__sol.invalid())
|
if (__sol.invalid())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstFitnessSaved)
|
if (firstFitnessSaved)
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
fitness=__sol.fitness();
|
||||||
counter=0;
|
counter=0;
|
||||||
|
|
@ -95,13 +95,13 @@ public:
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
if( __sol.fitness() > fitness )
|
if ( __sol.fitness() > fitness )
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
fitness=__sol.fitness();
|
||||||
counter=0;
|
counter=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(counter==maxNumberOfIterationsWithoutImprovement)
|
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||||
{
|
{
|
||||||
std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ public:
|
||||||
firstFitnessSaved=true;
|
firstFitnessSaved=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Maximum number of iterations before considering the fitness.
|
//! Maximum number of iterations before considering the fitness.
|
||||||
unsigned int maxNumberOfIterations;
|
unsigned int maxNumberOfIterations;
|
||||||
|
|
@ -138,6 +138,6 @@ private:
|
||||||
|
|
||||||
//! The iteration couter.
|
//! The iteration couter.
|
||||||
unsigned int counter;
|
unsigned int counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
Generic algorithm that describes a tabu search.
|
Generic algorithm that describes a tabu search.
|
||||||
*/
|
*/
|
||||||
template < class M > class moTS:public moAlgo < typename M::EOType >
|
template < class M > class moTS:public moAlgo < typename M::EOType >
|
||||||
{
|
{
|
||||||
|
|
||||||
//!Alias for the type
|
//!Alias for the type
|
||||||
typedef
|
typedef
|
||||||
|
|
@ -66,7 +66,7 @@ template < class M > class moTS:public moAlgo < typename M::EOType >
|
||||||
EOT::Fitness
|
EOT::Fitness
|
||||||
Fitness;
|
Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//!Constructor of a moTS specifying all the boxes
|
//!Constructor of a moTS specifying all the boxes
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
\param __cont stop criterion
|
\param __cont stop criterion
|
||||||
\param __full_eval full evaluation function
|
\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,
|
(__move_init, __next_move, __incr_eval, __tabu_list,
|
||||||
__aspir_crit)), cont (__cont), full_eval (__full_eval)
|
__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 __cont stop criterion
|
||||||
\param __full_eval full evaluation function
|
\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),
|
cont (__cont),
|
||||||
full_eval (__full_eval)
|
full_eval (__full_eval)
|
||||||
{}
|
{}
|
||||||
|
|
@ -154,7 +154,7 @@ moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc <
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Neighborhood explorer
|
//! Neighborhood explorer
|
||||||
moMoveExpl < M > &move_expl;
|
moMoveExpl < M > &move_expl;
|
||||||
|
|
@ -164,6 +164,6 @@ private:
|
||||||
|
|
||||||
//! Full evaluation function
|
//! Full evaluation function
|
||||||
eoEvalFunc < EOT > &full_eval;
|
eoEvalFunc < EOT > &full_eval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
It is used by a moTS.
|
It is used by a moTS.
|
||||||
*/
|
*/
|
||||||
template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
|
template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
|
||||||
{
|
{
|
||||||
|
|
||||||
//!Alias for the type
|
//!Alias for the type
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
@ -61,7 +61,7 @@ template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
|
||||||
//!Alias for the fitness
|
//!Alias for the fitness
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//!Constructor
|
//!Constructor
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
\param __tabu_list tabu list
|
\param __tabu_list tabu list
|
||||||
\param __aspir_crit aspiration criterion
|
\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),
|
move_init (__move_init),
|
||||||
next_move (__next_move),
|
next_move (__next_move),
|
||||||
incr_eval (__incr_eval),
|
incr_eval (__incr_eval),
|
||||||
|
|
@ -133,7 +133,7 @@ moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
|
||||||
tabu_list.add (best_move, __new_sol);
|
tabu_list.add (best_move, __new_sol);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//!Move initialisation
|
//!Move initialisation
|
||||||
moMoveInit < M > &move_init;
|
moMoveInit < M > &move_init;
|
||||||
|
|
@ -152,6 +152,6 @@ private:
|
||||||
|
|
||||||
//!Aspiration criterion
|
//!Aspiration criterion
|
||||||
moAspirCrit < M > &aspir_crit;
|
moAspirCrit < M > &aspir_crit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@
|
||||||
template < class M > class moTabuList:public eoBF < const M &, const typename
|
template < class M > class moTabuList:public eoBF < const M &, const typename
|
||||||
M::EOType &,
|
M::EOType &,
|
||||||
bool >
|
bool >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Alias for the type
|
//! Alias for the type
|
||||||
typedef typename M::EOType EOT;
|
typedef typename M::EOType EOT;
|
||||||
|
|
||||||
|
|
@ -76,6 +76,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
init () = 0;
|
init () = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
int
|
int
|
||||||
main (int __argc, char * __argv [])
|
main (int __argc, char * __argv [])
|
||||||
{
|
{
|
||||||
if (__argc != 2) {
|
if (__argc != 2)
|
||||||
|
{
|
||||||
|
|
||||||
std :: cerr << "Usage : ./hill_climbing [instance]" << std :: endl ;
|
std :: cerr << "Usage : ./hill_climbing [instance]" << std :: endl ;
|
||||||
return 1 ;
|
return 1 ;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
|
|
||||||
#include "city_swap.h"
|
#include "city_swap.h"
|
||||||
|
|
||||||
bool CitySwap :: operator () (Route & __route) {
|
bool CitySwap :: operator () (Route & __route)
|
||||||
|
{
|
||||||
|
|
||||||
std :: swap (__route [rng.random (__route.size ())],
|
std :: swap (__route [rng.random (__route.size ())],
|
||||||
__route [rng.random (__route.size ())]) ;
|
__route [rng.random (__route.size ())]) ;
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,13 @@
|
||||||
|
|
||||||
/** Its swaps two vertices
|
/** Its swaps two vertices
|
||||||
randomly choosen */
|
randomly choosen */
|
||||||
class CitySwap : public eoMonOp <Route> {
|
class CitySwap : public eoMonOp <Route>
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (Route & __route) ;
|
bool operator () (Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ EdgeXover :: build_map (const Route & __par1, const Route & __par2)
|
||||||
|
|
||||||
void
|
void
|
||||||
EdgeXover :: remove_entry (unsigned int __vertex, std :: vector <std :: set <unsigned int> > & __map)
|
EdgeXover :: remove_entry (unsigned int __vertex, std :: vector <std :: set <unsigned int> > & __map)
|
||||||
{
|
{
|
||||||
|
|
||||||
std :: set <unsigned int> & neigh = __map [__vertex] ;
|
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) ;
|
__map [* it].erase (__vertex) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
|
EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
|
||||||
|
|
@ -87,7 +87,8 @@ EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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) ;
|
build_map (__par1, __par2) ;
|
||||||
|
|
||||||
|
|
@ -100,7 +101,8 @@ EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
|
||||||
|
|
||||||
add_vertex (cur_vertex, __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 ;
|
unsigned int len_min_entry = MAXINT ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,13 @@
|
||||||
|
|
||||||
/** Edge Crossover */
|
/** Edge Crossover */
|
||||||
class EdgeXover : public eoQuadOp <Route>
|
class EdgeXover : public eoQuadOp <Route>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (Route & __route1, Route & __route2) ;
|
bool operator () (Route & __route1, Route & __route2) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
void cross (const Route & __par1, const Route & __par2, Route & __child) ; /* Binary */
|
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 */
|
std :: vector <bool> visited ; /* Vertices that are already visited */
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
|
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
namespace Graph {
|
namespace Graph
|
||||||
|
{
|
||||||
|
|
||||||
static std :: vector <std :: pair <double, double> > vectCoord ; // Coordinates
|
static std :: vector <std :: pair <double, double> > vectCoord ; // Coordinates
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace Graph
|
namespace Graph
|
||||||
{
|
{
|
||||||
void load (const char * __file_name) ;
|
void load (const char * __file_name) ;
|
||||||
/* Loading cities
|
/* Loading cities
|
||||||
(expressed by their coordinates)
|
(expressed by their coordinates)
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,15 @@
|
||||||
|
|
||||||
/** Order Crossover */
|
/** Order Crossover */
|
||||||
class OrderXover : public eoQuadOp <Route>
|
class OrderXover : public eoQuadOp <Route>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (Route & __route1, Route & __route2) ;
|
bool operator () (Route & __route1, Route & __route2) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
|
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
#include "part_route_eval.h"
|
#include "part_route_eval.h"
|
||||||
#include "graph.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)
|
void PartRouteEval :: operator () (Route & __route)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,20 +43,20 @@
|
||||||
|
|
||||||
/** Route Evaluator */
|
/** Route Evaluator */
|
||||||
class PartRouteEval : public eoEvalFunc <Route>
|
class PartRouteEval : public eoEvalFunc <Route>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
PartRouteEval (float __from, float __to) ;
|
PartRouteEval (float __from, float __to) ;
|
||||||
|
|
||||||
void operator () (Route & __route) ;
|
void operator () (Route & __route) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
float from, to ;
|
float from, to ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
/** It sets the first couple of edges */
|
/** It sets the first couple of edges */
|
||||||
class PartTwoOptInit : public moMoveInit <TwoOpt>
|
class PartTwoOptInit : public moMoveInit <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
void operator () (TwoOpt & __move, const Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@
|
||||||
|
|
||||||
/** It updates a couple of edges */
|
/** It updates a couple of edges */
|
||||||
class PartTwoOptNext : public moNextMove <TwoOpt>
|
class PartTwoOptNext : public moNextMove <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (TwoOpt & __move, const Route & __route) ;
|
bool operator () (TwoOpt & __move, const Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,16 @@
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
|
||||||
/** Partial Mapped Crossover */
|
/** Partial Mapped Crossover */
|
||||||
class PartialMappedXover : public eoQuadOp <Route> {
|
class PartialMappedXover : public eoQuadOp <Route>
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (Route & __route1, Route & __route2) ;
|
bool operator () (Route & __route1, Route & __route2) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
|
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,13 @@
|
||||||
|
|
||||||
/** Route Evaluator */
|
/** Route Evaluator */
|
||||||
class RouteEval : public eoEvalFunc <Route>
|
class RouteEval : public eoEvalFunc <Route>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (Route & __route) ;
|
void operator () (Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
|
||||||
class RouteInit : public eoInit <Route>
|
class RouteInit : public eoInit <Route>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (Route & __route) ;
|
void operator () (Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@
|
||||||
#include "two_opt.h"
|
#include "two_opt.h"
|
||||||
|
|
||||||
TwoOpt TwoOpt :: operator ! () const
|
TwoOpt TwoOpt :: operator ! () const
|
||||||
{
|
{
|
||||||
TwoOpt move = * this ;
|
TwoOpt move = * this ;
|
||||||
std :: swap (move.first, move.second) ;
|
std :: swap (move.first, move.second) ;
|
||||||
|
|
||||||
return move ;
|
return move ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOpt :: operator () (Route & __route)
|
void TwoOpt :: operator () (Route & __route)
|
||||||
{
|
{
|
||||||
|
|
@ -67,6 +67,6 @@ void TwoOpt :: readFrom (std :: istream & __is)
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOpt :: printOn (std :: ostream & __os) const
|
void TwoOpt :: printOn (std :: ostream & __os) const
|
||||||
{
|
{
|
||||||
__os << first << ' ' << second ;
|
__os << first << ' ' << second ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
|
||||||
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned>, public eoPersistent
|
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned>, public eoPersistent
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
TwoOpt operator ! () const ;
|
TwoOpt operator ! () const ;
|
||||||
|
|
||||||
|
|
@ -56,6 +56,6 @@ public :
|
||||||
void readFrom (std :: istream & __is) ;
|
void readFrom (std :: istream & __is) ;
|
||||||
|
|
||||||
void printOn (std :: ostream & __os) const ;
|
void printOn (std :: ostream & __os) const ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,12 @@
|
||||||
#include "two_opt.h"
|
#include "two_opt.h"
|
||||||
|
|
||||||
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
|
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
float operator () (const TwoOpt & __move, const Route & __route) ;
|
float operator () (const TwoOpt & __move, const Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
/** It sets the first couple of edges */
|
/** It sets the first couple of edges */
|
||||||
class TwoOptInit : public moMoveInit <TwoOpt>
|
class TwoOptInit : public moMoveInit <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
void operator () (TwoOpt & __move, const Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@
|
||||||
|
|
||||||
/** It updates a couple of edges */
|
/** It updates a couple of edges */
|
||||||
class TwoOptNext : public moNextMove <TwoOpt>
|
class TwoOptNext : public moNextMove <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (TwoOpt & __move, const Route & __route) ;
|
bool operator () (TwoOpt & __move, const Route & __route) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@
|
||||||
#include "two_opt.h"
|
#include "two_opt.h"
|
||||||
|
|
||||||
class TwoOptRand : public moRandMove <TwoOpt>
|
class TwoOptRand : public moRandMove <TwoOpt>
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void operator () (TwoOpt & __move) ;
|
void operator () (TwoOpt & __move) ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ bool TwoOptTabuList :: operator () (const TwoOpt & __move, const Route & __sol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOptTabuList :: add (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 ;
|
tabu_span [__move.first] [__move.second] = tabu_span [__move.second] [__move.first] = TABU_LENGTH ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoOptTabuList :: update ()
|
void TwoOptTabuList :: update ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@
|
||||||
|
|
||||||
/** The table of tabu movements, i.e. forbidden edges */
|
/** The table of tabu movements, i.e. forbidden edges */
|
||||||
class TwoOptTabuList : public moTabuList <TwoOpt>
|
class TwoOptTabuList : public moTabuList <TwoOpt>
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool operator () (const TwoOpt & __move, const Route & __sol) ;
|
bool operator () (const TwoOpt & __move, const Route & __sol) ;
|
||||||
|
|
||||||
|
|
@ -54,10 +54,10 @@ public :
|
||||||
|
|
||||||
void init () ;
|
void init () ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
std :: vector <std :: vector <unsigned> > tabu_span ;
|
std :: vector <std :: vector <unsigned> > tabu_span ;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue