Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
40 changed files with 0 additions and 4096888 deletions
88
mo/src/continuator/moAverageFitnessNeighborStat.h
Normal file
88
mo/src/continuator/moAverageFitnessNeighborStat.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
<moAverageFitnessNeighborStat.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 moAverageFitnessNeighborStat_h
|
||||
#define moAverageFitnessNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the average of fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moAverageFitnessNeighborStat : public moStat<typename Neighbor::EOT, double >
|
||||
{
|
||||
public :
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, double >::value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moAverageFitnessNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||
moStat<EOT, double >(0.0, "average"), nhStat(_nhStat) {}
|
||||
|
||||
/**
|
||||
* Set the average of fitness in the neighborhood
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = nhStat.getMean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the average of fitness in the neighborhood
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
value() = nhStat.getMean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moAverageFitnessNeighborStat";
|
||||
}
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighbor> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
95
mo/src/continuator/moBestFitnessStat.h
Normal file
95
mo/src/continuator/moBestFitnessStat.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
<moBestFitnessStat.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 moBestFitnessStat_h
|
||||
#define moBestFitnessStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic which save the best solution found during the search
|
||||
*/
|
||||
template <class EOT>
|
||||
class moBestFitnessStat : public moStat<EOT, typename EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
using moStat< EOT , typename EOT::Fitness >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _reInitSol when true the best so far is reinitialized
|
||||
*/
|
||||
moBestFitnessStat(bool _reInitSol = true): moStat<EOT, typename EOT::Fitness>(Fitness(), "best"), reInitSol(_reInitSol), firstTime(true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the best solution on the first one
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
if (reInitSol)
|
||||
value() = _sol.fitness();
|
||||
else if (firstTime)
|
||||
{
|
||||
value() = _sol.fitness();
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the best solution
|
||||
* @param _sol the current solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
if (value() < _sol.fitness())
|
||||
{
|
||||
value() = _sol.fitness();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moBestFitnessStat";
|
||||
}
|
||||
|
||||
protected:
|
||||
bool reInitSol;
|
||||
bool firstTime;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
118
mo/src/continuator/moBestNoImproveContinuator.h
Normal file
118
mo/src/continuator/moBestNoImproveContinuator.h
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
<moBestNoImproveContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moBestNoImproveContinuator_h
|
||||
#define _moBestNoImproveContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <comparator/moSolComparator.h>
|
||||
|
||||
/**
|
||||
* Stop when the best solution cannot be improved
|
||||
* within a given number of iterations
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moBestNoImproveContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param _bestSol the best solution
|
||||
* @param _maxNoImprove number maximum of iterations
|
||||
* @param _solComparator a comparator between solutions
|
||||
* @param _verbose true/false : verbose mode on/off
|
||||
*/
|
||||
moBestNoImproveContinuator(const EOT & _bestSol,
|
||||
unsigned int _maxNoImprove,
|
||||
moSolComparator<EOT>& _solComparator,
|
||||
bool _verbose = true): bestSol(_bestSol), maxNoImprove(_maxNoImprove), solComparator(_solComparator), verbose(_verbose) {}
|
||||
|
||||
/**
|
||||
* Constructor where the comparator of solutions is the default comparator
|
||||
*
|
||||
* @param _bestSol the best solution
|
||||
* @param _maxNoImprove number maximum of iterations
|
||||
* @param _verbose true/false : verbose mode on/off
|
||||
*/
|
||||
moBestNoImproveContinuator(const EOT & _bestSol,
|
||||
unsigned int _maxNoImprove,
|
||||
bool _verbose = true): bestSol(_bestSol), maxNoImprove(_maxNoImprove), solComparator(defaultSolComp), verbose(_verbose) {}
|
||||
|
||||
/**
|
||||
* Count and test the number of non improvement of the best solution
|
||||
* improvement: if the current solution is STRICTLY better than the current best solution
|
||||
*
|
||||
*@param _solution a solution
|
||||
*@return true if counter < maxNoImprove
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
if (solComparator(_solution, bestSol) || solComparator.equals(_solution, bestSol))
|
||||
cpt++;
|
||||
else
|
||||
cpt = 0;
|
||||
|
||||
bool res = (cpt < maxNoImprove);
|
||||
|
||||
if (!res && verbose)
|
||||
std::cout << "STOP in moBestNoImproveContinuator: Reached maximum number of iterations without improvement [" << cpt << "/" << maxNoImprove << "]" << std::endl;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the counter of iteration
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
cpt = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* the current number of iteration without improvement
|
||||
* @return the number of iteration
|
||||
*/
|
||||
unsigned int value() {
|
||||
return cpt ;
|
||||
}
|
||||
|
||||
private:
|
||||
const EOT & bestSol;
|
||||
unsigned int maxNoImprove;
|
||||
unsigned int cpt;
|
||||
// comparator between solutions
|
||||
moSolComparator<EOT>& solComparator;
|
||||
bool verbose;
|
||||
moSolComparator<EOT> defaultSolComp;
|
||||
|
||||
};
|
||||
#endif
|
||||
94
mo/src/continuator/moBestSoFarStat.h
Normal file
94
mo/src/continuator/moBestSoFarStat.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
<moBestSoFarStat.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 moBestSoFarStat_h
|
||||
#define moBestSoFarStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic which save the best solution found during the search
|
||||
*/
|
||||
template <class EOT>
|
||||
class moBestSoFarStat : public moStat<EOT, EOT>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT , EOT >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _reInitSol when true the best so far is reinitialized
|
||||
*/
|
||||
moBestSoFarStat(bool _reInitSol = true): moStat<EOT, EOT>(EOT(), "best"), reInitSol(_reInitSol), firstTime(true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the best solution on the first one
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
if (reInitSol)
|
||||
value() = _sol;
|
||||
else if (firstTime)
|
||||
{
|
||||
value() = _sol;
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the best solution
|
||||
* @param _sol the current solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
if (value().fitness() < _sol.fitness())
|
||||
{
|
||||
value() = _sol;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moBestSoFarStat";
|
||||
}
|
||||
|
||||
protected:
|
||||
bool reInitSol;
|
||||
bool firstTime;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
82
mo/src/continuator/moBooleanStat.h
Normal file
82
mo/src/continuator/moBooleanStat.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
<moBooleanStat.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 moBooleanStat_h
|
||||
#define moBooleanStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic gives from a boolean variable
|
||||
*/
|
||||
template <class EOT>
|
||||
class moBooleanStat : public moStat<EOT, bool>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, bool>::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moBooleanStat(bool * _b): moStat<EOT, bool>(*_b, "boolean"), b(_b) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moBooleanStat";
|
||||
}
|
||||
|
||||
private:
|
||||
bool * b;
|
||||
};
|
||||
|
||||
#endif
|
||||
197
mo/src/continuator/moCheckpoint.h
Normal file
197
mo/src/continuator/moCheckpoint.h
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
<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>
|
||||
#include <continuator/moUpdater.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* Continuator allowing to add others (continuators, stats, monitors or updaters)
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moCheckpoint : public moContinuator<Neighbor> {
|
||||
public :
|
||||
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor (moCheckpoint must have at least one continuator)
|
||||
* @param _cont a continuator
|
||||
* @param _interval frequency to compute statistical operators
|
||||
*/
|
||||
moCheckpoint(moContinuator<Neighbor>& _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<Neighbor>& _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);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a MO updater to the checkpoint
|
||||
* @param _moupd an mo updater
|
||||
*/
|
||||
void add(moUpdater& _moupd) {
|
||||
moupdaters.push_back(&_moupd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 < stats.size(); ++i)
|
||||
stats[i]->init(_sol);
|
||||
counter=1;
|
||||
|
||||
for (unsigned i = 0; i < moupdaters.size(); ++i)
|
||||
moupdaters[i]->init();
|
||||
|
||||
for (unsigned int i = 0; i < monitors.size(); ++i)
|
||||
(*monitors[i])();
|
||||
|
||||
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 < moupdaters.size(); ++i)
|
||||
(*moupdaters[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 < moupdaters.size(); ++i)
|
||||
moupdaters[i]->lastCall();
|
||||
|
||||
for (i = 0; i < monitors.size(); ++i)
|
||||
monitors[i]->lastCall();
|
||||
}
|
||||
|
||||
private :
|
||||
/** continuators vector */
|
||||
std::vector<moContinuator<Neighbor>*> continuators;
|
||||
/** statistic operators vector */
|
||||
std::vector<moStatBase<EOT>*> stats;
|
||||
/** monitors vector */
|
||||
std::vector<eoMonitor*> monitors;
|
||||
/** updaters vector */
|
||||
std::vector<eoUpdater*> updaters;
|
||||
/** MO updaters vector */
|
||||
std::vector<moUpdater*> moupdaters;
|
||||
|
||||
unsigned int interval;
|
||||
unsigned int counter;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
93
mo/src/continuator/moCombinedContinuator.h
Normal file
93
mo/src/continuator/moCombinedContinuator.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
<moCombinedContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moCombinedContinuator_h
|
||||
#define _moCombinedContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* Combined several continuators.
|
||||
* Continue until one of the continuators returns false
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moCombinedContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor (moCheckpoint must have at least one continuator)
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
moCombinedContinuator(moContinuator<Neighbor>& _cont) {
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a continuator to the combined continuator
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
void add(moContinuator<Neighbor>& _cont) {
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
* init all continuators
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
for (unsigned int i = 0; i < continuators.size(); ++i)
|
||||
continuators[i]->init(_solution);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return true all the continuators are true
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
bool bContinue = true;
|
||||
|
||||
// some data may be update in each continuator.
|
||||
// So, all continuators are tested
|
||||
for (unsigned int i = 0; i < continuators.size(); ++i)
|
||||
if ( !(*continuators[i])(_solution) )
|
||||
bContinue = false;
|
||||
|
||||
return bContinue;
|
||||
}
|
||||
|
||||
private:
|
||||
/** continuators vector */
|
||||
std::vector< moContinuator<Neighbor>* > continuators;
|
||||
|
||||
};
|
||||
#endif
|
||||
64
mo/src/continuator/moContinuator.h
Normal file
64
mo/src/continuator/moContinuator.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
<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>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* To make specific continuator from a solution
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moContinuator : public eoUF<typename Neighbor::EOT &, bool>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename Neighbor::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
|
||||
97
mo/src/continuator/moCounterMonitorSaver.h
Normal file
97
mo/src/continuator/moCounterMonitorSaver.h
Normal 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>
|
||||
|
||||
/**
|
||||
* Class calling monitors with a given frequency
|
||||
*/
|
||||
class moCounterMonitorSaver : public eoUpdater {
|
||||
public :
|
||||
|
||||
/**
|
||||
* 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
|
||||
80
mo/src/continuator/moCounterStat.h
Normal file
80
mo/src/continuator/moCounterStat.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
<moCounterStat.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 moCounterStat_h
|
||||
#define moCounterStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic gives the number of iteration
|
||||
*/
|
||||
template <class EOT>
|
||||
class moCounterStat : public moStat<EOT, unsigned int>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, unsigned int>::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moCounterStat(): moStat<EOT, unsigned int>(0, "counter") {
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
value() = value() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moCounterStat";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
93
mo/src/continuator/moDistanceStat.h
Normal file
93
mo/src/continuator/moDistanceStat.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
<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;
|
||||
|
||||
/**
|
||||
* 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 the first solution and the reference solution
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = dist(_sol, refSolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
99
mo/src/continuator/moEvalsContinuator.h
Normal file
99
mo/src/continuator/moEvalsContinuator.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
<moEvalsContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moEvalsContinuator_h
|
||||
#define _moEvalsContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
#include <eval/moEvalCounter.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fixed number of full evaluation and neighbor evaluation is reached (total number of evaluation = full evaluation + incremental evaluation)
|
||||
*
|
||||
*
|
||||
* Becareful 1: if restartCounter is true, then the number of neighbor evaluations (for example incremental evaluations) is considered during the local search (not before it)
|
||||
*
|
||||
* Becareful 2: Can not be used if the evaluation function is used in parallel
|
||||
*
|
||||
* Becareful 3: Check if the incremental does not use full evaluation, otherwise the total number of evaluations is not correct
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moEvalsContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _fullEval full evaluation function to count
|
||||
* @param _neighborEval neighbor evaluation function to count
|
||||
* @param _maxEvals number maximum of evaluations (full and incremental evaluations)
|
||||
* @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative
|
||||
*/
|
||||
moEvalsContinuator(eoEvalFuncCounter<EOT> & _fullEval, moEvalCounter<Neighbor> & _neighborEval, unsigned int _maxEvals, bool _restartCounter = true): fullEval(_fullEval), neighborEval(_neighborEval), maxEvals(_maxEvals), restartCounter(_restartCounter) {}
|
||||
|
||||
/**
|
||||
* Test if continue
|
||||
* @param _solution a solution
|
||||
* @return true if number of evaluations < maxEvals
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (fullEval.value() + neighborEval.value() - nbEval_start < maxEvals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the number of evaluations
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
if (restartCounter)
|
||||
nbEval_start = fullEval.value() + neighborEval.value();
|
||||
else
|
||||
nbEval_start = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* the current number of evaluation from the begining
|
||||
* @return the number of evaluation
|
||||
*/
|
||||
unsigned int value() {
|
||||
return fullEval.value() + neighborEval.value() - nbEval_start ;
|
||||
}
|
||||
|
||||
private:
|
||||
eoEvalFuncCounter<EOT> & fullEval;
|
||||
moEvalCounter<Neighbor> & neighborEval;
|
||||
unsigned int maxEvals;
|
||||
bool restartCounter;
|
||||
unsigned int nbEval_start ;
|
||||
|
||||
};
|
||||
#endif
|
||||
63
mo/src/continuator/moFitContinuator.h
Normal file
63
mo/src/continuator/moFitContinuator.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<moFitContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moFitContinuator_h
|
||||
#define _moFitContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fitness is reached
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moFitContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
/**
|
||||
* @param _maxFit maximum fitness to reach
|
||||
*/
|
||||
moFitContinuator(Fitness _maxFit): maxFit(_maxFit) {}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return true if counter < maxFit
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (_solution.fitness() < maxFit);
|
||||
}
|
||||
|
||||
private:
|
||||
Fitness maxFit;
|
||||
|
||||
};
|
||||
#endif
|
||||
83
mo/src/continuator/moFitnessStat.h
Normal file
83
mo/src/continuator/moFitnessStat.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<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>
|
||||
|
||||
/**
|
||||
* Stat given the fitness of the current solution
|
||||
*/
|
||||
template <class EOT>
|
||||
class moFitnessStat : public moStat<EOT, typename EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _description a description of the stat
|
||||
*/
|
||||
moFitnessStat(std::string _description = "fitness"):
|
||||
moStat<EOT, Fitness>(Fitness(), _description) {}
|
||||
|
||||
/**
|
||||
* store the initial fitness value
|
||||
* @param _sol the initial solution
|
||||
*/
|
||||
virtual void init(EOT & _sol)
|
||||
{
|
||||
value() = _sol.fitness();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
96
mo/src/continuator/moFullEvalContinuator.h
Normal file
96
mo/src/continuator/moFullEvalContinuator.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
<moFullEvalContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moFullEvalContinuator_h
|
||||
#define _moFullEvalContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eoEvalFuncCounter.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fixed number of full evaluation is reached
|
||||
*
|
||||
*
|
||||
* Becareful 1: if restartCounter is true, then the number of full evaluations is considered during the local search (not before it)
|
||||
*
|
||||
* Becareful 2: Can not be used if the evaluation function is used in parallel
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moFullEvalContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _eval evaluation function to count
|
||||
* @param _maxFullEval number maximum of iterations
|
||||
* @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative
|
||||
*/
|
||||
moFullEvalContinuator(eoEvalFuncCounter<EOT> & _eval, unsigned int _maxFullEval, bool _restartCounter = true): eval(_eval), maxFullEval(_maxFullEval), restartCounter(_restartCounter) {
|
||||
nbEval_start = eval.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if continue
|
||||
* @param _solution a solution
|
||||
* @return true if number of evaluations < maxFullEval
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return (eval.value() - nbEval_start < maxFullEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the number of evaluations
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
if (restartCounter)
|
||||
nbEval_start = eval.value();
|
||||
else
|
||||
nbEval_start = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* the current number of evaluation from the begining
|
||||
* @return the number of evaluation
|
||||
*/
|
||||
unsigned int value() {
|
||||
return eval.value() - nbEval_start ;
|
||||
}
|
||||
|
||||
private:
|
||||
eoEvalFuncCounter<EOT> & eval;
|
||||
unsigned int nbEval_start ;
|
||||
bool restartCounter;
|
||||
unsigned int maxFullEval ;
|
||||
|
||||
};
|
||||
#endif
|
||||
86
mo/src/continuator/moIterContinuator.h
Normal file
86
mo/src/continuator/moIterContinuator.h
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
<moIterContinuator.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 ue,
|
||||
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".
|
||||
|
||||
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 _moIterContinuator_h
|
||||
#define _moIterContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* Continue until a maximum fixed number of iterations is reached
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moIterContinuator : public moContinuator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* @param _maxIter number maximum of iterations
|
||||
* @param _verbose true/false : verbose mode on/off
|
||||
*/
|
||||
moIterContinuator(unsigned int _maxIter, bool _verbose=true): maxIter(_maxIter), verbose(_verbose) {}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return true if counter < maxIter
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
bool res;
|
||||
cpt++;
|
||||
res = (cpt < maxIter);
|
||||
if (!res && verbose)
|
||||
std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the counter of iteration
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
cpt = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* the current number of iteration
|
||||
* @return the number of iteration
|
||||
*/
|
||||
unsigned int value() {
|
||||
return cpt ;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int maxIter;
|
||||
unsigned int cpt;
|
||||
bool verbose;
|
||||
|
||||
};
|
||||
#endif
|
||||
89
mo/src/continuator/moMaxNeighborStat.h
Normal file
89
mo/src/continuator/moMaxNeighborStat.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
<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>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the max fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moMaxNeighborStat : public moStat<typename Neighbor::EOT, typename Neighbor::EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moMaxNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
|
||||
|
||||
/**
|
||||
* Set the max fitness in the neighborhood
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = nhStat.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Neighbor> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
89
mo/src/continuator/moMinNeighborStat.h
Normal file
89
mo/src/continuator/moMinNeighborStat.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
<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>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the min fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moMinNeighborStat : public moStat<typename Neighbor::EOT, typename Neighbor::EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moMinNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
|
||||
|
||||
/**
|
||||
* Set the worst fitness in the neighborhood
|
||||
* @param _sol the first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = nhStat.getMin();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Neighbor> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
90
mo/src/continuator/moMinusOneCounterStat.h
Normal file
90
mo/src/continuator/moMinusOneCounterStat.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
<moMinusOneCounterStat.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 moMinusOneCounterStat_h
|
||||
#define moMinusOneCounterStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic gives the number of iteration minus 1
|
||||
* then the last iteration is not counted (for example for length of adaptive walk)
|
||||
*/
|
||||
template <class EOT>
|
||||
class moMinusOneCounterStat : public moStat<EOT, unsigned int>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, unsigned int>::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moMinusOneCounterStat(): moStat<EOT, unsigned int>(0, "counter") {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
counter = 0;
|
||||
value() = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of iteration
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
counter++;
|
||||
if (counter > 0)
|
||||
value() = counter - 1;
|
||||
else
|
||||
value() = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moMinusOneCounterStat";
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int counter;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
90
mo/src/continuator/moNbInfNeighborStat.h
Normal file
90
mo/src/continuator/moNbInfNeighborStat.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
<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>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
|
||||
* with (strictly) lower fitness than the current solution
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNbInfNeighborStat : public moStat<typename Neighbor::EOT, unsigned>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, unsigned >::value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moNbInfNeighborStat(moNeighborhoodStat<Neighbor> & _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 first solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = nhStat.getNbInf();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Neighbor> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue