moFitSolContinue, moSteadyFitSolContinue and moNoFitImprSolContinue are added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@582 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
bbe5e6f2b4
commit
0693358307
172 changed files with 3155 additions and 355 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include "moCoolingSchedule.h"
|
||||
#include "moExponentialCoolingSchedule.h"
|
||||
#include "moFirstImprSelect.h"
|
||||
#include "moFitSolContinue.h"
|
||||
#include "moGenSolContinue.h"
|
||||
#include "moHC.h"
|
||||
#include "moHCMoveLoopExpl.h"
|
||||
|
|
@ -33,12 +34,14 @@
|
|||
#include "moMoveSelect.h"
|
||||
#include "moNextMove.h"
|
||||
#include "moNoAspirCrit.h"
|
||||
#include "moNoFitImprSolContinue.h"
|
||||
#include "moRandImprSelect.h"
|
||||
#include "moRandMove.h"
|
||||
#include "moSA.h"
|
||||
#include "moSimpleMoveTabuList.h"
|
||||
#include "moSimpleSolutionTabuList.h"
|
||||
#include "moSolContinue.h"
|
||||
#include "moSteadyFitSolContinue.h"
|
||||
#include "moTabuList.h"
|
||||
#include "moTS.h"
|
||||
#include "moTSMoveLoopExpl.h"
|
||||
|
|
|
|||
75
trunk/paradiseo-mo/src/moFitSolContinue.h
Normal file
75
trunk/paradiseo-mo/src/moFitSolContinue.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "moFitSolContinue.h"
|
||||
|
||||
// (c) OPAC Team (LIFL), Dolphin project (INRIA), 2003-2007
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef __moFitSolContinue_h
|
||||
#define __moFitSolContinue_h
|
||||
|
||||
#include "moSolContinue.h"
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a fitness threshold gained.
|
||||
*/
|
||||
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param __fitness The fitness to reach.
|
||||
\param __maximization Indicate if the the aim is to maximize or minimize the fitness.
|
||||
*/
|
||||
moFitSolContinue (Fitness __fitness, bool __maximization=true): fitness (__fitness), maximization(__maximization)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness threshold has not been yet reached.
|
||||
|
||||
\param __sol the current solution.
|
||||
\return true or false according to the value of the fitness.
|
||||
*/
|
||||
bool operator () (const EOT & __sol)
|
||||
{
|
||||
if(__sol.invalid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(maximization)
|
||||
{
|
||||
return __sol.fitness()<fitness;
|
||||
}
|
||||
return __sol.fitness()>fitness;
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise all the stuff needed.
|
||||
void init ()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
//! Fitness target.
|
||||
Fitness fitness;
|
||||
|
||||
//! Flag that indicate if there is a maximization (true) or a minimization (false) of the fitness value.
|
||||
/*!
|
||||
It can be interesting to know this information because some solution-based metaheuristics can generate solution with a fitness that
|
||||
is worse that the best known fitness (in this case, the counter is not reinitialized).
|
||||
*/
|
||||
bool maximization;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "eoGenSolContinue.h"
|
||||
// "moGenSolContinue.h"
|
||||
|
||||
// (c) OPAC Team, LIFL, 2003-2006
|
||||
|
||||
|
|
@ -14,48 +14,39 @@
|
|||
|
||||
#include "moSolContinue.h"
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
//! One possible stopping criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a maximum number of iteration.
|
||||
The stopping criterion corresponds to a maximum number of iteration.
|
||||
*/
|
||||
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Simple constructor.
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param __maxNumGen the maximum number of generation.
|
||||
*/
|
||||
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Function that activates the stop criterion.
|
||||
/*!
|
||||
Increments the counter and returns TRUE if the
|
||||
Increments the counter and returns true if the
|
||||
current number of iteration is lower than the given
|
||||
maximum number of iterations.
|
||||
|
||||
\param __sol the current solution.
|
||||
\return TRUE or FALSE according to the current generation number.
|
||||
\return true or false according to the current generation number.
|
||||
*/
|
||||
bool operator () (const EOT & __sol)
|
||||
bool operator () (const EOT & __sol)
|
||||
{
|
||||
|
||||
return (++numGen < maxNumGen);
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise the generation counter.
|
||||
/*!
|
||||
It can also be used to reset the iteration counter.
|
||||
*/
|
||||
//! Procedure which allows to initialise all the stuff needed.
|
||||
void init ()
|
||||
{
|
||||
|
||||
numGen = 0;
|
||||
}
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
102
trunk/paradiseo-mo/src/moNoFitImprSolContinue.h
Normal file
102
trunk/paradiseo-mo/src/moNoFitImprSolContinue.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "moNoFitImprSolContinue.h"
|
||||
|
||||
// (c) OPAC Team (LIFL), Dolphin project (INRIA), 2003-2007
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef __moNoFitImprSolContinue_h
|
||||
#define __moNoFitImprSolContinue_h
|
||||
|
||||
#include "moSolContinue.h"
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a maximum number of iterations without improvement.
|
||||
*/
|
||||
template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param __maxNumberOfIterationWithoutImprovment The number of iterations without fitness improvment to reach for stop.
|
||||
\param __maximization Indicate if the the aim is to maximize or minimize the fitness.
|
||||
*/
|
||||
moNoFitImprSolContinue (unsigned int __maxNumberOfIterationWithoutImprovment, bool __maximization=true)
|
||||
: maxNumberOfIterationsWithoutImprovment(__maxNumberOfIterationWithoutImprovment),maximization(__maximization),
|
||||
firstFitnessSaved(true), counter(0)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness has not been improved since a given number of iterations (after a minimum of iterations).
|
||||
\param __sol the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & __sol)
|
||||
{
|
||||
if(__sol.invalid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(firstFitnessSaved)
|
||||
{
|
||||
fitness=__sol.fitness();
|
||||
counter=0;
|
||||
FirstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if( ((maximization) && (__sol.fitness() > fitness)) ||
|
||||
((!maximization) && (__sol.fitness() < fitness)) )
|
||||
{
|
||||
fitness=__sol.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if(counter==maxNumberOfIterationsWithoutImprovment)
|
||||
{
|
||||
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||
}
|
||||
return counter!=maxNumberOfIterationsWithoutImprovment;
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise all the stuff needed.
|
||||
void init ()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
//! Maximum number of iterations without improvment allowed.
|
||||
unsigned int maxNumberOfIterationsWithoutImprovment;
|
||||
|
||||
//! Flag that this is the first time that the fitness is used.
|
||||
bool firstFitnessSaved;
|
||||
|
||||
//! Current Fitness.
|
||||
Fitness fitness;
|
||||
|
||||
//! Flag that indicate if there is a maximization (true) or a minimization (false) of the fitness value.
|
||||
/*!
|
||||
It can be interesting to know this information because some solution-based metaheuristics can generate solutions wiht a fitness that
|
||||
is worse that the best known fitness (in this case, the counter is not reinitialized).
|
||||
*/
|
||||
bool maximization;
|
||||
|
||||
//! The iteration couter.
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Class that describes a stop criterion for a solution-based heuristic
|
||||
//! Class that describes a stopping criterion for a solution-based heuristic
|
||||
|
||||
/*!
|
||||
It allows to add an initialisation procedure to an object that is a unary function (eoUF).
|
||||
|
|
@ -23,7 +23,7 @@ template < class EOT > class moSolContinue:public eoUF < const EOT &, bool >
|
|||
{
|
||||
|
||||
public:
|
||||
//! Procedure which initialises all that the stop criterion needs
|
||||
//! Procedure which initialises all that the stopping criterion needs
|
||||
/*!
|
||||
Generally, it allocates some data structures or initialises some counters.
|
||||
*/
|
||||
|
|
|
|||
120
trunk/paradiseo-mo/src/moSteadyFitSolContinue.h
Normal file
120
trunk/paradiseo-mo/src/moSteadyFitSolContinue.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "moSteadyFitSolContinue.h"
|
||||
|
||||
// (c) OPAC Team (LIFL), Dolphin project (INRIA), 2003-2007
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef __moSteadyFitSolContinue_h
|
||||
#define __moSteadyFitSolContinue_h
|
||||
|
||||
#include "moSolContinue.h"
|
||||
|
||||
//! One possible stopping criterion for a solution-based heuristic.
|
||||
/*!
|
||||
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:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param __maxNumberOfIterations The number of iterations to reach before looking for the fitness.
|
||||
\param __maxNumberOfIterationWithoutImprovment The number of iterations without fitness improvment to reach for stop.
|
||||
\param __maximization Indicate if the the aim is to maximize or minimize the fitness.
|
||||
*/
|
||||
moSteadyFitSolContinue (unsigned int __maxNumberOfIterations, unsigned int __maxNumberOfIterationWithoutImprovment, bool __maximization=true)
|
||||
: maxNumberOfIterations (__maxNumberOfIterations), maxNumberOfIterationsWithoutImprovment(__maxNumberOfIterationWithoutImprovment),
|
||||
maximization(__maximization), maxNumberOfIterationsReached(false), firstFitnessSaved(true), counter(0)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness has not been improved since a number of iterations (after a minimum of iterations).
|
||||
|
||||
\param __sol the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & __sol)
|
||||
{
|
||||
if(!maxNumberOfIterationsReached)
|
||||
{
|
||||
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
||||
if(maxNumberOfIterationsReached)
|
||||
{
|
||||
std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(__sol.invalid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(firstFitnessSaved)
|
||||
{
|
||||
fitness=__sol.fitness();
|
||||
counter=0;
|
||||
FirstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if( ((maximization) && (__sol.fitness() > fitness)) ||
|
||||
((!maximization) && (__sol.fitness() < fitness)) )
|
||||
{
|
||||
fitness=__sol.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if(counter==maxNumberOfIterationsWithoutImprovment)
|
||||
{
|
||||
std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||
}
|
||||
return counter!=maxNumberOfIterationsWithoutImprovment;
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise the stuff needed.
|
||||
void init ()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
//! Maximum number of iterations before considering the fitness.
|
||||
unsigned int maxNumberOfIterations;
|
||||
|
||||
//! Maximum number of iterations without improvment allowed.
|
||||
unsigned int maxNumberOfIterationsWithoutImprovment;
|
||||
|
||||
//! Flag that indicates that the maxNumberIteration have been reached.
|
||||
bool maxNumberOfIterationsReached;
|
||||
|
||||
//! Flag that this is the first time that the fitness is used.
|
||||
bool firstFitnessSaved;
|
||||
|
||||
//! Current Fitness.
|
||||
Fitness fitness;
|
||||
|
||||
//! Flag that indicate if there is a maximization (true) or a minimization (false) of the fitness value.
|
||||
/*!
|
||||
It can be interesting to know this information because some solution-based metaheuristics can generate solution with a fitness that
|
||||
is worse that the best known fitness (in this case, the counter is not reinitialized).
|
||||
*/
|
||||
bool maximization;
|
||||
|
||||
//! The iteration couter.
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue