EvolvingObjects
eoScalarFitness< ScalarType, Compare > Class Template Reference

Wraps a scalar fitness values such as a double or int, with the option of maximizing (using less<ScalarType>) or minimizing (using greater<ScalarType>) More...

#include <eoScalarFitness.h>

List of all members.

Public Member Functions

 eoScalarFitness (const eoScalarFitness &other)
 eoScalarFitness (const ScalarType &v)
eoScalarFitnessoperator= (const eoScalarFitness &other)
eoScalarFitnessoperator= (const ScalarType &v)
 operator ScalarType (void) const
 Conversion operator: it permits to use a fitness instance as its scalar type, if needed.
bool operator< (const eoScalarFitness &other) const
 Comparison, using less by default.
bool operator< (const ScalarType &other) const
 Comparison, using less by default.
bool operator> (const eoScalarFitness< ScalarType, Compare > &y) const
bool operator<= (const eoScalarFitness< ScalarType, Compare > &y) const
bool operator>= (const eoScalarFitness< ScalarType, Compare > &y) const

Private Attributes

ScalarType value

Detailed Description

template<class ScalarType, class Compare>
class eoScalarFitness< ScalarType, Compare >

Wraps a scalar fitness values such as a double or int, with the option of maximizing (using less<ScalarType>) or minimizing (using greater<ScalarType>)

It overrides operator<() to use the Compare template argument. Thus, if you need to compare if an indiv1 is "better" than an indiv2, you can use: if( indiv1 > indiv2 ) { // indiv1 is better } else { // indiv2 is better }

Suitable constructors and assignments and casts are defined to work with this quantity as if it were a ScalarType.

Examples:
t-eoEasyPSO.cpp, t-eofitness.cpp, t-eoSSGA.cpp, t-eoSymreg.cpp, and t-eoSyncEasyPSO.cpp.

Definition at line 52 of file eoScalarFitness.h.


Member Function Documentation

template<class ScalarType, class Compare>
eoScalarFitness< ScalarType, Compare >::operator ScalarType ( void  ) const [inline]

Conversion operator: it permits to use a fitness instance as its scalar type, if needed.

 For example, this is possible: eoScalarFitness<double,std::less<double> > fit; double val = 1.0; fit = val; val = fit;

Definition at line 72 of file eoScalarFitness.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends