Added symbolic regression, which tests combined ops as well

This commit is contained in:
mac 2000-08-18 08:44:22 +00:00
commit 8ae796ab28
14 changed files with 161 additions and 199 deletions

View file

@ -185,78 +185,5 @@ class eoPop: public vector<EOT>, public eoObject, public eoPersistent
};
/**
Keeps and calculates information about a population such
as the sum of fitnesses and whether the population is sorted.
It can be used to cache information about a population between
calls of functors, see for instance how this makes eoProportional
just this tat more efficient
@see eoSelectOne, eoSelect, eoProportional
template <class EOT>
class eoPopStats
{
public :
typedef typename EOT::Fitness FitnessType;
/// Initialize by stating nothing is known
eoPopStats() :
sum_fitness_calculated(false),
pop_sorted_calculated(false)
{}
/// Call this function after the pop might have/is changed
void reset()
{
sum_fitness_calculated = false;
pop_sorted_calculated = false;
}
/// Calculate sum_fitness or return cached value
FitnessType get_sum_fitness(const eoPop<EOT>& _pop)
{
if (sum_fitness_calculated)
return sum_fitness;
sum_fitness = 0.0;
for (int i = 0; i < _pop.size(); ++i)
{
sum_fitness += _pop[i].fitness();
}
sum_fitness_calculated = true;
return sum_fitness;
}
/// Check if the pop is sorted or return cached_value
bool is_pop_sorted(const eoPop<EOT>& _pop)
{
if (pop_sorted_calculated)
return pop_sorted;
int i;
for (i = 1; i < _pop.size(); ++i)
{
if (!(_pop[i-1] < _pop[i]))
{ // not in sort order
break;
}
}
pop_sorted = (i == _pop.size());
pop_sorted_calculated = true;
return pop_sorted;
}
bool sum_fitness_calculated;
FitnessType sum_fitness;
bool pop_sorted_calculated;
bool pop_sorted;
};
*/
#endif