paradiseo new mo added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1712 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:07:28 +00:00
commit d7496cafff
116 changed files with 12034 additions and 0 deletions

View file

@ -0,0 +1,170 @@
/*
<moCheckpoint.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moCheckpoint_h
#define moCheckpoint_h
#include <continuator/moContinuator.h>
#include <utils/eoMonitor.h>
#include <continuator/moStatBase.h>
#include <utils/eoUpdater.h>
/**
* Continuator allowing to add others (continuators, stats, monitors or updaters)
*/
template <class NH>
class moCheckpoint : public moContinuator<NH> {
public :
typedef NH Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
/**
* Default constructor (moCheckpoint must have at least one continuator)
* @param _cont a continuator
* @param _interval frequency to compute statistical operators
*/
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0){
continuators.push_back(&_cont);
}
/**
* add a continuator to the checkpoint
* @param _cont a continuator
*/
void add(moContinuator<Neighborhood>& _cont) {
continuators.push_back(&_cont);
}
/**
* add a statistic operator to the checkpoint
* @param _stat a statistic operator
*/
void add(moStatBase<EOT>& _stat) {
stats.push_back(&_stat);
}
/**
* add a monitor to the checkpoint
* @param _mon a monitor
*/
void add(eoMonitor& _mon) {
monitors.push_back(&_mon);
}
/**
* add a updater to the checkpoint
* @param _upd an updater
*/
void add(eoUpdater& _upd) {
updaters.push_back(&_upd);
}
/**
* init all continuators containing in the checkpoint regarding a solution
* @param _sol the corresponding solution
*/
virtual void init(EOT& _sol) {
for(unsigned i = 0; i < continuators.size(); ++i)
continuators[i]->init(_sol);
}
/**
* @return class name
*/
virtual std::string className(void) const {
return "moCheckpoint";
}
/**
* apply operator of checkpoint's containers
* @param _sol reference of the solution
* @return true if all continuator return true
*/
bool operator()(EOT & _sol) {
unsigned i;
bool bContinue = true;
for (i = 0; i < stats.size(); ++i){
if(counter % interval == 0)
(*stats[i])(_sol);
counter++;
}
for (i = 0; i < updaters.size(); ++i)
(*updaters[i])();
for (i = 0; i < monitors.size(); ++i)
(*monitors[i])();
for (i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_sol) )
bContinue = false;
return bContinue;
}
/**
* last call of statistic operators, monitors and updaters
* @param _sol reference of the solution
*/
void lastCall(EOT& _sol){
unsigned int i;
for (i = 0; i < stats.size(); ++i)
stats[i]->lastCall(_sol);
for (i = 0; i < updaters.size(); ++i)
updaters[i]->lastCall();
for (i = 0; i < monitors.size(); ++i)
monitors[i]->lastCall();
}
private :
/** continuators vector */
std::vector<moContinuator<Neighborhood>*> continuators;
/** statistic operators vector */
std::vector<moStatBase<EOT>*> stats;
/** monitors vector */
std::vector<eoMonitor*> monitors;
/** updaters vector */
std::vector<eoUpdater*> updaters;
unsigned int interval;
unsigned int counter;
};
#endif

View file

@ -0,0 +1,63 @@
/*
<moContinuator.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moContinuator_h
#define _moContinuator_h
#include <eoFunctor.h>
/**
* To make specific continuator from a solution
*/
template< class NH >
class moContinuator : public eoUF<typename NH::EOT &, bool>
{
public:
typedef NH Neighborhood ;
typedef typename Neighborhood::EOT EOT ;
/**
* Init Continuator parameters
* @param _solution the related solution
*/
virtual void init(EOT& _solution){};
/**
* Last Call to terminate the checkpoint
* @param _solution the related solution
*/
virtual void lastCall(EOT& _solution){};
};
#endif

View file

@ -0,0 +1,97 @@
/*
<moCounterMonitorSaver.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moCounterMonitorSaver_h
#define moCounterMonitorSaver_h
#include <utils/eoUpdater.h>
#include <utils/eoMonitor.h>
/**
* The actual class that will be used as base for all statistics
* that need to be calculated over the solution
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
*/
class moCounterMonitorSaver : public eoUpdater {
public :
/**
* Default Constructor
* @param _interval frequency to call monitors
* @param _mon a monitor
*/
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
monitors.push_back(&_mon);
}
/**
* call monitors if interval is reach by a counter
*/
void operator()(void) {
if (counter++ % interval == 0)
for (unsigned i = 0; i < monitors.size(); i++)
(*monitors[i])();
}
/**
* last call of monitors
*/
void lastCall(void) {
for (unsigned i = 0; i < monitors.size(); i++)
monitors[i]->lastCall();
}
/**
* attach another monitor to this class
* @param _mon the monitor to attach
*/
void add(eoMonitor& _mon) {
monitors.push_back(&_mon);
}
/**
* @return name of the class
*/
virtual std::string className(void) const { return "moCounterMonitorSaver"; }
private :
/** interval and counter value */
unsigned int interval, counter;
/** monitor's vector */
std::vector<eoMonitor*> monitors;
};
#endif

View file

@ -0,0 +1,83 @@
/*
<moDistanceStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moDistanceStat_h
#define moDistanceStat_h
#include <utils/eoDistance.h>
#include <continuator/moStat.h>
/**
* The statistic gives the distance to a reference solution
* The reference solution could be the global optimum, or the best knowed solution
* It allows to compute the Fitness-Distance correlation (FDC)
*/
template <class EOT, class T = double>
class moDistanceStat : public moStat<EOT, T>
{
public :
using moStat< EOT, T >::value;
/**
* Default Constructor
* @param _dist a distance
* @param _ref the reference solution
*/
moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref){}
/**
* Compute distance between a solution and the reference solution
* @param _sol a solution
*/
virtual void operator()(EOT & _sol){
value() = dist(_sol, refSolution);
}
/**
* @return name of the class
*/
virtual std::string className(void) const { return "moDistanceStat"; }
private:
/** the distance */
eoDistance<EOT> & dist;
/**
* the reference solution does not change during the run
* it could be the best solution knowed of the problem
*/
EOT refSolution;
};
#endif

View file

@ -0,0 +1,74 @@
/*
<moFitnessStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moFitnessStat_h
#define moFitnessStat_h
#include <continuator/moStat.h>
/**
* The actual class that will be used as base for all statistics
* that need to be calculated over the solution
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
*/
template <class EOT, class T=typename EOT::Fitness>
class moFitnessStat : public moStat<EOT, T>
{
public :
typedef T Fitness;
using moStat< EOT, Fitness >::value;
/**
* Default Constructor
* @param _description a description of the stat
*/
moFitnessStat(std::string _description = "fitness"):
moStat<EOT, Fitness>(Fitness(), _description){}
/**
* store fitness value
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol)
{
value() = _sol.fitness();
}
/**
* @return the name of the class
*/
virtual std::string className(void) const { return "moFitnessStat"; }
};
#endif

View file

@ -0,0 +1,78 @@
/*
<moMaxNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moMaxNeighborStat_h
#define moMaxNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
* From moNeighborhoodStat, to compute the max fitness in the neighborhood
*/
template< class Neighborhood >
class moMaxNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
/**
* Set the max fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getMax();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moMaxNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,78 @@
/*
<moMinNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moMinNeighborStat_h
#define moMinNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
* From moNeighborhoodStat, to compute the min fitness in the neighborhood
*/
template< class Neighborhood >
class moMinNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
/**
* Set the worst fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getMin();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moMinNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,81 @@
/*
<moNbInfNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moNbInfNeighborStat_h
#define moNbInfNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with (strictly) lower fitness than the current solution
*
*/
template< class Neighborhood >
class moNbInfNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbInf();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNbInfNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,81 @@
/*
<moNbSupNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moNbSupNeighborStat_h
#define moNbSupNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with higher fitness than the current solution
*
*/
template< class Neighborhood >
class moNbSupNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood with better fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbSup();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNbSupNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,235 @@
/*
<moNeighborhoodStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moNeighborhoodStat_h
#define moNeighborhoodStat_h
#include <continuator/moStat.h>
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
/**
* All possible statitic on the neighborhood fitness
* to combine with other specific statistic to print them
*/
template< class Neighborhood >
class moNeighborhoodStat : public moStat<typename Neighborhood::EOT, bool>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, bool >::value;
/**
* Default Constructor
* @param _neighborhood a neighborhood
* @param _eval an evaluation function
* @param _neighborComparator a neighbor Comparator
* @param _solNeighborComparator a comparator between a solution and a neighbor
*/
moNeighborhoodStat(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator):
moStat<EOT, bool>(true, "neighborhood"),
neighborhood(_neighborhood), eval(_eval),
neighborComparator(_neighborComparator),
solNeighborComparator(_solNeighborComparator)
{}
/**
* Compute classical statistics of a solution's neighborhood
* @param _solution the corresponding solution
*/
virtual void operator()(EOT & _solution){
Neighbor current ;
Neighbor best ;
Neighbor lowest ;
if(neighborhood.hasNeighbor(_solution)){
//init the first neighbor
neighborhood.init(_solution, current);
//eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, current);
// init the statistics
value() = true;
mean = current.fitness();
sd = mean * mean;
nb = 1;
nbInf = 0;
nbEqual = 0;
nbSup = 0;
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
//initialize the best neighbor
best = current;
lowest = current;
//test all others neighbors
while (neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, current);
//eval
eval(_solution, current);
mean += current.fitness();
sd += current.fitness() * current.fitness();
nb++;
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
//if we found a better neighbor, update the best
if (neighborComparator(best, current))
best = current;
if (neighborComparator(current, lowest))
lowest = current;
}
max = best.fitness();
min = lowest.fitness();
mean /= nb;
if (nb > 1)
sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) );
else
sd = 0.0;
}
else{
//if _solution hasn't neighbor,
value() = false;
}
}
/**
* @return the worst fitness value found in the neighborhood
*/
Fitness getMin(){
return min;
}
/**
* @return the best fitness value found in the neighborhood
*/
Fitness getMax(){
return max;
}
/**
* @return the mean fitness value of the neighborhood
*/
double getMean(){
return mean;
}
/**
* @return the standard deviation value of the neighborhood
*/
double getSD(){
return sd;
}
/**
* @return the size of the neighborhood
*/
unsigned getSize(){
return nb;
}
/**
* @return the number of neighbors having a better fitness than the current solution
*/
unsigned getNbSup(){
return nbSup;
}
/**
* @return the number of neighbors having the same fitness than the current solution
*/
unsigned getNbEqual(){
return nbEqual;
}
/**
* @return the number of neighbors having a worst fitness than the current solution
*/
unsigned getNbInf() {
return nbInf;
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNeighborhoodStat";
}
private:
// to explore the neighborhood
Neighborhood& neighborhood ;
moEval<Neighbor>& eval;
// comparator betwenn solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
// the stastics of the fitness
Fitness max, min;
//mean and standard deviation
double mean, sd ;
// number of neighbors in the neighborhood;
unsigned int nb;
// number of neighbors with lower, equal and higher fitness
unsigned int nbInf, nbEqual, nbSup ;
};
#endif

