Commit 68e60f94 authored by Joseph Pallamidessi's avatar Joseph Pallamidessi

Fix an issue where the correct pressures for the offsprings and parents reduction were not used/set

parent fca1c208
...@@ -145,10 +145,10 @@ void CPopulation::optimiseOffspringPopulation(){ ...@@ -145,10 +145,10 @@ void CPopulation::optimiseOffspringPopulation(){
*/ */
void CPopulation::reducePopulation(CIndividual** population, unsigned populationSize, void CPopulation::reducePopulation(CIndividual** population, unsigned populationSize,
CIndividual** reducedPopulation, unsigned obSize, CIndividual** reducedPopulation, unsigned obSize,
CSelectionOperator* replacementOperator){ CSelectionOperator* replacementOperator,int pressure){
replacementOperator->initialize(population,replacementPressure,populationSize); replacementOperator->initialize(population,pressure,populationSize);
for( unsigned i=0 ; i<obSize ; i++ ){ for( unsigned i=0 ; i<obSize ; i++ ){
...@@ -177,7 +177,7 @@ CIndividual** CPopulation::reduceParentPopulation(unsigned obSize){ ...@@ -177,7 +177,7 @@ CIndividual** CPopulation::reduceParentPopulation(unsigned obSize){
nextGeneration = new CIndividual*[obSize]; nextGeneration = new CIndividual*[obSize];
reducePopulation(parents,actualParentPopulationSize,nextGeneration,obSize, reducePopulation(parents,actualParentPopulationSize,nextGeneration,obSize,
CPopulation::parentReductionOperator); CPopulation::parentReductionOperator,parentReductionPressure);
// free no longer needed CIndividuals // free no longer needed CIndividuals
for( unsigned i=0 ; i<actualParentPopulationSize-obSize ; i++ ) for( unsigned i=0 ; i<actualParentPopulationSize-obSize ; i++ )
...@@ -199,7 +199,7 @@ CIndividual** CPopulation::reduceOffspringPopulation(unsigned obSize){ ...@@ -199,7 +199,7 @@ CIndividual** CPopulation::reduceOffspringPopulation(unsigned obSize){
CIndividual** nextGeneration = new CIndividual*[offspringPopulationSize]; CIndividual** nextGeneration = new CIndividual*[offspringPopulationSize];
reducePopulation(offsprings,actualOffspringPopulationSize,nextGeneration,obSize, reducePopulation(offsprings,actualOffspringPopulationSize,nextGeneration,obSize,
CPopulation::offspringReductionOperator); CPopulation::offspringReductionOperator,offspringReductionPressure);
//printf("POPULATION SIZE %d\n",actualOffspringPopulationSize-obSize); //printf("POPULATION SIZE %d\n",actualOffspringPopulationSize-obSize);
// free no longer needed CIndividuals // free no longer needed CIndividuals
...@@ -296,7 +296,7 @@ void CPopulation::reduceTotalPopulation(CIndividual** elitPop){ ...@@ -296,7 +296,7 @@ void CPopulation::reduceTotalPopulation(CIndividual** elitPop){
replacementOperator->initialize(globalPopulation, replacementPressure,actualGlobalSize); replacementOperator->initialize(globalPopulation, replacementPressure,actualGlobalSize);
CPopulation::reducePopulation(globalPopulation,actualGlobalSize,params->elitSize+nextGeneration, CPopulation::reducePopulation(globalPopulation,actualGlobalSize,params->elitSize+nextGeneration,
parentPopulationSize-params->elitSize,replacementOperator); parentPopulationSize-params->elitSize,replacementOperator,replacementPressure);
for( unsigned int i=0 ; i<((int)actualGlobalSize+params->elitSize)-(int)parentPopulationSize ; i++ ) for( unsigned int i=0 ; i<((int)actualGlobalSize+params->elitSize)-(int)parentPopulationSize ; i++ )
......
...@@ -78,8 +78,7 @@ public: ...@@ -78,8 +78,7 @@ public:
virtual void evaluateOffspringPopulation(); virtual void evaluateOffspringPopulation();
virtual void optimiseOffspringPopulation(); virtual void optimiseOffspringPopulation();
CIndividual** reducePopulations(CIndividual** population, unsigned populationSize, CIndividual** reducePopulations(CIndividual** population, unsigned populationSize,CIndividual** reducedPopulation, unsigned obSize,int pressure);
CIndividual** reducedPopulation, unsigned obSize);
CIndividual** reduceParentPopulation(unsigned obSize); CIndividual** reduceParentPopulation(unsigned obSize);
CIndividual** reduceOffspringPopulation(unsigned obSize); CIndividual** reduceOffspringPopulation(unsigned obSize);
void reduceTotalPopulation(CIndividual** elitPop); void reduceTotalPopulation(CIndividual** elitPop);
...@@ -118,7 +117,7 @@ public: ...@@ -118,7 +117,7 @@ public:
static void reducePopulation(CIndividual** population, unsigned populationSize, static void reducePopulation(CIndividual** population, unsigned populationSize,
CIndividual** reducedPopulation, unsigned obSize, CIndividual** reducedPopulation, unsigned obSize,
CSelectionOperator* replacementOperator); CSelectionOperator* replacementOperator,int pressure);
void syncOutVector(); void syncOutVector();
void syncInVector(); void syncInVector();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment