Add quartiles statistics of the moNeighborhoodStat. Add metho longName in moVectorMonitor.
This commit is contained in:
parent
a3288caf6d
commit
25850272c3
22 changed files with 533 additions and 28 deletions
|
|
@ -55,7 +55,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moAverageFitnessNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moAverageFitnessNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, double >(0.0, "average"), nhStat(_nhStat) {}
|
moStat<EOT, double >(0.0, "mean"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the average of fitness in the neighborhood
|
* Set the average of fitness in the neighborhood
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moMaxNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moMaxNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
|
moStat<EOT, Fitness>(Fitness(), "max"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the max fitness in the neighborhood
|
* Set the max fitness in the neighborhood
|
||||||
|
|
|
||||||
90
mo/src/continuator/moMedianNeighborStat.h
Normal file
90
mo/src/continuator/moMedianNeighborStat.h
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
<moMedianNeighborStat.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 moMedianNeighborStat_h
|
||||||
|
#define moMedianNeighborStat_h
|
||||||
|
|
||||||
|
#include <continuator/moStat.h>
|
||||||
|
#include <continuator/moNeighborhoodStat.h>
|
||||||
|
#include <neighborhood/moNeighborhood.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From moNeighborhoodStat,
|
||||||
|
* to compute the meadian fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moMedianNeighborStat : 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
|
||||||
|
*/
|
||||||
|
moMedianNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
|
moStat<EOT, Fitness>(Fitness(), "median"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the median fitness in the neighborhood
|
||||||
|
* @param _sol the first solution
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _sol) {
|
||||||
|
value() = nhStat.getMedian();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the median fitness in the neighborhood
|
||||||
|
* @param _sol the corresponding solution
|
||||||
|
*/
|
||||||
|
virtual void operator()(EOT & _sol) {
|
||||||
|
value() = nhStat.getMedian();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the class name
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moMedianNeighborStat";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** moNeighborhoodStat */
|
||||||
|
moNeighborhoodStat<Neighbor> & nhStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -57,7 +57,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moNbInfNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moNbInfNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat) {}
|
moStat<EOT, unsigned>(0, "inf"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
|
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moNbSupNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moNbSupNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat) {}
|
moStat<EOT, unsigned>(0, "sup"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the number of solutions in the neighborhood with better fitness than the current solution
|
* Set the number of solutions in the neighborhood with better fitness than the current solution
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
#include <neighborhood/moNeighborhood.h>
|
#include <neighborhood/moNeighborhood.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm> // std::sort
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All possible statitic on the neighborhood fitness
|
* All possible statitic on the neighborhood fitness
|
||||||
|
|
@ -102,8 +104,11 @@ public :
|
||||||
Neighbor lowest ;
|
Neighbor lowest ;
|
||||||
|
|
||||||
if (neighborhood.hasNeighbor(_solution)) {
|
if (neighborhood.hasNeighbor(_solution)) {
|
||||||
//init the first neighbor
|
// to save the fitness values of the neighbors
|
||||||
neighborhood.init(_solution, current);
|
std::vector<double> neighborFitness;
|
||||||
|
|
||||||
|
//init the first neighbor
|
||||||
|
neighborhood.init(_solution, current);
|
||||||
|
|
||||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||||
eval(_solution, current);
|
eval(_solution, current);
|
||||||
|
|
@ -112,7 +117,7 @@ public :
|
||||||
value() = true;
|
value() = true;
|
||||||
|
|
||||||
mean = current.fitness();
|
mean = current.fitness();
|
||||||
sd = mean * mean;
|
neighborFitness.push_back( (double) current.fitness() );
|
||||||
nb = 1;
|
nb = 1;
|
||||||
nbInf = 0;
|
nbInf = 0;
|
||||||
nbEqual = 0;
|
nbEqual = 0;
|
||||||
|
|
@ -137,7 +142,7 @@ public :
|
||||||
eval(_solution, current);
|
eval(_solution, current);
|
||||||
|
|
||||||
mean += current.fitness();
|
mean += current.fitness();
|
||||||
sd += current.fitness() * current.fitness();
|
neighborFitness.push_back( (double) current.fitness() );
|
||||||
nb++;
|
nb++;
|
||||||
|
|
||||||
if (solNeighborComparator.equals(_solution, current))
|
if (solNeighborComparator.equals(_solution, current))
|
||||||
|
|
@ -159,10 +164,24 @@ public :
|
||||||
min = lowest.fitness();
|
min = lowest.fitness();
|
||||||
|
|
||||||
mean /= nb;
|
mean /= nb;
|
||||||
if (nb > 1)
|
|
||||||
sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) );
|
if (nb > 1) {
|
||||||
else
|
sd = 0;
|
||||||
|
for(int i = 0; i < nb; i++)
|
||||||
|
sd += (neighborFitness[i] - mean) * (neighborFitness[i] - mean) ;
|
||||||
|
sd = sqrt( sd / (nb - 1.0) ); // becareful: could be infinite when large values
|
||||||
|
//sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) ); // becareful: could be negative due to approximation of large values
|
||||||
|
|
||||||
|
std::sort(neighborFitness.begin(), neighborFitness.end()); // to compute the quartiles
|
||||||
|
q1 = neighborFitness[nb / 4];
|
||||||
|
q2 = neighborFitness[nb / 2];
|
||||||
|
q3 = neighborFitness[3 * nb / 4];
|
||||||
|
} else {
|
||||||
sd = 0.0;
|
sd = 0.0;
|
||||||
|
q1 = max;
|
||||||
|
q2 = q1;
|
||||||
|
q3 = q1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//if _solution hasn't neighbor,
|
//if _solution hasn't neighbor,
|
||||||
|
|
@ -198,6 +217,27 @@ public :
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the first quartile of fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
Fitness getQ1() {
|
||||||
|
return q1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the third quartile of fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
Fitness getQ3() {
|
||||||
|
return q3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the median fitness value of the neighborhood
|
||||||
|
*/
|
||||||
|
Fitness getMedian() {
|
||||||
|
return q2;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the size of the neighborhood
|
* @return the size of the neighborhood
|
||||||
*/
|
*/
|
||||||
|
|
@ -251,9 +291,13 @@ protected:
|
||||||
|
|
||||||
// the stastics of the fitness
|
// the stastics of the fitness
|
||||||
Fitness max, min;
|
Fitness max, min;
|
||||||
//mean and standard deviation
|
|
||||||
|
// mean and standard deviation
|
||||||
double mean, sd ;
|
double mean, sd ;
|
||||||
|
|
||||||
|
// quartiles
|
||||||
|
Fitness q1, q2, q3;
|
||||||
|
|
||||||
// number of neighbors in the neighborhood;
|
// number of neighbors in the neighborhood;
|
||||||
unsigned int nb;
|
unsigned int nb;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat) {}
|
moStat<EOT, unsigned>(0, "nd"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
|
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
|
||||||
|
|
|
||||||
90
mo/src/continuator/moQ1NeighborStat.h
Normal file
90
mo/src/continuator/moQ1NeighborStat.h
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
<moQ1NeighborStat.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 moQ1NeighborStat_h
|
||||||
|
#define moQ1NeighborStat_h
|
||||||
|
|
||||||
|
#include <continuator/moStat.h>
|
||||||
|
#include <continuator/moNeighborhoodStat.h>
|
||||||
|
#include <neighborhood/moNeighborhood.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From moNeighborhoodStat,
|
||||||
|
* to compute the first quartile of fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moQ1NeighborStat : 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
|
||||||
|
*/
|
||||||
|
moQ1NeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
|
moStat<EOT, Fitness>(Fitness(), "q1"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the first quartile of fitness in the neighborhood
|
||||||
|
* @param _sol the first solution
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _sol) {
|
||||||
|
value() = nhStat.getQ1();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the first quartile of fitness in the neighborhood
|
||||||
|
* @param _sol the corresponding solution
|
||||||
|
*/
|
||||||
|
virtual void operator()(EOT & _sol) {
|
||||||
|
value() = nhStat.getQ1();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the class name
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moQ1NeighborStat";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** moNeighborhoodStat */
|
||||||
|
moNeighborhoodStat<Neighbor> & nhStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
90
mo/src/continuator/moQ3NeighborStat.h
Normal file
90
mo/src/continuator/moQ3NeighborStat.h
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
<moQ3NeighborStat.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 moQ3NeighborStat_h
|
||||||
|
#define moQ3NeighborStat_h
|
||||||
|
|
||||||
|
#include <continuator/moStat.h>
|
||||||
|
#include <continuator/moNeighborhoodStat.h>
|
||||||
|
#include <neighborhood/moNeighborhood.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From moNeighborhoodStat,
|
||||||
|
* to compute the third quartile of fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moQ3NeighborStat : 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
|
||||||
|
*/
|
||||||
|
moQ3NeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
|
moStat<EOT, Fitness>(Fitness(), "q3"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the third quartile of fitness in the neighborhood
|
||||||
|
* @param _sol the third solution
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _sol) {
|
||||||
|
value() = nhStat.getQ3();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the third quartile of fitness in the neighborhood
|
||||||
|
* @param _sol the corresponding solution
|
||||||
|
*/
|
||||||
|
virtual void operator()(EOT & _sol) {
|
||||||
|
value() = nhStat.getQ3();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the class name
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moQ3NeighborStat";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** moNeighborhoodStat */
|
||||||
|
moNeighborhoodStat<Neighbor> & nhStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
91
mo/src/continuator/moQuartilesNeighborStat.h
Normal file
91
mo/src/continuator/moQuartilesNeighborStat.h
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
<moQuartilesNeighborStat.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 moQuartilesNeighborStat_h
|
||||||
|
#define moQuartilesNeighborStat_h
|
||||||
|
|
||||||
|
#include <continuator/moStat.h>
|
||||||
|
#include <continuator/moNeighborhoodStat.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From moNeighborhoodStat,
|
||||||
|
* to compute the first and the third quartile of fitness in the neighborhood
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moQuartilesNeighborStat : public moStat<typename Neighbor::EOT, std::pair<double, double> >
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
typedef typename Neighbor::EOT EOT ;
|
||||||
|
typedef typename EOT::Fitness Fitness ;
|
||||||
|
|
||||||
|
using moStat< EOT, std::pair<double, double> >::value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param _nhStat a neighborhoodStat
|
||||||
|
*/
|
||||||
|
moQuartilesNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
|
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "first and third quartile"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the first and the third quartile of fitness in the neighborhood
|
||||||
|
* @param _sol the first solution
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _sol) {
|
||||||
|
value().first = nhStat.getQ1();
|
||||||
|
value().second = nhStat.getQ3();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the first and the third quartile fitness in the neighborhood
|
||||||
|
* @param _sol the corresponding solution
|
||||||
|
*/
|
||||||
|
virtual void operator()(EOT & _sol) {
|
||||||
|
value().first = nhStat.getQ1();
|
||||||
|
value().second = nhStat.getQ3();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the class name
|
||||||
|
*/
|
||||||
|
virtual std::string className(void) const {
|
||||||
|
return "moQuartilesNeighborStat";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** moNeighborhoodStat */
|
||||||
|
moNeighborhoodStat<Neighbor> & nhStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -55,7 +55,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moSecondMomentNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moSecondMomentNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat) {}
|
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "mean sd"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the average and the standard deviation of fitness in the neighborhood
|
* Set the average and the standard deviation of fitness in the neighborhood
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moSizeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moSizeNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat) {}
|
moStat<EOT, unsigned>(0, "nghsize"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the number of solutions in the neighborhood
|
* Set the number of solutions in the neighborhood
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public :
|
||||||
* @param _description a description of the parameter
|
* @param _description a description of the parameter
|
||||||
*/
|
*/
|
||||||
moSolutionStat(std::string _description = "solution"):
|
moSolutionStat(std::string _description = "solution"):
|
||||||
moStat<EOT, EOT>(EOT(), _description) { }
|
moStat<EOT, EOT>(EOT(), "fitness solution") { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization the solution by copy
|
* Initialization the solution by copy
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public :
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param _stat a stat
|
* @param _stat a stat
|
||||||
*/
|
*/
|
||||||
moStatFromStat(moStat<EOT,T> & _stat): moStat<EOT, T>(0, _stat.description()), stat(_stat) {
|
moStatFromStat(moStat<EOT,T> & _stat): moStat<EOT, T>(0, _stat.longName()), stat(_stat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public :
|
||||||
* @param _nhStat a neighborhoodStat
|
* @param _nhStat a neighborhoodStat
|
||||||
*/
|
*/
|
||||||
moStdFitnessNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
moStdFitnessNeighborStat(moNeighborhoodStat<Neighbor> & _nhStat):
|
||||||
moStat<EOT, double >(0.0, "stdev"), nhStat(_nhStat) {}
|
moStat<EOT, double >(0.0, "sd"), nhStat(_nhStat) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the average and the standard deviation of fitness in the neighborhood
|
* Set the average and the standard deviation of fitness in the neighborhood
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,24 @@ public:
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the long name of the statistic (which is a eoParam)
|
||||||
|
*
|
||||||
|
* @return longName of the statistic
|
||||||
|
*/
|
||||||
|
const std::string& longName() const {
|
||||||
|
if (doubleParam != NULL)
|
||||||
|
return doubleParam->longName();
|
||||||
|
else
|
||||||
|
if (intParam != NULL)
|
||||||
|
return intParam->longName();
|
||||||
|
else
|
||||||
|
if (intLongParam != NULL)
|
||||||
|
return intLongParam->longName();
|
||||||
|
else
|
||||||
|
return eotParam->longName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear the vector
|
* clear the vector
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -95,9 +95,15 @@ public:
|
||||||
// to count the number of step in the HC
|
// to count the number of step in the HC
|
||||||
checkpoint.add(lengthStat);
|
checkpoint.add(lengthStat);
|
||||||
|
|
||||||
|
// set the long name of this statistic which is the length of the walk
|
||||||
|
copyStat.setLongName("length");
|
||||||
|
|
||||||
// to count the number of evaluations
|
// to count the number of evaluations
|
||||||
checkpoint.add(nEvalStat);
|
checkpoint.add(nEvalStat);
|
||||||
|
|
||||||
|
// set the long name of this statistic which is the number of neighbor evaluation
|
||||||
|
copyEvalStat.setLongName("ngheval");
|
||||||
|
|
||||||
// add the solution into statistics
|
// add the solution into statistics
|
||||||
this->add(copyEvalStat);
|
this->add(copyEvalStat);
|
||||||
this->add(solStat);
|
this->add(solStat);
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,9 @@ public:
|
||||||
// to count the number of step in the HC
|
// to count the number of step in the HC
|
||||||
checkpoint.add(lengthStat);
|
checkpoint.add(lengthStat);
|
||||||
|
|
||||||
|
// set the long name of this statistic which is the length of the walk
|
||||||
|
copyStat.setLongName("length");
|
||||||
|
|
||||||
// add the solution into statistics
|
// add the solution into statistics
|
||||||
this->add(solStat);
|
this->add(solStat);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@
|
||||||
#include <continuator/moNeighborhoodStat.h>
|
#include <continuator/moNeighborhoodStat.h>
|
||||||
#include <continuator/moMaxNeighborStat.h>
|
#include <continuator/moMaxNeighborStat.h>
|
||||||
#include <continuator/moMinNeighborStat.h>
|
#include <continuator/moMinNeighborStat.h>
|
||||||
|
#include <continuator/moQ1NeighborStat.h>
|
||||||
|
#include <continuator/moQ3NeighborStat.h>
|
||||||
|
#include <continuator/moMedianNeighborStat.h>
|
||||||
#include <continuator/moAverageFitnessNeighborStat.h>
|
#include <continuator/moAverageFitnessNeighborStat.h>
|
||||||
#include <continuator/moStdFitnessNeighborStat.h>
|
#include <continuator/moStdFitnessNeighborStat.h>
|
||||||
#include <continuator/moSizeNeighborStat.h>
|
#include <continuator/moSizeNeighborStat.h>
|
||||||
|
|
@ -63,9 +66,12 @@
|
||||||
* Informations collected:
|
* Informations collected:
|
||||||
* - the current solution of the walk
|
* - the current solution of the walk
|
||||||
* - the distance from the starting solution
|
* - the distance from the starting solution
|
||||||
* - the minimal fitness in the neighborhood
|
|
||||||
* - the average fitness
|
* - the average fitness
|
||||||
* - the standard deviation of the fitness
|
* - the standard deviation of the fitness
|
||||||
|
* - the minimal fitness in the neighborhood
|
||||||
|
* - the first quartile of fitness in the neighborhood
|
||||||
|
* - the median fitness in the neighborhood
|
||||||
|
* - the third quartile of fitness in the neighborhood
|
||||||
* - the maximal fitness
|
* - the maximal fitness
|
||||||
* - the size of the neighborhood
|
* - the size of the neighborhood
|
||||||
* - the number of neighbors with lower fitness
|
* - the number of neighbors with lower fitness
|
||||||
|
|
@ -99,20 +105,26 @@ public:
|
||||||
init(_initSol),
|
init(_initSol),
|
||||||
distStat(_distance, _initSol),
|
distStat(_distance, _initSol),
|
||||||
neighborhoodStat(_neighborhood, _eval),
|
neighborhoodStat(_neighborhood, _eval),
|
||||||
minStat(neighborhoodStat),
|
|
||||||
averageStat(neighborhoodStat),
|
averageStat(neighborhoodStat),
|
||||||
stdStat(neighborhoodStat),
|
stdStat(neighborhoodStat),
|
||||||
|
minStat(neighborhoodStat),
|
||||||
maxStat(neighborhoodStat),
|
maxStat(neighborhoodStat),
|
||||||
nbSupStat(neighborhoodStat),
|
nbSupStat(neighborhoodStat),
|
||||||
nbInfStat(neighborhoodStat),
|
nbInfStat(neighborhoodStat),
|
||||||
sizeStat(neighborhoodStat),
|
sizeStat(neighborhoodStat),
|
||||||
ndStat(neighborhoodStat)
|
ndStat(neighborhoodStat),
|
||||||
|
q1Stat(neighborhoodStat),
|
||||||
|
medianStat(neighborhoodStat),
|
||||||
|
q3Stat(neighborhoodStat)
|
||||||
{
|
{
|
||||||
this->add(neighborhoodStat, false);
|
this->add(neighborhoodStat, false);
|
||||||
this->add(distStat);
|
this->add(distStat);
|
||||||
this->add(minStat);
|
|
||||||
this->add(averageStat);
|
this->add(averageStat);
|
||||||
this->add(stdStat);
|
this->add(stdStat);
|
||||||
|
this->add(minStat);
|
||||||
|
this->add(q1Stat);
|
||||||
|
this->add(medianStat);
|
||||||
|
this->add(q3Stat);
|
||||||
this->add(maxStat);
|
this->add(maxStat);
|
||||||
this->add(sizeStat);
|
this->add(sizeStat);
|
||||||
this->add(nbInfStat);
|
this->add(nbInfStat);
|
||||||
|
|
@ -145,13 +157,19 @@ public:
|
||||||
nbSupStat(neighborhoodStat),
|
nbSupStat(neighborhoodStat),
|
||||||
nbInfStat(neighborhoodStat),
|
nbInfStat(neighborhoodStat),
|
||||||
sizeStat(neighborhoodStat),
|
sizeStat(neighborhoodStat),
|
||||||
ndStat(neighborhoodStat)
|
ndStat(neighborhoodStat),
|
||||||
|
q1Stat(neighborhoodStat),
|
||||||
|
medianStat(neighborhoodStat),
|
||||||
|
q3Stat(neighborhoodStat)
|
||||||
{
|
{
|
||||||
this->add(neighborhoodStat, false);
|
this->add(neighborhoodStat, false);
|
||||||
// this->add(distStat);
|
// this->add(distStat);
|
||||||
this->add(minStat);
|
|
||||||
this->add(averageStat);
|
this->add(averageStat);
|
||||||
this->add(stdStat);
|
this->add(stdStat);
|
||||||
|
this->add(minStat);
|
||||||
|
this->add(q1Stat);
|
||||||
|
this->add(medianStat);
|
||||||
|
this->add(q3Stat);
|
||||||
this->add(maxStat);
|
this->add(maxStat);
|
||||||
this->add(sizeStat);
|
this->add(sizeStat);
|
||||||
this->add(nbInfStat);
|
this->add(nbInfStat);
|
||||||
|
|
@ -182,6 +200,9 @@ protected:
|
||||||
moNbInfNeighborStat< Neighbor > nbInfStat;
|
moNbInfNeighborStat< Neighbor > nbInfStat;
|
||||||
moSizeNeighborStat< Neighbor > sizeStat;
|
moSizeNeighborStat< Neighbor > sizeStat;
|
||||||
moNeutralDegreeNeighborStat< Neighbor > ndStat;
|
moNeutralDegreeNeighborStat< Neighbor > ndStat;
|
||||||
|
moQ1NeighborStat< Neighbor > q1Stat;
|
||||||
|
moMedianNeighborStat< Neighbor > medianStat;
|
||||||
|
moQ3NeighborStat< Neighbor > q3Stat;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,19 +140,20 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to export the vectors of values into one file
|
* to export the vectors of values into one file
|
||||||
|
*
|
||||||
* @param _filename file name
|
* @param _filename file name
|
||||||
* @param _delim delimiter between statistics
|
* @param _delim delimiter between statistics
|
||||||
* @param _openFile to specify if it writes at the following of the file
|
* @param _openFile to specify if it writes at the following of the file
|
||||||
|
* @param _header if true, print the headers which are the name of the statistic
|
||||||
*/
|
*/
|
||||||
void fileExport(std::string _filename, std::string _delim = " ", bool _openFile=false) {
|
void fileExport(std::string _filename, std::string _delim = " ", bool _openFile = false, bool _header = false) {
|
||||||
// create file
|
// create file
|
||||||
std::ofstream os;
|
std::ofstream os;
|
||||||
|
|
||||||
if(! _openFile)
|
if(! _openFile)
|
||||||
os.open(_filename.c_str());
|
os.open(_filename.c_str());
|
||||||
|
|
||||||
else
|
else
|
||||||
os.open(_filename.c_str(),std::ios::app);
|
os.open(_filename.c_str(), std::ios::app);
|
||||||
|
|
||||||
if (!os) {
|
if (!os) {
|
||||||
std::string str = "moSampling: Could not open " + _filename;
|
std::string str = "moSampling: Could not open " + _filename;
|
||||||
|
|
@ -164,6 +165,16 @@ public:
|
||||||
for (unsigned int j = 0; j < monitorVec.size(); j++)
|
for (unsigned int j = 0; j < monitorVec.size(); j++)
|
||||||
monitorVec[j]->precision(precisionOutput);
|
monitorVec[j]->precision(precisionOutput);
|
||||||
|
|
||||||
|
if (!_openFile && _header) {
|
||||||
|
os << monitorVec[0]->longName();
|
||||||
|
|
||||||
|
for (unsigned int j = 1; j < monitorVec.size(); j++) {
|
||||||
|
os << _delim.c_str() << monitorVec[j]->longName();
|
||||||
|
}
|
||||||
|
|
||||||
|
os << std::endl ;
|
||||||
|
}
|
||||||
|
|
||||||
// all vector have the same size
|
// all vector have the same size
|
||||||
unsigned vecSize = monitorVec[0]->size();
|
unsigned vecSize = monitorVec[0]->size();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ int main() {
|
||||||
|
|
||||||
std::vector<double> res;
|
std::vector<double> res;
|
||||||
std::vector<bitVector> res2;
|
std::vector<bitVector> res2;
|
||||||
res = test.getValues(1);
|
res = test.getValues(2);
|
||||||
res2= test.getSolutions(0);
|
res2= test.getSolutions(0);
|
||||||
|
|
||||||
for (unsigned int i=0; i<res2.size(); i++)
|
for (unsigned int i=0; i<res2.size(); i++)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <continuator/moStdFitnessNeighborStat.h>
|
#include <continuator/moStdFitnessNeighborStat.h>
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
#include <continuator/moQuartilesNeighborStat.h>
|
||||||
|
#include <continuator/moQ1NeighborStat.h>
|
||||||
|
#include <continuator/moQ3NeighborStat.h>
|
||||||
|
#include <continuator/moMedianNeighborStat.h>
|
||||||
|
|
||||||
#include "moTestClass.h"
|
#include "moTestClass.h"
|
||||||
|
|
||||||
|
|
@ -85,6 +89,9 @@ int main() {
|
||||||
assert(test.getMean()==6.6);
|
assert(test.getMean()==6.6);
|
||||||
double sd=test.getSD();
|
double sd=test.getSD();
|
||||||
assert(sd>0.966 && sd<0.967);
|
assert(sd>0.966 && sd<0.967);
|
||||||
|
assert(test.getMedian()==6);
|
||||||
|
assert(test.getQ1()==6);
|
||||||
|
assert(test.getQ3()==8);
|
||||||
assert(test.getSize()==10);
|
assert(test.getSize()==10);
|
||||||
assert(test.getNbSup()==7);
|
assert(test.getNbSup()==7);
|
||||||
assert(test.getNbInf()==3);
|
assert(test.getNbInf()==3);
|
||||||
|
|
@ -167,6 +174,40 @@ int main() {
|
||||||
assert(test10.className()=="moStdFitnessNeighborStat");
|
assert(test10.className()=="moStdFitnessNeighborStat");
|
||||||
std::cout << "[t-moStdFitnessNeighborStat] => OK" << std::endl;
|
std::cout << "[t-moStdFitnessNeighborStat] => OK" << std::endl;
|
||||||
|
|
||||||
|
//test of moQuartilesNeighborStat.h
|
||||||
|
std::cout << "[t-moQuartilesNeighborStat] => START" << std::endl;
|
||||||
|
moQuartilesNeighborStat<bitNeighbor> test11(test);
|
||||||
|
test11.init(sol);
|
||||||
|
test11(sol);
|
||||||
|
assert(test11.value().first==6);
|
||||||
|
assert(test11.value().second==8);
|
||||||
|
assert(test11.className()=="moQuartilesNeighborStat");
|
||||||
|
std::cout << "[t-moQuartilesNeighborStat] => OK" << std::endl;
|
||||||
|
|
||||||
|
//test of moMedianNeighborStat.h
|
||||||
|
std::cout << "[t-moMedianNeighborStat] => START" << std::endl;
|
||||||
|
moMedianNeighborStat<bitNeighbor> test12(test);
|
||||||
|
test12(sol);
|
||||||
|
assert(test12.value()==6);
|
||||||
|
assert(test12.className()=="moMedianNeighborStat");
|
||||||
|
std::cout << "[t-moMedianNeighborStat] => OK" << std::endl;
|
||||||
|
|
||||||
|
//test of moQ1NeighborStat.h
|
||||||
|
std::cout << "[t-moQ1NeighborStat] => START" << std::endl;
|
||||||
|
moQ1NeighborStat<bitNeighbor> test13(test);
|
||||||
|
test13(sol);
|
||||||
|
assert(test13.value()==6);
|
||||||
|
assert(test13.className()=="moQ1NeighborStat");
|
||||||
|
std::cout << "[t-moQ1NeighborStat] => OK" << std::endl;
|
||||||
|
|
||||||
|
//test of moQ3NeighborStat.h
|
||||||
|
std::cout << "[t-moQ3NeighborStat] => START" << std::endl;
|
||||||
|
moQ3NeighborStat<bitNeighbor> test14(test);
|
||||||
|
test14(sol);
|
||||||
|
assert(test14.value()==8);
|
||||||
|
assert(test14.className()=="moQ3NeighborStat");
|
||||||
|
std::cout << "[t-moQ3NeighborStat] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue