* eoFitContinue: using of _pop.best_element().fitness() instead of pop.nth_element_fitness(0)
This commit is contained in:
parent
12a631cfb1
commit
e42a1dae74
1 changed files with 19 additions and 14 deletions
|
|
@ -26,12 +26,16 @@
|
||||||
#define _eoFitContinue_h
|
#define _eoFitContinue_h
|
||||||
|
|
||||||
#include <eoContinue.h>
|
#include <eoContinue.h>
|
||||||
|
#include <utils/eoLogger.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fitness continuation:
|
Fitness continuation:
|
||||||
|
|
||||||
Continues until the maximum fitness level is reached.
|
Continues until the optimum fitness level is reached.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//! all types which derive from eoScalarFitness is able to compare well via the operator override ( <, >, <=, ...)
|
||||||
|
|
||||||
template< class EOT>
|
template< class EOT>
|
||||||
class eoFitContinue: public eoContinue<EOT> {
|
class eoFitContinue: public eoContinue<EOT> {
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,26 +44,27 @@ public:
|
||||||
typedef typename EOT::Fitness FitnessType;
|
typedef typename EOT::Fitness FitnessType;
|
||||||
|
|
||||||
/// Ctor
|
/// Ctor
|
||||||
eoFitContinue( const FitnessType _maximum)
|
eoFitContinue( const FitnessType _optimum)
|
||||||
: eoContinue<EOT> (), maximum( _maximum ) {};
|
: eoContinue<EOT> (), optimum( _optimum ) {};
|
||||||
|
|
||||||
/** Returns false when a fitness criterium is reached. Assumes pop is not sorted! */
|
/** Returns false when a fitness criterium is reached. Assumes pop is not sorted! */
|
||||||
virtual bool operator() ( const eoPop<EOT>& _pop )
|
virtual bool operator() ( const eoPop<EOT>& _pop )
|
||||||
{
|
{
|
||||||
FitnessType bestCurrentFitness = _pop.nth_element_fitness(0);
|
//FitnessType bestCurrentFitness = _pop.nth_element_fitness(0);
|
||||||
if (bestCurrentFitness >= maximum)
|
FitnessType bestCurrentFitness = _pop.best_element().fitness();
|
||||||
{
|
if (bestCurrentFitness >= optimum)
|
||||||
std::cout << "STOP in eoFitContinue: Best fitness has reached " <<
|
{
|
||||||
bestCurrentFitness << "\n";
|
eo::log << eo::logging << "STOP in eoFitContinue: Best fitness has reached " <<
|
||||||
return false;
|
bestCurrentFitness << "\n";
|
||||||
}
|
return false;
|
||||||
return true;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string className(void) const { return "eoFitContinue"; }
|
virtual std::string className(void) const { return "eoFitContinue"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FitnessType maximum;
|
FitnessType optimum;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue