Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
110
mo/src/sampling/moAdaptiveWalkSampling.h
Normal file
110
mo/src/sampling/moAdaptiveWalkSampling.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
<moAdaptiveWalkSampling.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 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 moAdaptiveWalkSampling_h
|
||||
#define moAdaptiveWalkSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <continuator/moCheckpoint.h>
|
||||
#include <perturb/moLocalSearchInit.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <algo/moFirstImprHC.h>
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include <continuator/moMinusOneCounterStat.h>
|
||||
#include <continuator/moStatFromStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the length and final solution of an adaptive walk:
|
||||
* Perform a first improvement Hill-climber based on the neighborhood (adaptive walk),
|
||||
* The lengths of HC are collected and the final solution which are local optima
|
||||
* The adaptive walk is repeated several times
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moAdaptiveWalkSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood giving neighbor in random order
|
||||
* @param _fullEval a full evaluation function
|
||||
* @param _eval an incremental evaluation of neighbors
|
||||
* @param _nbAdaptWalk Number of adaptive walks
|
||||
*/
|
||||
moAdaptiveWalkSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbAdaptWalk) :
|
||||
moSampling<Neighbor>(initHC, * new moRandomSearch<Neighbor>(initHC, _fullEval, _nbAdaptWalk), copyStat),
|
||||
copyStat(lengthStat),
|
||||
checkpoint(trueCont),
|
||||
hc(_neighborhood, _fullEval, _eval, checkpoint),
|
||||
initHC(_init, hc)
|
||||
{
|
||||
// to count the number of step in the HC
|
||||
checkpoint.add(lengthStat);
|
||||
|
||||
// add the solution into statistics
|
||||
this->add(solStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moAdaptiveWalkSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moSolutionStat<EOT> solStat;
|
||||
moMinusOneCounterStat<EOT> lengthStat;
|
||||
moTrueContinuator<Neighbor> trueCont;
|
||||
moStatFromStat<EOT, unsigned int> copyStat;
|
||||
moCheckpoint<Neighbor> checkpoint;
|
||||
moFirstImprHC<Neighbor> hc;
|
||||
moLocalSearchInit<Neighbor> initHC;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
89
mo/src/sampling/moAutocorrelationSampling.h
Normal file
89
mo/src/sampling/moAutocorrelationSampling.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
<moAutocorrelationSampling.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 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 moAutocorrelationSampling_h
|
||||
#define moAutocorrelationSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomWalk.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the autocorrelation function:
|
||||
* Perform a random walk based on the neighborhood,
|
||||
* The fitness values of solutions are collected during the random walk
|
||||
* The autocorrelation can be computed from the serie of fitness values
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moAutocorrelationSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood giving neighbor in random order
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbStep Number of steps of the random walk
|
||||
*/
|
||||
moAutocorrelationSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbStep) :
|
||||
moSampling<Neighbor>(_init, * new moRandomWalk<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moAutocorrelationSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
83
mo/src/sampling/moDensityOfStatesSampling.h
Normal file
83
mo/src/sampling/moDensityOfStatesSampling.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<moDensityOfStatesSampling.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 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 moDensityOfStatesSampling_h
|
||||
#define moDensityOfStatesSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the density of states:
|
||||
* Sample the fitness of random solution in the search space
|
||||
* The fitness values of solutions are collected during the random search
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moDensityOfStatesSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moDensityOfStatesSampling(eoInit<EOT> & _init,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat) {}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moDensityOfStatesSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
95
mo/src/sampling/moFDCsampling.h
Normal file
95
mo/src/sampling/moFDCsampling.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
<moFDCsampling.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 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 moFDCsampling_h
|
||||
#define moFDCsampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <utils/eoDistance.h>
|
||||
#include <continuator/moDistanceStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the fitness distance correlation:
|
||||
* Sample the fitness and the distance from a particular solution of random solution in the search space
|
||||
* The fitness values and distances of solutions are collected during the random search
|
||||
* Then the correlation between the fitness and the distance can be computed
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moFDCsampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _fullEval a full evaluation function
|
||||
* @param _dist the distance function between solution
|
||||
* @param _refSol the reference solution to compute the distance (think of global optimum when possible)
|
||||
* @param _nbSol Number of solutions of the sample
|
||||
*/
|
||||
moFDCsampling(eoInit<EOT> & _init,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
eoDistance<EOT>& _dist,
|
||||
EOT& _refSol,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat),
|
||||
distStat(_dist, _refSol)
|
||||
{
|
||||
this->add(distStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moFDCsampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
moDistanceStat<EOT> distStat;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
100
mo/src/sampling/moFitnessCloudSampling.h
Normal file
100
mo/src/sampling/moFitnessCloudSampling.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
<moFitnessCloudSampling.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 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 moFitnessCloudSampling_h
|
||||
#define moFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moDummyLS.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <continuator/moNeighborFitnessStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* This class do nothing. See others mo(...)FitnessCloudSampling classes
|
||||
* with different fitness sampling methods
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moFitnessCloudSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to get a neighbor
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moDummyLS<Neighbor>(_fullEval), fitnessStat),
|
||||
neighborhood(_neighborhood),
|
||||
fullEval(_fullEval),
|
||||
eval(_eval),
|
||||
nbSol(_nbSol)
|
||||
{}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moFitnessCloudSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborhood<Neighbor> & neighborhood;
|
||||
eoEvalFunc<EOT>& fullEval;
|
||||
moEval<Neighbor>& eval;
|
||||
unsigned int nbSol;
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
110
mo/src/sampling/moHillClimberSampling.h
Normal file
110
mo/src/sampling/moHillClimberSampling.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
<moHillClimberSampling.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 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 moHillClimberSampling_h
|
||||
#define moHillClimberSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <continuator/moCheckpoint.h>
|
||||
#include <perturb/moLocalSearchInit.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <algo/moSimpleHC.h>
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include <continuator/moMinusOneCounterStat.h>
|
||||
#include <continuator/moStatFromStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the length and final solution of an adaptive walk:
|
||||
* Perform a simple Hill-climber based on the neighborhood (gradiant walk, the whole neighborhood is visited),
|
||||
* The lengths of HC are collected and the final solution which are local optima
|
||||
* The adaptive walk is repeated several times
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moHillClimberSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood giving neighbor in random order
|
||||
* @param _fullEval a full evaluation function
|
||||
* @param _eval an incremental evaluation of neighbors
|
||||
* @param _nbAdaptWalk Number of adaptive walks
|
||||
*/
|
||||
moHillClimberSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbAdaptWalk) :
|
||||
moSampling<Neighbor>(initHC, * new moRandomSearch<Neighbor>(initHC, _fullEval, _nbAdaptWalk), copyStat),
|
||||
copyStat(lengthStat),
|
||||
checkpoint(trueCont),
|
||||
hc(_neighborhood, _fullEval, _eval, checkpoint),
|
||||
initHC(_init, hc)
|
||||
{
|
||||
// to count the number of step in the HC
|
||||
checkpoint.add(lengthStat);
|
||||
|
||||
// add the solution into statistics
|
||||
this->add(solStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moHillClimberSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moSolutionStat<EOT> solStat;
|
||||
moMinusOneCounterStat<EOT> lengthStat;
|
||||
moTrueContinuator<Neighbor> trueCont;
|
||||
moStatFromStat<EOT, unsigned int> copyStat;
|
||||
moCheckpoint<Neighbor> checkpoint;
|
||||
moSimpleHC<Neighbor> hc;
|
||||
moLocalSearchInit<Neighbor> initHC;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
113
mo/src/sampling/moMHBestFitnessCloudSampling.h
Normal file
113
mo/src/sampling/moMHBestFitnessCloudSampling.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
<moMHBestFitnessCloudSampling.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 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 moMHBestFitnessCloudSampling_h
|
||||
#define moMHBestFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moMetropolisHasting.h>
|
||||
#include <continuator/moNeighborBestStat.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* Here solution are sampled with Metropolis-Hasting method
|
||||
*
|
||||
* Sample the fitness of solutions from Metropolis-Hasting sampling
|
||||
* and the best fitness of k random neighbor
|
||||
*
|
||||
* The values are collected during the Metropolis-Hasting walk
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moMHBestFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood)
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbStep Number of step of the MH sampling
|
||||
*/
|
||||
moMHBestFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbStep) :
|
||||
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbStep),
|
||||
neighborBestStat(_neighborhood, _eval)
|
||||
{
|
||||
// delete the dummy local search
|
||||
delete localSearch;
|
||||
|
||||
// Metropolis-Hasting sampling
|
||||
localSearch = new moMetropolisHasting<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep);
|
||||
|
||||
// delete the checkpoint with the wrong continuator
|
||||
delete checkpoint;
|
||||
|
||||
// set the continuator
|
||||
continuator = localSearch->getContinuator();
|
||||
|
||||
// re-construction of the checkpoint
|
||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||
checkpoint->add(fitnessStat);
|
||||
checkpoint->add(*monitorVec[0]);
|
||||
|
||||
// one random neighbor
|
||||
this->add(neighborBestStat);
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborBestStat< Neighbor > neighborBestStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
113
mo/src/sampling/moMHRndFitnessCloudSampling.h
Normal file
113
mo/src/sampling/moMHRndFitnessCloudSampling.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
<moMHRndFitnessCloudSampling.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 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 moMHRndFitnessCloudSampling_h
|
||||
#define moMHRndFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moMetropolisHasting.h>
|
||||
#include <continuator/moNeighborFitnessStat.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* Here solution are sampled with Metropolis-Hasting method
|
||||
*
|
||||
* Sample the fitness of solutions from Metropolis-Hasting sampling
|
||||
* and the fitness of one random neighbor
|
||||
*
|
||||
* The values are collected during the Metropolis-Hasting walk
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moMHRndFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood)
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbStep Number of step of the MH sampling
|
||||
*/
|
||||
moMHRndFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbStep) :
|
||||
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbStep),
|
||||
neighborFitnessStat(_neighborhood, _eval)
|
||||
{
|
||||
// delete the dummy local search
|
||||
delete localSearch;
|
||||
|
||||
// Metropolis-Hasting sampling
|
||||
localSearch = new moMetropolisHasting<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep);
|
||||
|
||||
// delete the checkpoint with the wrong continuator
|
||||
delete checkpoint;
|
||||
|
||||
// set the continuator
|
||||
continuator = localSearch->getContinuator();
|
||||
|
||||
// re-construction of the checkpoint
|
||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||
checkpoint->add(fitnessStat);
|
||||
checkpoint->add(*monitorVec[0]);
|
||||
|
||||
// one random neighbor
|
||||
this->add(neighborFitnessStat);
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
125
mo/src/sampling/moNeutralDegreeSampling.h
Normal file
125
mo/src/sampling/moNeutralDegreeSampling.h
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
<moNeutralDegreeSampling.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 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 moNeutralDegreeSampling_h
|
||||
#define moNeutralDegreeSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
#include <continuator/moNeutralDegreeNeighborStat.h>
|
||||
#include <sampling/moSampling.h>
|
||||
|
||||
/**
|
||||
* To compute the neutral degree:
|
||||
* Sample the fitness of random solution in the search space (1er information)
|
||||
* and sample the neutral degree (2nd information), i.e. the number of neighbor solutions with the same fitness value
|
||||
* The values are collected during the random search
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moNeutralDegreeSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to compute the neutral degree
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moNeutralDegreeSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat),
|
||||
neighborhoodStat(_neighborhood, _eval),
|
||||
ndStat(neighborhoodStat)
|
||||
{
|
||||
this->add(neighborhoodStat, false);
|
||||
this->add(ndStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with comparators
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to compute the neutral degree
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _neighborComparator a neighbor Comparator
|
||||
* @param _solNeighborComparator a comparator between a solution and a neighbor
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moNeutralDegreeSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
moNeighborComparator<Neighbor>& _neighborComparator,
|
||||
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat),
|
||||
neighborhoodStat(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
|
||||
ndStat(neighborhoodStat)
|
||||
{
|
||||
this->add(neighborhoodStat, false);
|
||||
this->add(ndStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moNeutralDegreeSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moFitnessStat<EOT> fitnessStat;
|
||||
moNeighborhoodStat< Neighbor > neighborhoodStat;
|
||||
moNeutralDegreeNeighborStat< Neighbor > ndStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
148
mo/src/sampling/moNeutralWalkSampling.h
Normal file
148
mo/src/sampling/moNeutralWalkSampling.h
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
<moNeutralWalkSampling.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 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 moNeutralWalkSampling_h
|
||||
#define moNeutralWalkSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomNeutralWalk.h>
|
||||
#include <sampling/moSampling.h>
|
||||
#include <perturb/moSolInit.h>
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include <utils/eoDistance.h>
|
||||
#include <continuator/moDistanceStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
#include <continuator/moMaxNeighborStat.h>
|
||||
#include <continuator/moMinNeighborStat.h>
|
||||
#include <continuator/moAverageFitnessNeighborStat.h>
|
||||
#include <continuator/moStdFitnessNeighborStat.h>
|
||||
#include <continuator/moSizeNeighborStat.h>
|
||||
#include <continuator/moNbInfNeighborStat.h>
|
||||
#include <continuator/moNbSupNeighborStat.h>
|
||||
#include <continuator/moNeutralDegreeNeighborStat.h>
|
||||
|
||||
/**
|
||||
* To explore the evolvability of solutions in a neutral networks:
|
||||
* Perform a random neutral walk based on the neighborhood,
|
||||
* The measures of evolvability of solutions are collected during the random neutral walk
|
||||
* The distribution and autocorrelation can be computed from the serie of values
|
||||
*
|
||||
* Informations collected:
|
||||
* - the current solution of the walk
|
||||
* - the distance from the starting solution
|
||||
* - the minimal fitness in the neighborhood
|
||||
* - the average fitness
|
||||
* - the standard deviation of the fitness
|
||||
* - the maximal fitness
|
||||
* - the size of the neighborhood
|
||||
* - the number of neighbors with lower fitness
|
||||
* - the number of neighbors with equal fitness (neutral degree)
|
||||
* - the number of neighbors with higher fitness
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moNeutralWalkSampling : public moSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _initSol the first solution of the walk
|
||||
* @param _neighborhood neighborhood giving neighbor in random order
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _distance component to measure the distance from the initial solution
|
||||
* @param _nbStep Number of steps of the random walk
|
||||
*/
|
||||
moNeutralWalkSampling(EOT & _initSol,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
eoDistance<EOT> & _distance,
|
||||
unsigned int _nbStep) :
|
||||
moSampling<Neighbor>(init, * new moRandomNeutralWalk<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), solutionStat),
|
||||
init(_initSol),
|
||||
distStat(_distance, _initSol),
|
||||
neighborhoodStat(_neighborhood, _eval),
|
||||
minStat(neighborhoodStat),
|
||||
averageStat(neighborhoodStat),
|
||||
stdStat(neighborhoodStat),
|
||||
maxStat(neighborhoodStat),
|
||||
nbSupStat(neighborhoodStat),
|
||||
nbInfStat(neighborhoodStat),
|
||||
sizeStat(neighborhoodStat),
|
||||
ndStat(neighborhoodStat)
|
||||
{
|
||||
this->add(neighborhoodStat, false);
|
||||
this->add(distStat);
|
||||
this->add(minStat);
|
||||
this->add(averageStat);
|
||||
this->add(stdStat);
|
||||
this->add(maxStat);
|
||||
this->add(sizeStat);
|
||||
this->add(nbInfStat);
|
||||
this->add(ndStat);
|
||||
this->add(nbSupStat);
|
||||
}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moNeutralWalkSampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
moSolInit<EOT> init;
|
||||
moSolutionStat<EOT> solutionStat;
|
||||
moDistanceStat<EOT> distStat;
|
||||
moNeighborhoodStat< Neighbor > neighborhoodStat;
|
||||
moMinNeighborStat< Neighbor > minStat;
|
||||
moAverageFitnessNeighborStat< Neighbor > averageStat;
|
||||
moStdFitnessNeighborStat< Neighbor > stdStat;
|
||||
moMaxNeighborStat< Neighbor > maxStat;
|
||||
moNbSupNeighborStat< Neighbor > nbSupStat;
|
||||
moNbInfNeighborStat< Neighbor > nbInfStat;
|
||||
moSizeNeighborStat< Neighbor > sizeStat;
|
||||
moNeutralDegreeNeighborStat< Neighbor > ndStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
111
mo/src/sampling/moRndBestFitnessCloudSampling.h
Normal file
111
mo/src/sampling/moRndBestFitnessCloudSampling.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
<moRndBestFitnessCloudSampling.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 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 moRndBestFitnessCloudSampling_h
|
||||
#define moRndBestFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <continuator/moNeighborBestStat.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* Sample the fitness of random solution in the search space
|
||||
* and the best fitness of k random neighbor
|
||||
*
|
||||
* The values are collected during the random search
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moRndBestFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood)
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moRndBestFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbSol) :
|
||||
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbSol),
|
||||
neighborBestStat(_neighborhood, _eval)
|
||||
{
|
||||
// delete the dummy local search
|
||||
delete localSearch;
|
||||
|
||||
// random sampling
|
||||
localSearch = new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol);
|
||||
|
||||
// delete the checkpoint with the wrong continuator
|
||||
delete checkpoint;
|
||||
|
||||
// set the continuator
|
||||
continuator = localSearch->getContinuator();
|
||||
|
||||
// re-construction of the checkpoint
|
||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||
checkpoint->add(fitnessStat);
|
||||
checkpoint->add(*monitorVec[0]);
|
||||
|
||||
// one random neighbor
|
||||
this->add(neighborBestStat);
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborBestStat< Neighbor > neighborBestStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
111
mo/src/sampling/moRndRndFitnessCloudSampling.h
Normal file
111
mo/src/sampling/moRndRndFitnessCloudSampling.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
<moRndRndFitnessCloudSampling.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 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 moRndRndFitnessCloudSampling_h
|
||||
#define moRndRndFitnessCloudSampling_h
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <algo/moRandomSearch.h>
|
||||
#include <continuator/moNeighborFitnessStat.h>
|
||||
#include <sampling/moFitnessCloudSampling.h>
|
||||
|
||||
/**
|
||||
* To compute an estimation of the fitness cloud,
|
||||
* i.e. the scatter plot of solution fitness versus neighbor fitness:
|
||||
*
|
||||
* Sample the fitness of random solution in the search space
|
||||
* and the fitness of one random neighbor
|
||||
*
|
||||
* The values are collected during the random search
|
||||
*
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moRndRndFitnessCloudSampling : public moFitnessCloudSampling<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
using moSampling<Neighbor>::localSearch;
|
||||
using moSampling<Neighbor>::checkpoint;
|
||||
using moSampling<Neighbor>::monitorVec;
|
||||
using moSampling<Neighbor>::continuator;
|
||||
using moFitnessCloudSampling<Neighbor>::fitnessStat;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood)
|
||||
* @param _fullEval Fitness function, full evaluation function
|
||||
* @param _eval neighbor evaluation, incremental evaluation function
|
||||
* @param _nbSol Number of solutions in the sample
|
||||
*/
|
||||
moRndRndFitnessCloudSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbSol) :
|
||||
moFitnessCloudSampling<Neighbor>(_init, _neighborhood, _fullEval, _eval, _nbSol),
|
||||
neighborFitnessStat(_neighborhood, _eval)
|
||||
{
|
||||
// delete the dummy local search
|
||||
delete localSearch;
|
||||
|
||||
// random sampling
|
||||
localSearch = new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol);
|
||||
|
||||
// delete the checkpoint with the wrong continuator
|
||||
delete checkpoint;
|
||||
|
||||
// set the continuator
|
||||
continuator = localSearch->getContinuator();
|
||||
|
||||
// re-construction of the checkpoint
|
||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||
checkpoint->add(fitnessStat);
|
||||
checkpoint->add(*monitorVec[0]);
|
||||
|
||||
// one random neighbor
|
||||
this->add(neighborFitnessStat);
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborFitnessStat< Neighbor > neighborFitnessStat;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
239
mo/src/sampling/moSampling.h
Normal file
239
mo/src/sampling/moSampling.h
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
<moSampling.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 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 moSampling_h
|
||||
#define moSampling_h
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <eoFunctor.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moCheckpoint.h>
|
||||
#include <continuator/moVectorMonitor.h>
|
||||
#include <algo/moLocalSearch.h>
|
||||
#include <eoInit.h>
|
||||
|
||||
|
||||
/**
|
||||
* To sample the search space:
|
||||
* A local search is used to sample the search space
|
||||
* Some statistics are computed at each step of the local search
|
||||
*
|
||||
* Can be used to study the fitness landscape
|
||||
*/
|
||||
template <class Neighbor>
|
||||
class moSampling : public eoF<void>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _init initialisation method of the solution
|
||||
* @param _localSearch local search to sample the search space
|
||||
* @param _stat statistic to compute during the search
|
||||
* @param _monitoring the statistic is saved into the monitor if true
|
||||
*/
|
||||
template <class ValueType>
|
||||
moSampling(eoInit<EOT> & _init, moLocalSearch<Neighbor> & _localSearch, moStat<EOT,ValueType> & _stat, bool _monitoring = true) : init(_init), localSearch(&_localSearch), continuator(_localSearch.getContinuator())
|
||||
{
|
||||
checkpoint = new moCheckpoint<Neighbor>(*continuator);
|
||||
add(_stat, _monitoring);
|
||||
// precision of the output by default
|
||||
precisionOutput = std::cout.precision();
|
||||
}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
*/
|
||||
~moSampling() {
|
||||
// delete all monitors
|
||||
for (unsigned i = 0; i < monitorVec.size(); i++)
|
||||
delete monitorVec[i];
|
||||
|
||||
// delete the checkpoint
|
||||
delete checkpoint ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a statistic
|
||||
* @param _stat another statistic to compute during the search
|
||||
* @param _monitoring the statistic is saved into the monitor if true
|
||||
*/
|
||||
template< class ValueType >
|
||||
void add(moStat<EOT, ValueType> & _stat, bool _monitoring = true) {
|
||||
checkpoint->add(_stat);
|
||||
|
||||
if (_monitoring) {
|
||||
moVectorMonitor<EOT> * monitor = new moVectorMonitor<EOT>(_stat);
|
||||
monitorVec.push_back(monitor);
|
||||
checkpoint->add(*monitor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To sample the search and get the statistics which are stored in the moVectorMonitor vector
|
||||
*/
|
||||
void operator()(void) {
|
||||
// clear all statistic vectors
|
||||
for (unsigned i = 0; i < monitorVec.size(); i++)
|
||||
monitorVec[i]->clear();
|
||||
|
||||
// change the checkpoint to compute the statistics
|
||||
localSearch->setContinuator(*checkpoint);
|
||||
|
||||
// the initial solution
|
||||
EOT solution;
|
||||
|
||||
// initialisation of the solution
|
||||
init(solution);
|
||||
|
||||
// compute the sampling
|
||||
(*localSearch)(solution);
|
||||
|
||||
// set back to initial continuator
|
||||
localSearch->setContinuator(*continuator);
|
||||
}
|
||||
|
||||
/**
|
||||
* to set the precision of the output file
|
||||
* @param _precision precision of the output (number of digit)
|
||||
*/
|
||||
void precision(unsigned int _precision) {
|
||||
precisionOutput = _precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* to export the vectors of values into one file
|
||||
* @param _filename file name
|
||||
* @param _delim delimiter between statistics
|
||||
* @param _openFile to specify if it writes at the following of the file
|
||||
*/
|
||||
void fileExport(std::string _filename, std::string _delim = " ", bool _openFile=false) {
|
||||
// create file
|
||||
std::ofstream os;
|
||||
|
||||
if(! _openFile)
|
||||
os.open(_filename.c_str());
|
||||
|
||||
else
|
||||
os.open(_filename.c_str(),std::ios::app);
|
||||
|
||||
if (!os) {
|
||||
std::string str = "moSampling: Could not open " + _filename;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
// set the precision of the output
|
||||
os.precision(precisionOutput);
|
||||
for (unsigned int j = 0; j < monitorVec.size(); j++)
|
||||
monitorVec[j]->precision(precisionOutput);
|
||||
|
||||
// all vector have the same size
|
||||
unsigned vecSize = monitorVec[0]->size();
|
||||
|
||||
for (unsigned int i = 0; i < vecSize; i++) {
|
||||
os << monitorVec[0]->getValue(i);
|
||||
|
||||
for (unsigned int j = 1; j < monitorVec.size(); j++) {
|
||||
os << _delim.c_str() << monitorVec[j]->getValue(i);
|
||||
}
|
||||
|
||||
os << std::endl ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to export one vector of values into a file
|
||||
* @param _col number of vector to print into file
|
||||
* @param _filename file name
|
||||
* @param _openFile to specify if it writes at the following of the file
|
||||
*/
|
||||
void fileExport(unsigned int _col, std::string _filename, bool _openFile=false) {
|
||||
if (_col >= monitorVec.size()) {
|
||||
std::string str = "moSampling: Could not export into file the vector. The index does not exists (too large)";
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
monitorVec[_col]->precision(precisionOutput);
|
||||
monitorVec[_col]->fileExport(_filename, _openFile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* to get one vector of values
|
||||
* @param _numStat number of statistics to get (in the order of creation)
|
||||
* @return the vector of value (all values are converted in double)
|
||||
*/
|
||||
const std::vector<double> & getValues(unsigned int _numStat) {
|
||||
return monitorVec[_numStat]->getValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* to get one vector of solutions values
|
||||
* @param _numStat number of statistics to get (in the order of creation)
|
||||
* @return the vector of value (all values are converted in double)
|
||||
*/
|
||||
const std::vector<EOT> & getSolutions(unsigned int _numStat) {
|
||||
return monitorVec[_numStat]->getSolutions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moSampling";
|
||||
}
|
||||
|
||||
protected:
|
||||
eoInit<EOT> & init;
|
||||
moLocalSearch<Neighbor> * localSearch;
|
||||
|
||||
moContinuator<Neighbor> * continuator;
|
||||
moCheckpoint<Neighbor> * checkpoint;
|
||||
|
||||
std::vector< moVectorMonitor<EOT> *> monitorVec;
|
||||
|
||||
// precision of the output
|
||||
unsigned int precisionOutput;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
226
mo/src/sampling/moStatistics.h
Normal file
226
mo/src/sampling/moStatistics.h
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
<moStatistics.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 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 moStatistics_h
|
||||
#define moStatistics_h
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <utils/eoDistance.h>
|
||||
|
||||
/**
|
||||
* Tools to compute some basic statistics
|
||||
*
|
||||
* Remember it is better to use some statistic tool like R, etc.
|
||||
* But it could be usefull to have here in paradisEO
|
||||
*/
|
||||
class moStatistics
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moStatistics() { }
|
||||
|
||||
/**
|
||||
* To compute min, max , average and standard deviation of a vector of double
|
||||
*
|
||||
* @param data vector of double
|
||||
* @param min to compute
|
||||
* @param max to compute
|
||||
* @param avg average to compute
|
||||
* @param std standard deviation to compute
|
||||
*/
|
||||
void basic(const std::vector<double> & data,
|
||||
double & min, double & max, double & avg, double & std) {
|
||||
|
||||
if (data.size() == 0) {
|
||||
min = 0.0;
|
||||
max = 0.0;
|
||||
avg = 0.0;
|
||||
std = 0.0;
|
||||
} else {
|
||||
unsigned int n = data.size();
|
||||
|
||||
min = data[0];
|
||||
max = data[0];
|
||||
avg = 0.0;
|
||||
std = 0.0;
|
||||
|
||||
double d;
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
d = data[i];
|
||||
if (d < min)
|
||||
min = d;
|
||||
if (max < d)
|
||||
max = d;
|
||||
avg += d;
|
||||
std += d * d;
|
||||
}
|
||||
|
||||
avg /= n;
|
||||
|
||||
std = (std / n) - avg * avg ;
|
||||
if (std > 0)
|
||||
std = sqrt(std);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To compute the distance between solutions
|
||||
*
|
||||
* @param data vector of solutions
|
||||
* @param distance method to compute the distance
|
||||
* @param matrix matrix of distances between solutions
|
||||
*/
|
||||
template <class EOT>
|
||||
void distances(const std::vector<EOT> & data, eoDistance<EOT> & distance,
|
||||
std::vector< std::vector<double> > & matrix) {
|
||||
if (data.size() == 0) {
|
||||
matrix.resize(0);
|
||||
} else {
|
||||
unsigned int n = data.size();
|
||||
|
||||
matrix.resize(n);
|
||||
for (unsigned i = 0; i < n; i++)
|
||||
matrix[i].resize(n);
|
||||
|
||||
unsigned j;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
matrix[i][i] = 0.0;
|
||||
for (j = 0; j < i; j++) {
|
||||
matrix[i][j] = distance(data[i], data[j]);
|
||||
matrix[j][i] = matrix[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To compute the autocorrelation and partial autocorrelation
|
||||
*
|
||||
* @param data vector of double
|
||||
* @param nbS number of correlation coefficients
|
||||
* @param rho autocorrelation coefficients
|
||||
* @param phi partial autocorrelation coefficients
|
||||
*/
|
||||
void autocorrelation(const std::vector<double> & data, unsigned int nbS,
|
||||
std::vector<double> & rho, std::vector<double> & phi) {
|
||||
if (data.size() == 0) {
|
||||
rho.resize(0);
|
||||
phi.resize(0);
|
||||
} else {
|
||||
unsigned int n = data.size();
|
||||
|
||||
std::vector<double> cov;
|
||||
cov.resize(nbS+1);
|
||||
//double cov[nbS+1];
|
||||
std::vector<double> m;
|
||||
m.resize(nbS+1);
|
||||
//double m[nbS+1];
|
||||
std::vector<double> sig;
|
||||
sig.resize(nbS+1);
|
||||
//double sig[nbS+1];
|
||||
|
||||
rho.resize(nbS+1);
|
||||
phi.resize(nbS+1);
|
||||
rho[0] = 1.0;
|
||||
phi[0] = 1.0;
|
||||
|
||||
unsigned s, k;
|
||||
|
||||
for (s = 0; s <= nbS; s++) {
|
||||
cov[s] = 0;
|
||||
m[s] = 0;
|
||||
sig[s] = 0;
|
||||
}
|
||||
|
||||
double m0, s0;
|
||||
unsigned j;
|
||||
|
||||
k = 0;
|
||||
s = nbS;
|
||||
while (s > 0) {
|
||||
while (k + s < n) {
|
||||
for (j = 0; j <= s; j++) {
|
||||
m[j] += data[k+j];
|
||||
sig[j] += data[k+j] * data[k+j];
|
||||
cov[j] += data[k] * data[k+j];
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
m[s] /= n - s;
|
||||
sig[s] = sig[s] / (n - s) - m[s] * m[s];
|
||||
if (sig[s] <= 0)
|
||||
sig[s] = 0;
|
||||
else
|
||||
sig[s] = sqrt(sig[s]);
|
||||
m0 = m[0] / (n - s);
|
||||
s0 = sqrt(sig[0] / (n - s) - m0 * m0);
|
||||
cov[s] = cov[s] / (n - s) - (m[0] / (n - s)) * m[s];
|
||||
rho[s] = cov[s] / (sig[s] * s0);
|
||||
s--;
|
||||
}
|
||||
|
||||
std::vector< std::vector<double> > phi2;
|
||||
phi2.resize(nbS+1);
|
||||
for(unsigned int i=0; i<phi2.size(); i++)
|
||||
phi2[i].resize(nbS+1);
|
||||
//double phi2[nbS+1][nbS+1];
|
||||
double tmp1, tmp2;
|
||||
|
||||
phi2[1][1] = rho[1];
|
||||
for (k = 2; k <= nbS; k++) {
|
||||
tmp1 = 0;
|
||||
tmp2 = 0;
|
||||
for (j = 1; j < k; j++) {
|
||||
tmp1 += phi2[k-1][j] * rho[k-j];
|
||||
tmp2 += phi2[k-1][j] * rho[j];
|
||||
}
|
||||
phi2[k][k] = (rho[k] - tmp1) / (1 - tmp2);
|
||||
for (j = 1; j < k; j++)
|
||||
phi2[k][j] = phi2[k-1][j] - phi2[k][k] * phi2[k-1][k-j];
|
||||
}
|
||||
|
||||
for (j = 1; j <= nbS; j++)
|
||||
phi[j] = phi2[j][j];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue