passage du code dans astyle

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1713 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:25:33 +00:00
commit dd66b5e4bd
105 changed files with 3950 additions and 3924 deletions

View file

@ -55,8 +55,8 @@ public :
* @param _cont a continuator
* @param _interval frequency to compute statistical operators
*/
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0){
continuators.push_back(&_cont);
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0) {
continuators.push_back(&_cont);
}
/**
@ -64,7 +64,7 @@ public :
* @param _cont a continuator
*/
void add(moContinuator<Neighborhood>& _cont) {
continuators.push_back(&_cont);
continuators.push_back(&_cont);
}
/**
@ -72,7 +72,7 @@ public :
* @param _stat a statistic operator
*/
void add(moStatBase<EOT>& _stat) {
stats.push_back(&_stat);
stats.push_back(&_stat);
}
/**
@ -80,7 +80,7 @@ public :
* @param _mon a monitor
*/
void add(eoMonitor& _mon) {
monitors.push_back(&_mon);
monitors.push_back(&_mon);
}
/**
@ -88,7 +88,7 @@ public :
* @param _upd an updater
*/
void add(eoUpdater& _upd) {
updaters.push_back(&_upd);
updaters.push_back(&_upd);
}
/**
@ -96,60 +96,60 @@ public :
* @param _sol the corresponding solution
*/
virtual void init(EOT& _sol) {
for(unsigned i = 0; i < continuators.size(); ++i)
continuators[i]->init(_sol);
for (unsigned i = 0; i < continuators.size(); ++i)
continuators[i]->init(_sol);
}
/**
* @return class name
*/
virtual std::string className(void) const {
return "moCheckpoint";
return "moCheckpoint";
}
/**
* apply operator of checkpoint's containers
* @param _sol reference of the solution
* @return true if all continuator return true
*/
/**
* apply operator of checkpoint's containers
* @param _sol reference of the solution
* @return true if all continuator return true
*/
bool operator()(EOT & _sol) {
unsigned i;
bool bContinue = true;
unsigned i;
bool bContinue = true;
for (i = 0; i < stats.size(); ++i){
if(counter % interval == 0)
(*stats[i])(_sol);
counter++;
}
for (i = 0; i < stats.size(); ++i) {
if (counter % interval == 0)
(*stats[i])(_sol);
counter++;
}
for (i = 0; i < updaters.size(); ++i)
(*updaters[i])();
for (i = 0; i < updaters.size(); ++i)
(*updaters[i])();
for (i = 0; i < monitors.size(); ++i)
(*monitors[i])();
for (i = 0; i < monitors.size(); ++i)
(*monitors[i])();
for (i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_sol) )
bContinue = false;
for (i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_sol) )
bContinue = false;
return bContinue;
}
return bContinue;
}
/**
* last call of statistic operators, monitors and updaters
* @param _sol reference of the solution
*/
void lastCall(EOT& _sol){
unsigned int i;
for (i = 0; i < stats.size(); ++i)
stats[i]->lastCall(_sol);
void lastCall(EOT& _sol) {
unsigned int i;
for (i = 0; i < stats.size(); ++i)
stats[i]->lastCall(_sol);
for (i = 0; i < updaters.size(); ++i)
updaters[i]->lastCall();
for (i = 0; i < updaters.size(); ++i)
updaters[i]->lastCall();
for (i = 0; i < monitors.size(); ++i)
monitors[i]->lastCall();
}
for (i = 0; i < monitors.size(); ++i)
monitors[i]->lastCall();
}
private :
/** continuators vector */

View file

@ -51,13 +51,13 @@ public:
* Init Continuator parameters
* @param _solution the related solution
*/
virtual void init(EOT& _solution){};
virtual void init(EOT& _solution) {};
/**
* Last Call to terminate the checkpoint
* @param _solution the related solution
*/
virtual void lastCall(EOT& _solution){};
/**
* Last Call to terminate the checkpoint
* @param _solution the related solution
*/
virtual void lastCall(EOT& _solution) {};
};
#endif

View file

@ -46,51 +46,53 @@
class moCounterMonitorSaver : public eoUpdater {
public :
/**
* Default Constructor
* @param _interval frequency to call monitors
* @param _mon a monitor
*/
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
monitors.push_back(&_mon);
}
/**
* Default Constructor
* @param _interval frequency to call monitors
* @param _mon a monitor
*/
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
monitors.push_back(&_mon);
}
/**
* call monitors if interval is reach by a counter
*/
void operator()(void) {
if (counter++ % interval == 0)
for (unsigned i = 0; i < monitors.size(); i++)
(*monitors[i])();
}
/**
* call monitors if interval is reach by a counter
*/
void operator()(void) {
if (counter++ % interval == 0)
for (unsigned i = 0; i < monitors.size(); i++)
(*monitors[i])();
}
/**
* last call of monitors
*/
void lastCall(void) {
for (unsigned i = 0; i < monitors.size(); i++)
monitors[i]->lastCall();
}
/**
* last call of monitors
*/
void lastCall(void) {
for (unsigned i = 0; i < monitors.size(); i++)
monitors[i]->lastCall();
}
/**
* attach another monitor to this class
* @param _mon the monitor to attach
*/
void add(eoMonitor& _mon) {
monitors.push_back(&_mon);
}
/**
* attach another monitor to this class
* @param _mon the monitor to attach
*/
void add(eoMonitor& _mon) {
monitors.push_back(&_mon);
}
/**
* @return name of the class
*/
virtual std::string className(void) const { return "moCounterMonitorSaver"; }
/**
* @return name of the class
*/
virtual std::string className(void) const {
return "moCounterMonitorSaver";
}
private :
/** interval and counter value */
unsigned int interval, counter;
/** interval and counter value */
unsigned int interval, counter;
/** monitor's vector */
std::vector<eoMonitor*> monitors;
/** monitor's vector */
std::vector<eoMonitor*> monitors;
};

View file

@ -54,20 +54,22 @@ public :
* @param _dist a distance
* @param _ref the reference solution
*/
moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref){}
moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref) {}
/**
* Compute distance between a solution and the reference solution
* @param _sol a solution
*/
virtual void operator()(EOT & _sol){
value() = dist(_sol, refSolution);
virtual void operator()(EOT & _sol) {
value() = dist(_sol, refSolution);
}
/**
* @return name of the class
*/
virtual std::string className(void) const { return "moDistanceStat"; }
virtual std::string className(void) const {
return "moDistanceStat";
}
private:
/** the distance */
@ -76,7 +78,7 @@ private:
* the reference solution does not change during the run
* it could be the best solution knowed of the problem
*/
EOT refSolution;
EOT refSolution;
};

View file

@ -54,7 +54,7 @@ public :
* @param _description a description of the stat
*/
moFitnessStat(std::string _description = "fitness"):
moStat<EOT, Fitness>(Fitness(), _description){}
moStat<EOT, Fitness>(Fitness(), _description) {}
/**
* store fitness value
@ -62,13 +62,15 @@ public :
*/
virtual void operator()(EOT & _sol)
{
value() = _sol.fitness();
value() = _sol.fitness();
}
/**
* @return the name of the class
*/
virtual std::string className(void) const { return "moFitnessStat"; }
virtual std::string className(void) const {
return "moFitnessStat";
}
};
#endif

View file