View file

@ -0,0 +1,80 @@
/*
<moNeutralDegreeNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moNeutralDegreeNeighborStat_h
#define moNeutralDegreeNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
* From moNeighborhoodStat, to compute the neutral degree of the solution
* which is the number of solutions in the neighborhood
* with equals fitness
*/
template< class Neighborhood >
class moNeutralDegreeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat){}
/**
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbEqual();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNeutralDegreeNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,79 @@
/*
<moSecondMomentNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moSecondMomentNeighborStat_h
#define moSecondMomentNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
* From moNeighborhoodStat, to compute the average and the standard deviation of fitness in the neighborhood
*/
template< class Neighborhood >
class moSecondMomentNeighborStat : public moStat<typename Neighborhood::EOT, std::pair<double, double> >
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, std::pair<double, double> >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat){}
/**
* Set the average and the standard deviation of fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value().first = nhStat.getMean();
value().second = nhStat.getSD();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moSecondMomentNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,79 @@
/*
<moSizeNeighborStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moSizeNeighborStat_h
#define moSizeNeighborStat_h
#include <continuator/moStat.h>
#include <continuator/moNeighborhoodStat.h>
/**
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
*
*/
template< class Neighborhood >
class moSizeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getSize();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moSizeNeighborStat"; }
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -0,0 +1,74 @@
/*
<moSolutionStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moSolutionStat_h
#define moSolutionStat_h
#include <continuator/moStat.h>
/**
* The statistic which only give the current solution
* be careful, the solution is given by copy
*
*/
template <class EOT>
class moSolutionStat : public moStat<EOT, EOT>
{
public :
using moStat< EOT, EOT >::value;
/**
* Default Constructor
* @param _description a description of the parameter
*/
moSolutionStat(std::string _description = "solution"):
moStat<EOT, EOT>(EOT(), _description){}
/**
* Set the solution by copy
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = _sol;
}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moSolutionStat";
}
};
#endif

View file

@ -0,0 +1,67 @@
/*
<moStat.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moStat_h
#define moStat_h
#include <continuator/moStatBase.h>
/**
* The actual class that will be used as base for all statistics
* that need to be calculated over the solution
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
*/
template <class EOT, class T>
class moStat : public eoValueParam<T>, public moStatBase<EOT>
{
public:
/**
* Default Constructor
* @param _value a default parameter's value
* @param _description a description of the parameter
*/
moStat(T _value, std::string _description):
eoValueParam<T>(_value, _description){}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moStat";
}
};
#endif

View file

@ -0,0 +1,65 @@
/*
<moStatBase.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moStatBase_h
#define moStatBase_h
#include <eoFunctor.h>
#include <utils/eoParam.h>
/**
* Base class for all statistics that need to be calculated
* over the solution
* (I guess it is not really necessary? MS.
* Depstd::ends, there might be reasons to have a stat that is not an eoValueParam,
* but maybe I'm just kidding myself, MK)
*/
template <class EOT>
class moStatBase : public eoUF<EOT &, void>
{
public:
/**
* last call of a statistical operator
*/
virtual void lastCall(EOT &) {}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moStatBase";
}
};
#endif

View file

@ -0,0 +1,68 @@
/*
<moTrueContinuator.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moTrueContinuator_h
#define _moTrueContinuator_h
#include <continuator/moContinuator.h>
/**
* Continuator always return True
*/
template< class NH >
class moTrueContinuator : public moContinuator<NH>
{
public:
typedef typename NH::EOT EOT ;
// empty constructor
moTrueContinuator() {} ;
/**
*@param _solution a solution
*@return always true
*/
virtual bool operator()(EOT & _solution) {
return true;
}
/**
* NOTHING TO DO
* @param _solution a solution
*/
virtual void init(EOT & _solution) {}
};
#endif