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

@ -1,4 +1,4 @@
/*
/*
* <moNoFitImprSolContinue.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,80 +44,80 @@
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 __maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
*/
moNoFitImprSolContinue (unsigned int __maxNumberOfIterationWithoutImprovement)
: maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement), 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++;
public:
if( __sol.fitness() > fitness)
{
fitness=__sol.fitness();
counter=0;
}
if(counter==maxNumberOfIterationsWithoutImprovement)
{
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
}
return counter!=maxNumberOfIterationsWithoutImprovement;
}
//! Alias for the fitness.
typedef typename EOT::Fitness Fitness;
//! Procedure which allows to initialise all the stuff needed.
/*!
It can be also used to reinitialize all the needed things.
*/
void init ()
{
firstFitnessSaved=true;
counter=0;
}
//! Basic constructor.
/*!
\param __maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
*/
moNoFitImprSolContinue (unsigned int __maxNumberOfIterationWithoutImprovement)
: maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement), firstFitnessSaved(true), counter(0)
{}
private:
//! 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;
}
//! Maximum number of iterations without improvement allowed.
unsigned int maxNumberOfIterationsWithoutImprovement;
if (firstFitnessSaved)
{
fitness=__sol.fitness();
counter=0;
firstFitnessSaved=false;
return true;
}
//! Flag that this is the first time that the fitness is used.
bool firstFitnessSaved;
counter++;
//! Current Fitness.
Fitness fitness;
if ( __sol.fitness() > fitness)
{
fitness=__sol.fitness();
counter=0;
}
//! The iteration couter.
unsigned int counter;
};
if (counter==maxNumberOfIterationsWithoutImprovement)
{
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
}
return counter!=maxNumberOfIterationsWithoutImprovement;
}
//! Procedure which allows to initialise all the stuff needed.
/*!
It can be also used to reinitialize all the needed things.
*/
void init ()
{
firstFitnessSaved=true;
counter=0;
}
private:
//! Maximum number of iterations without improvement allowed.
unsigned int maxNumberOfIterationsWithoutImprovement;
//! Flag that this is the first time that the fitness is used.
bool firstFitnessSaved;
//! Current Fitness.
Fitness fitness;
//! The iteration couter.
unsigned int counter;
};
#endif