@ -45,34 +45,36 @@ template< class Neighborhood >
class moMaxNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
using moStat< EOT, Fitness >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
/**
* Set the max fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getMax();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moMaxNeighborStat"; }
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/**
* Set the max fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getMax();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moMaxNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -45,34 +45,36 @@ template< class Neighborhood >
class moMinNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, Fitness >::value;
using moStat< EOT, Fitness >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
/**
* Set the worst fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getMin();
}
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moMinNeighborStat"; }
/**
* Set the worst fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getMin();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moMinNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -40,42 +40,44 @@
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with (strictly) lower fitness than the current solution
*
*
*/
template< class Neighborhood >
class moNbInfNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbInf();
}
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat) {}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNbInfNeighborStat"; }
/**
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getNbInf();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNbInfNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -40,42 +40,44 @@
/**
*
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
* with higher fitness than the current solution
*
*
*/
template< class Neighborhood >
class moNbSupNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood with better fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbSup();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNbSupNeighborStat"; }
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat) {}
/**
* Set the number of solutions in the neighborhood with better fitness than the current solution
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getNbSup();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNbSupNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -49,187 +49,187 @@ template< class Neighborhood >
class moNeighborhoodStat : public moStat<typename Neighborhood::EOT, bool>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename Neighborhood::Neighbor Neighbor ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, bool >::value;
using moStat< EOT, bool >::value;
/**
* Default Constructor
* @param _neighborhood a neighborhood
* @param _eval an evaluation function
* @param _neighborComparator a neighbor Comparator
* @param _solNeighborComparator a comparator between a solution and a neighbor
*/
moNeighborhoodStat(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator):
moStat<EOT, bool>(true, "neighborhood"),
neighborhood(_neighborhood), eval(_eval),
neighborComparator(_neighborComparator),
solNeighborComparator(_solNeighborComparator)
{}
/**
* Default Constructor
* @param _neighborhood a neighborhood
* @param _eval an evaluation function
* @param _neighborComparator a neighbor Comparator
* @param _solNeighborComparator a comparator between a solution and a neighbor
*/
moNeighborhoodStat(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator):
moStat<EOT, bool>(true, "neighborhood"),
neighborhood(_neighborhood), eval(_eval),
neighborComparator(_neighborComparator),
solNeighborComparator(_solNeighborComparator)
{}
/**
* Compute classical statistics of a solution's neighborhood
* @param _solution the corresponding solution
*/
virtual void operator()(EOT & _solution){
Neighbor current ;
Neighbor best ;
Neighbor lowest ;
/**
* Compute classical statistics of a solution's neighborhood
* @param _solution the corresponding solution
*/
virtual void operator()(EOT & _solution) {
Neighbor current ;
Neighbor best ;
Neighbor lowest ;
if(neighborhood.hasNeighbor(_solution)){
//init the first neighbor
neighborhood.init(_solution, current);
if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor
neighborhood.init(_solution, current);
//eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, current);
// init the statistics
value() = true;
//eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, current);
mean = current.fitness();
sd = mean * mean;
nb = 1;
nbInf = 0;
nbEqual = 0;
nbSup = 0;
// init the statistics
value() = true;
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
mean = current.fitness();
sd = mean * mean;
nb = 1;
nbInf = 0;
nbEqual = 0;
nbSup = 0;
//initialize the best neighbor
best = current;
lowest = current;
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
//test all others neighbors
while (neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, current);
//eval
eval(_solution, current);
//initialize the best neighbor
best = current;
lowest = current;
mean += current.fitness();
sd += current.fitness() * current.fitness();
nb++;
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
//test all others neighbors
while (neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, current);
//eval
eval(_solution, current);
//if we found a better neighbor, update the best
if (neighborComparator(best, current))
best = current;
if (neighborComparator(current, lowest))
lowest = current;
}
mean += current.fitness();
sd += current.fitness() * current.fitness();
nb++;
max = best.fitness();
min = lowest.fitness();
if (solNeighborComparator.equals(_solution, current))
nbEqual++;
else if (solNeighborComparator(_solution, current))
nbSup++;
else
nbInf++;
mean /= nb;
if (nb > 1)
sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) );
else
sd = 0.0;
}
else{
//if _solution hasn't neighbor,
value() = false;
}
}
//if we found a better neighbor, update the best
if (neighborComparator(best, current))
best = current;
/**
* @return the worst fitness value found in the neighborhood
*/
Fitness getMin(){
return min;
}
if (neighborComparator(current, lowest))
lowest = current;
}
/**
* @return the best fitness value found in the neighborhood
*/
Fitness getMax(){
return max;
}
max = best.fitness();
min = lowest.fitness();
/**
* @return the mean fitness value of the neighborhood
*/
double getMean(){
return mean;
}
mean /= nb;
if (nb > 1)
sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) );
else
sd = 0.0;
}
else {
//if _solution hasn't neighbor,
value() = false;
}
}
/**
* @return the standard deviation value of the neighborhood
*/
double getSD(){
return sd;
}
/**
* @return the worst fitness value found in the neighborhood
*/
Fitness getMin() {
return min;
}
/**
* @return the size of the neighborhood
*/
unsigned getSize(){
return nb;
}
/**
* @return the best fitness value found in the neighborhood
*/
Fitness getMax() {
return max;
}
/**
* @return the number of neighbors having a better fitness than the current solution
*/
unsigned getNbSup(){
return nbSup;
}
/**
* @return the mean fitness value of the neighborhood
*/
double getMean() {
return mean;
}
/**
* @return the number of neighbors having the same fitness than the current solution
*/
unsigned getNbEqual(){
return nbEqual;
}
/**
* @return the number of neighbors having a worst fitness than the current solution
*/
unsigned getNbInf() {
return nbInf;
}
/**
* @return the standard deviation value of the neighborhood
*/
double getSD() {
return sd;
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNeighborhoodStat";
}
/**
* @return the size of the neighborhood
*/
unsigned getSize() {
return nb;
}
/**
* @return the number of neighbors having a better fitness than the current solution
*/
unsigned getNbSup() {
return nbSup;
}
/**
* @return the number of neighbors having the same fitness than the current solution
*/
unsigned getNbEqual() {
return nbEqual;
}
/**
* @return the number of neighbors having a worst fitness than the current solution
*/
unsigned getNbInf() {
return nbInf;
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNeighborhoodStat";
}
private:
// to explore the neighborhood
Neighborhood& neighborhood ;
moEval<Neighbor>& eval;
// to explore the neighborhood
Neighborhood& neighborhood ;
moEval<Neighbor>& eval;
// comparator betwenn solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
// comparator betwenn solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
// the stastics of the fitness
Fitness max, min;
//mean and standard deviation
double mean, sd ;
// the stastics of the fitness
Fitness max, min;
//mean and standard deviation
double mean, sd ;
// number of neighbors in the neighborhood;
unsigned int nb;
// number of neighbors in the neighborhood;
unsigned int nb;
// number of neighbors with lower, equal and higher fitness
unsigned int nbInf, nbEqual, nbSup ;
// number of neighbors with lower, equal and higher fitness
unsigned int nbInf, nbEqual, nbSup ;
};
#endif

