Added functions to control crossover rate and type

This commit is contained in:
2018-04-14 01:07:56 -07:00
parent 5f0b8a4c13
commit b0da515139
5 changed files with 92 additions and 10 deletions

View File

@@ -149,6 +149,34 @@ namespace BitEvolver
return fitness_average;
}
//
void Population::SetCrossoverPoint(double p)
{
//
this->crossover_point = p;
}
//
double Population::GetCrossoverPoint()
{
//
return this->crossover_point;
}
//
void Population::SetCrossoverType(Enums::CrossoverType t)
{
//
this->crossover_type = t;
}
//
Enums::CrossoverType Population::GetCrossoverType()
{
//
return this->crossover_type;
}
//
void Population::SetMutationRate(double r)
{
@@ -156,6 +184,13 @@ namespace BitEvolver
this->mutation_rate = r;
}
//
double Population::GetMutationRate()
{
//
return this->mutation_rate;
}
//
void Population::Evolve()
{
@@ -332,7 +367,12 @@ namespace BitEvolver
papa = this->PickChromosomeForBreeding();
//
kiddo = this->breeder->Breed(mama, papa, BIT_EVOLVER_POPULATION_DEFAULT_CROSSOVER, this->mutation_rate);
kiddo = this->breeder->Breed(
mama, papa,
this->crossover_type,
this->crossover_point,
this->mutation_rate
);
return kiddo;
}