Added functions to control crossover rate and type
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user