View file

@ -40,41 +40,43 @@
/**
* From moNeighborhoodStat, to compute the neutral degree of the solution
* which is the number of solutions in the neighborhood
* with equals fitness
* which is the number of solutions in the neighborhood
* with equals fitness
*/
template< class Neighborhood >
class moNeutralDegreeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat){}
/**
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getNbEqual();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moNeutralDegreeNeighborStat"; }
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat) {}
/**
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getNbEqual();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moNeutralDegreeNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -45,35 +45,37 @@ template< class Neighborhood >
class moSecondMomentNeighborStat : public moStat<typename Neighborhood::EOT, std::pair<double, double> >
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, std::pair<double, double> >::value;
using moStat< EOT, std::pair<double, double> >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat){}
/**
* Set the average and the standard deviation of fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value().first = nhStat.getMean();
value().second = nhStat.getSD();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moSecondMomentNeighborStat"; }
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat) {}
/**
* Set the average and the standard deviation of fitness in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value().first = nhStat.getMean();
value().second = nhStat.getSD();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moSecondMomentNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -40,40 +40,42 @@
/**
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
*
*
*/
template< class Neighborhood >
class moSizeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
{
public :
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
typedef typename Neighborhood::EOT EOT ;
typedef typename EOT::Fitness Fitness ;
using moStat< EOT, unsigned >::value;
using moStat< EOT, unsigned >::value;
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat){}
/**
* Set the number of solutions in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = nhStat.getSize();
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moSizeNeighborStat"; }
/**
* Default Constructor
* @param _nhStat a neighborhoodStat
*/
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat) {}
/**
* Set the number of solutions in the neighborhood
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol) {
value() = nhStat.getSize();
}
/**
* @return the class name
*/
virtual std::string className(void) const {
return "moSizeNeighborStat";
}
private:
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
/** moNeighborhoodStat */
moNeighborhoodStat<Neighborhood> & nhStat;
};
#endif

View file

@ -40,7 +40,7 @@
/**
* The statistic which only give the current solution
* be careful, the solution is given by copy
*
*
*/
template <class EOT>
class moSolutionStat : public moStat<EOT, EOT>
@ -53,21 +53,21 @@ public :
* @param _description a description of the parameter
*/
moSolutionStat(std::string _description = "solution"):
moStat<EOT, EOT>(EOT(), _description){}
moStat<EOT, EOT>(EOT(), _description) {}
/**
* Set the solution by copy
* @param _sol the corresponding solution
*/
virtual void operator()(EOT & _sol){
value() = _sol;
virtual void operator()(EOT & _sol) {
value() = _sol;
}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moSolutionStat";
virtual std::string className(void) const {
return "moSolutionStat";
}
};

View file

@ -47,19 +47,19 @@ class moStat : public eoValueParam<T>, public moStatBase<EOT>
{
public:
/**
* Default Constructor
* @param _value a default parameter's value
* @param _description a description of the parameter
*/
/**
* Default Constructor
* @param _value a default parameter's value
* @param _description a description of the parameter
*/
moStat(T _value, std::string _description):
eoValueParam<T>(_value, _description){}
eoValueParam<T>(_value, _description) {}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moStat";
virtual std::string className(void) const {
return "moStat";
}
};

View file

@ -49,17 +49,17 @@ template <class EOT>
class moStatBase : public eoUF<EOT &, void>
{
public:
/**
* last call of a statistical operator
*/
virtual void lastCall(EOT &) {}
/**
* last call of a statistical operator
*/
virtual void lastCall(EOT &) {}
/**
* @return name of the class
*/
virtual std::string className(void) const{
return "moStatBase";
}
/**
* @return name of the class
*/
virtual std::string className(void) const {
return "moStatBase";
}
};
#endif

View file

@ -54,7 +54,7 @@ public:
*@return always true
*/
virtual bool operator()(EOT & _solution) {
return true;
return true;
}
/**