new eoAerageSizeStat class
This commit is contained in:
parent
f4351c0c11
commit
cf5533c1b2
2 changed files with 37 additions and 0 deletions
1
eo/NEWS
1
eo/NEWS
|
|
@ -15,6 +15,7 @@
|
||||||
- dual fitness class to handle feasibility of individual with guarantee that feasible fitness will always be better than unfeasible one
|
- dual fitness class to handle feasibility of individual with guarantee that feasible fitness will always be better than unfeasible one
|
||||||
- feasible fitness ratio stat
|
- feasible fitness ratio stat
|
||||||
- interquartile range stat
|
- interquartile range stat
|
||||||
|
- average size of individuals stat
|
||||||
- uniform(min,max) random function
|
- uniform(min,max) random function
|
||||||
- compatibility macros for compiling paradiseo with CUDACC
|
- compatibility macros for compiling paradiseo with CUDACC
|
||||||
- removed old multi-objective classes, deprecated by the Paradiseo-MOEO project
|
- removed old multi-objective classes, deprecated by the Paradiseo-MOEO project
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,7 @@ public :
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! A robust measure of dispersion (also called midspread or middle fifty) that is the difference between the third and the first quartile.
|
//! A robust measure of dispersion (also called midspread or middle fifty) that is the difference between the third and the first quartile.
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class eoInterquartileRangeStat : public eoStat< EOT, typename EOT::Fitness >
|
class eoInterquartileRangeStat : public eoStat< EOT, typename EOT::Fitness >
|
||||||
|
|
@ -449,6 +450,41 @@ public:
|
||||||
virtual std::string className(void) const { return "eoInterquartileRangeStat"; }
|
virtual std::string className(void) const { return "eoInterquartileRangeStat"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Compute the average size of indivudals over the population
|
||||||
|
*
|
||||||
|
* Obviously, will work only on representations that implement the (standard) "size()" method,
|
||||||
|
* like any STL container.
|
||||||
|
*/
|
||||||
|
template<class EOT>
|
||||||
|
class eoAverageSizeStat : public eoStat< EOT, double>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
using eoStat<EOT, double>::value;
|
||||||
|
|
||||||
|
eoAverageSizeStat( std::string description = "Av.Size" ) :
|
||||||
|
eoStat<EOT,double>( 0.0, description ) {} // 0 by default
|
||||||
|
|
||||||
|
virtual void operator()( const eoPop<EOT> & pop )
|
||||||
|
{
|
||||||
|
size_t pop_size = pop.size();
|
||||||
|
|
||||||
|
std::vector<size_t> sizes;
|
||||||
|
sizes.reserve(pop_size);
|
||||||
|
|
||||||
|
for( unsigned int i=0, s = pop_size; i<s; ++i ) {
|
||||||
|
sizes.push_back( pop[i].size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t sum = std::accumulate( sizes.begin(), sizes.end(), 0 );
|
||||||
|
|
||||||
|
value() = static_cast<double>(sum) / static_cast<double>(pop_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string className(void) const { return "eoAverageSizeStat"; }
|
||||||
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue