Ssmo2.cpp
Go to the documentation of this file.00001 00009 #include <Ssmo2.h> 00010 00016 Ssmo2::Ssmo2(MultiobjectiveProblem * problemToSolve, 00017 MutationOperator mutationOperator) : 00018 Ssmo(problemToSolve, mutationOperator) { 00019 00020 sumOfFrequencyValues_ = new int[problem_->numberOfVariables_] ; 00021 sumOfReverseFrequencyValues_ = new int[problem_->numberOfVariables_] ; 00022 frequency_ = new int*[numberOfSubranges_] ; 00023 reverseFrequency_ = new int*[numberOfSubranges_] ; 00024 if ((!frequency_) || (!reverseFrequency_) || 00025 (!sumOfFrequencyValues_) || (!sumOfReverseFrequencyValues_)) { 00026 cerr << "Ssmo2::Ssmo2->error when requesting memory " << endl ; 00027 exit(-1) ; 00028 } // if 00029 00030 for (int i = 0; i < problem_->numberOfVariables_; i++) 00031 sumOfFrequencyValues_[i] = 0 ; 00032 00033 for (int i = 0; i < numberOfSubranges_; i++) { 00034 frequency_[i] = new int[problem_->numberOfVariables_] ; 00035 reverseFrequency_[i] = new int[problem_->numberOfVariables_] ; 00036 if (!frequency_[i] || !reverseFrequency_[i]) { 00037 cerr << "Ssmo2::Ssmo2->error when requesting memory " << endl ; 00038 } // if 00039 for (int j = 0; j < problem_->numberOfVariables_; j++) 00040 frequency_[i][j] = 0 ; 00041 } // for 00042 00043 populationRanking_ = new Ranking(population_) ; 00044 } // Ssmo2::Ssmo2 00045 00051 Ssmo2::~Ssmo2() { 00052 delete populationRanking_ ; 00053 } // Ssmo2::~Ssmo2 00054 00058 Individual * Ssmo2::diversificationGeneration() { 00059 Individual * individual ; 00060 00061 individual = new Individual(problem_, &random_) ; 00062 if (!individual) { 00063 cerr << "Ssmo2::diversificationGeneration-> error creating individual" ; 00064 cerr << endl ; 00065 exit(-1) ; 00066 } // if 00067 00068 if (problem_->variableType_[0] == REAL) { 00069 double value ; 00070 int range ; 00071 00072 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00073 sumOfReverseFrequencyValues_[i] = 0 ; 00074 for (int j = 0; j < numberOfSubranges_; j++) { 00075 reverseFrequency_[j][i] = sumOfFrequencyValues_[i] - frequency_[j][i] ; 00076 sumOfReverseFrequencyValues_[i] += reverseFrequency_[j][i] ; 00077 } // for 00078 00079 if (sumOfReverseFrequencyValues_[i] == 0) 00080 range = random_.rnd(0, numberOfSubranges_ - 1) ; 00081 else { 00082 value = random_.rnd(0, sumOfReverseFrequencyValues_[i] - 1) ; 00083 range = 0 ; 00084 //cout << "V = " << value << endl ; 00085 while (value > reverseFrequency_[range][i]) { 00086 value -= reverseFrequency_[range][i] ; 00087 range++ ; 00088 } // while 00089 } // else 00090 //cout << "range = " << range << endl ; 00091 if (range >= numberOfSubranges_) { 00092 cerr << "Ssmo2::diversificationGeneration-> invalid range value: " 00093 << range ; 00094 cerr << ". Value must be between 0 and " 00095 << numberOfSubranges_ << " - 1 " ; 00096 cerr << endl ; 00097 exit(-1) ; 00098 } // if 00099 00100 frequency_[range][i] ++ ; 00101 sumOfFrequencyValues_[i] ++ ; 00102 00103 double low = problem_->lowerLimit_[i] + range*(problem_->upperLimit_[i] - 00104 problem_->lowerLimit_[i]) / numberOfSubranges_ ; 00105 double high = low + (problem_->upperLimit_[i] - 00106 problem_->lowerLimit_[i]) / numberOfSubranges_ ; 00107 value = random_.rndreal(low, high) ; 00108 ((RealGene *)(individual->chromosome_->gene_[i]))->allele_ = value ; 00109 } // for 00110 } // if 00111 else if (problem_->variableType_[0] == INTEGER) { 00112 int value ; 00113 int range ; 00114 00115 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00116 sumOfReverseFrequencyValues_[i] = 0 ; 00117 for (int j = 0; j < numberOfSubranges_; j++) { 00118 reverseFrequency_[j][i] = sumOfFrequencyValues_[i] - frequency_[j][i] ; 00119 sumOfReverseFrequencyValues_[i] += reverseFrequency_[j][i] ; 00120 } // for 00121 00122 if (sumOfReverseFrequencyValues_[i] == 0) 00123 range = random_.rnd(0, numberOfSubranges_ - 1) ; 00124 else { 00125 value = random_.rnd(0, sumOfReverseFrequencyValues_[i] - 1) ; 00126 range = 0 ; 00127 while (value > reverseFrequency_[range][i]) { 00128 value -= reverseFrequency_[range][i] ; 00129 range++ ; 00130 } // while 00131 } // else 00132 if (range >= numberOfSubranges_) { 00133 cerr << "Ssmo2::diversificationGeneration-> invalid range value: " 00134 << range ; 00135 cerr << ". Value must be between 0 and " 00136 << numberOfSubranges_ << " - 1 " ; 00137 cerr << endl ; 00138 exit(-1) ; 00139 } // if 00140 00141 frequency_[range][i] ++ ; 00142 sumOfFrequencyValues_[i] ++ ; 00143 00144 int low = (int) problem_->lowerLimit_[i] + 00145 range*((int) problem_->upperLimit_[i] - 00146 (int)problem_->lowerLimit_[i]) / numberOfSubranges_ ; 00147 int high = (int) low + ((int)problem_->upperLimit_[i] - 00148 (int)problem_->lowerLimit_[i]) / numberOfSubranges_ ; 00149 value = random_.rnd(low, high) ; 00150 ((IntegerGene *)(individual->chromosome_->gene_[i]))->allele_ = value ; 00151 } // for 00152 00153 } // else if 00154 else { 00155 cerr << "AbSS3::diversificationGeneration -> this method is not valid for " 00156 << "a representation of type " << problem_->variableType_[0] 00157 << endl ; 00158 exit(-1) ; 00159 } // else 00160 return individual ; 00161 } // Ssmo2::diversificationGeneration 00162 00174 Individual * Ssmo2::improvement(Individual * individual) { 00175 00176 Individual * mutantIndividual ; 00177 int result ; 00178 00179 for (int i = 0; i < improvementIterations_; i++) { 00180 mutantIndividual = new Individual(individual) ; 00181 int mutations = this->mutation(mutantIndividual) ; 00182 numberOfMutations_ ++ ; 00183 00184 if (mutations > 0) { 00185 if (problem_->numberOfConstraints_ > 0) { 00186 problem_->evaluateConstraints(mutantIndividual) ; 00187 result = individual->numberOfViolatedConstraintsTest(mutantIndividual) ; 00188 if (result == 0) { 00189 problem_->evaluate(mutantIndividual) ; 00190 numberOfFitnessEvaluations_ ++ ; 00191 result = individual->dominanceTest(mutantIndividual) ; 00192 } // if 00193 else if (result == -1) { 00194 problem_->evaluate(mutantIndividual) ; 00195 numberOfFitnessEvaluations_ ++ ; 00196 } // else if 00197 } // if 00198 else { 00199 problem_->evaluate(mutantIndividual) ; 00200 numberOfFitnessEvaluations_ ++ ; 00201 result = individual->dominanceTest(mutantIndividual) ; 00202 } // else 00203 00204 if (result == -1) { // the mutant individual dominates 00205 delete individual ; 00206 individual = mutantIndividual ; 00207 } // if 00208 else if (result == 0) { // both individuals are non-dominated 00209 // The mutant individual is added to the population 00210 addImprovedIndividual(population_, mutantIndividual) ; 00211 } // else if 00212 else { // the mutant individual is dominated 00213 delete mutantIndividual ; // delete mutantIndividual ; 00214 } // else 00215 } // if 00216 else 00217 delete mutantIndividual ; 00218 } // for 00219 00220 return individual ; 00221 00222 } // Ssmo2::improvement 00223 00230 void Ssmo2::referenceSetUpdate(bool rebuild) { 00231 if (rebuild) { 00232 if (qualityReferenceSet_->getPopulationSize() != 0) { 00233 cerr << "ERROR" << endl ; 00234 exit(-1) ; 00235 } 00236 Population * centroids ; 00237 // Apply ranking the population of solutions 00238 populationRanking_->rankPopulation(population_->getPopulationSize()) ; 00239 // Obtain qualityReferenceSetSize_ (or less if not possible) centroids 00240 populationRanking_->nonDominatedFront_[0]->clustering(qualityReferenceSetSize_, 00241 ¢roids) ; 00242 // The obtained centroids is the new RefSet1 00243 for (int i = 0; i < centroids->getPopulationSize(); i++) { 00244 qualityReferenceSet_->addIndividual(centroids->extractIth(0)) ; 00245 problem_->evaluateConstraints(qualityReferenceSet_->getIth(i)) ; 00246 problem_->evaluate(qualityReferenceSet_->getIth(i)) ; 00247 numberOfFitnessEvaluations_ ++ ; 00248 } // for 00249 delete centroids ; 00250 00251 // Compute minimum distances to RefSet1 00252 for (int i = 0; i < population_->getPopulationSize(); i++) 00253 this->distanceToPopulation(qualityReferenceSet_, 00254 (Individual *)population_->getIth(i)) ; 00255 00256 // Build RefSet2 00257 for (int i = 0; i < diversityReferenceSetSize_; i++) { 00258 // Find the solution with maximum minimum distance 00259 double maximumMinimumDistance = -1.0 ; 00260 int index ; 00261 for (int j = 0; j < population_->getPopulationSize(); j++) { 00262 if (((Individual *)population_->getIth(j))->distance_ > 00263 maximumMinimumDistance) { 00264 maximumMinimumDistance = ((Individual *)population_->getIth(j))->distance_ ; 00265 index = j ; 00266 } // if 00267 } // for 00268 Individual * newIndividual ; 00269 newIndividual = (Individual *)population_->extractIth(index) ; 00270 diversityReferenceSet_->addIndividual(newIndividual) ; 00271 00272 // Update minimum distances 00273 for (int j = 0; j < population_->getPopulationSize(); j++) { 00274 double tmp = 0.0 ; 00275 for (int k = 0; k < problem_->numberOfFunctions_; k++) 00276 tmp += pow(newIndividual->fitness_[k] - 00277 population_->getIth(j)->fitness_[k], 00278 2.0) ; 00279 if (tmp < ((Individual *)population_->getIth(j))->distance_) 00280 ((Individual *)population_->getIth(j))->distance_ = tmp ; 00281 } // for 00282 } // for 00283 00284 // Update distances in RefSet2 00285 for (int i = 0; i < diversityReferenceSet_->getPopulationSize(); i++) { 00286 int j = 0 ; 00287 while ((j != i) && (j < diversityReferenceSet_->getPopulationSize())) { 00288 double tmp = 0.0 ; 00289 for (int k = 0; k < problem_->numberOfFunctions_; k++) 00290 tmp += pow(diversityReferenceSet_->getIth(i)->fitness_[k]- 00291 diversityReferenceSet_->getIth(j)->fitness_[k], 00292 2.0) ; 00293 Individual * individual = (Individual *)diversityReferenceSet_->getIth(i) ; 00294 if (individual->distance_ > tmp) 00295 individual->distance_ = tmp ; 00296 j++ ; 00297 } // while 00298 } // for 00299 } // if 00300 else { 00301 int result ; 00302 00303 Individual * improvedIndividual ; 00304 Individual * refSetIndividual ; 00305 00306 int size = improvedCombinedSolutions_->getPopulationSize() ; 00307 for (int i = 0; i < size; i++) { 00308 improvedIndividual = (Individual *)improvedCombinedSolutions_->extractIth(0) ; 00309 00310 bool improvedIndividualIsDominated = false ; 00311 int index = 0 ; 00312 00313 while (index < qualityReferenceSet_->getPopulationSize()) { 00314 refSetIndividual = (Individual *)qualityReferenceSet_->getIth(index) ; 00315 00316 if (problem_->numberOfConstraints_ > 0) { 00317 result = refSetIndividual->numberOfViolatedConstraintsTest(improvedIndividual) ; 00318 if (result == 0) 00319 result = refSetIndividual->dominanceTest(improvedIndividual) ; 00320 else if (result == 1) 00321 improvedIndividualIsDominated = true ; 00322 } // if 00323 else 00324 result = refSetIndividual->dominanceTest(improvedIndividual) ; 00325 00326 if (result == -1) // the improved individual dominates 00327 qualityReferenceSet_->deleteIth(index) ; 00328 else if (result == 0) { // both individuals are non-dominated 00329 index ++ ; 00330 } 00331 else { // the improved individual is dominated 00332 improvedIndividualIsDominated = true ; 00333 index ++ ; 00334 } // else 00335 } // while 00336 00337 if (!improvedIndividualIsDominated) { 00338 if (qualityReferenceSet_->getPopulationSize() < 00339 (qualityReferenceSetSize_-1)) { 00340 qualityReferenceSet_->addIndividual(improvedIndividual) ; 00341 } // if 00342 else { 00343 addImprovedIndividual(population_, improvedIndividual) ; 00344 } // else 00345 } // if 00346 else { // Try to insert individual in RefSet2 00347 00348 distanceToPopulation(qualityReferenceSet_, improvedIndividual) ; 00349 distanceToPopulation(diversityReferenceSet_, improvedIndividual) ; 00350 00351 // Search the individual with worst distance in refset2 00352 int index = 0 ; 00353 double worstDistance = 0.0 ; 00354 for (int i = 0; i < diversityReferenceSet_->getPopulationSize(); i++) { 00355 Individual * individual = (Individual *)diversityReferenceSet_->getIth(i) ; 00356 if (individual->distance_ > worstDistance) { 00357 worstDistance = individual->distance_ ; 00358 index = i ; 00359 } // if 00360 } // for 00361 if (improvedIndividual->distance_ < worstDistance) { 00362 diversityReferenceSet_->deleteIth(index) ; 00363 diversityReferenceSet_->addIndividual(improvedIndividual) ; 00364 } // if 00365 else 00366 delete improvedIndividual ; 00367 } // else 00368 } // for 00369 } // else 00370 } // Ssmo2::referenceSetUpdate 00371 00375 int Ssmo2::subsetGeneration() { 00376 int newIndividuals ; 00377 bool finished ; 00378 00379 newIndividuals = 0 ; 00380 finished = false ; 00381 00382 // Pairs of individuals belonging to RefSet1 00383 for (int i = 0; i < qualityReferenceSet_->getPopulationSize(); i++) { 00384 for (int j = i + 1 ; j < qualityReferenceSet_->getPopulationSize(); j++) { 00385 Individual * parent1 ; 00386 Individual * parent2 ; 00387 parent1 = (Individual *)(qualityReferenceSet_->getIth(i)) ; 00388 parent2 = (Individual *)(qualityReferenceSet_->getIth(j)) ; 00389 00390 if (!parent1->hasBeenSelected_ || !parent2->hasBeenSelected_) { 00391 solutionCombination(parent1, parent2, 4) ; 00392 newIndividuals += 4 ; 00393 parent1->hasBeenSelected_ = true ; 00394 parent2->hasBeenSelected_ = true ; 00395 } // if 00396 } // for 00397 } // for 00398 00399 // Pairs of individuals belonging to RefSet2 00400 for (int i = 0; i < diversityReferenceSet_->getPopulationSize(); i++) { 00401 for (int j = i + 1 ; j < diversityReferenceSet_->getPopulationSize(); j++) { 00402 Individual * parent1 ; 00403 Individual * parent2 ; 00404 parent1 = (Individual *)(diversityReferenceSet_->getIth(i)) ; 00405 parent2 = (Individual *)(diversityReferenceSet_->getIth(j)) ; 00406 00407 if (!parent1->hasBeenSelected_ || !parent2->hasBeenSelected_) { 00408 solutionCombination(parent1, parent2, 2) ; 00409 newIndividuals += 2 ; 00410 parent1->hasBeenSelected_ = true ; 00411 parent2->hasBeenSelected_ = true ; 00412 } // if 00413 } // for 00414 } // for 00415 00416 /* 00417 // Pairs of individuals belonging to RefSet1 and RefSet2 00418 for (int i = 0; i < qualityReferenceSet_->getPopulationSize(); i++) { 00419 for (int j = 0 ; j < diversityReferenceSet_->getPopulationSize(); j++) { 00420 Individual * parent1 ; 00421 Individual * parent2 ; 00422 parent1 = (Individual *)(qualityReferenceSet_->getIth(i)) ; 00423 parent2 = (Individual *)(diversityReferenceSet_->getIth(j)) ; 00424 00425 if (!parent1->hasBeenSelected_ || !parent2->hasBeenSelected_) { 00426 solutionCombination(parent1, parent2, 3) ; 00427 newIndividuals += 3 ; 00428 //parent1->hasBeenSelected_ = true ; 00429 //parent2->hasBeenSelected_ = true ; 00430 } // if 00431 } // for 00432 } // for 00433 00434 00435 for (int i = 0; i < diversityReferenceSet_->getPopulationSize(); i++) { 00436 Individual * individual ; 00437 individual = (Individual *)(diversityReferenceSet_->getIth(i)) ; 00438 individual->hasBeenSelected_ = true ; 00439 } // for 00440 for (int i = 0; i < qualityReferenceSet_->getPopulationSize(); i++) { 00441 Individual * individual ; 00442 individual = (Individual *)(qualityReferenceSet_->getIth(i)) ; 00443 individual->hasBeenSelected_ = true ; 00444 } // for 00445 */ 00446 00447 return newIndividuals ; 00448 } // Ssmo2::subsetGeneration 00449 00456 void Ssmo2::solutionCombination(Individual * parent1, 00457 Individual * parent2, 00458 int numberOfChildren) { 00459 // This piece of code implements the linear combination crossover of 00460 // scatter search. 00461 00462 double random ; 00463 double chooseC1orC3 ; 00464 double * distance = new double[problem_->numberOfVariables_] ; 00465 00466 Individual ** children ; 00467 00468 children = new Individual*[numberOfChildren] ; 00469 if (!children) { 00470 cerr << "AbYSS3::solutionCombination->error when requesting memory" << endl ; 00471 exit(-1) ; 00472 } // if 00473 for (int i = 0; i < numberOfChildren; i++) { 00474 children[i] = new Individual(problem_, &random_) ; 00475 if (!children[i]) { 00476 cerr << "AbYSS3::solutionCombination->error when requesting memory for " 00477 << "child " << i << endl ; 00478 exit(-1) ; 00479 } // if 00480 } // for 00481 00482 for (int i = 0; i < problem_->numberOfVariables_; i++) 00483 distance[i] = (((RealGene *)(parent1->chromosome_->gene_[i]))->allele_ - 00484 ((RealGene *)(parent2->chromosome_->gene_[i]))->allele_) / 00485 2.0 ; 00486 00487 // Generate C2 00488 random = random_.rndreal(0.0, 1.0) ; 00489 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00490 double x ; 00491 00492 x = ((RealGene *)(parent1->chromosome_->gene_[i]))->allele_ + 00493 random * distance[i] ; 00494 if (x > problem_->upperLimit_[i]) 00495 x = problem_->upperLimit_[i] ; 00496 else if ( x < problem_->lowerLimit_[i]) 00497 x = problem_->lowerLimit_[i] ; 00498 00499 ((RealGene *)(children[0]->chromosome_->gene_[i]))->allele_ = x ; 00500 } // for 00501 00502 // Generate C1 or C3 00503 if (numberOfChildren >= 2) { 00504 chooseC1orC3 = random_.rndreal(0.0, 1.0) ; 00505 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00506 double x ; 00507 if (chooseC1orC3 <= 0.5) 00508 x = ((RealGene *)(parent1->chromosome_->gene_[i]))->allele_ - 00509 random * distance[i] ; 00510 else 00511 x = ((RealGene *)(parent2->chromosome_->gene_[i]))->allele_ + 00512 random * distance[i] ; 00513 if (x > problem_->upperLimit_[i]) 00514 x = problem_->upperLimit_[i] ; 00515 else if ( x < problem_->lowerLimit_[i]) 00516 x = problem_->lowerLimit_[i] ; 00517 00518 ((RealGene *)(children[1]->chromosome_->gene_[i]))->allele_ = x ; 00519 } // for 00520 } // if 00521 00522 // Generate the other one (C1 or C3) 00523 if (numberOfChildren >= 3) { 00524 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00525 double x ; 00526 if (chooseC1orC3 > 0.5) 00527 x = ((RealGene *)(parent1->chromosome_->gene_[i]))->allele_ - 00528 random * distance[i] ; 00529 else 00530 x = ((RealGene *)(parent2->chromosome_->gene_[i]))->allele_ + 00531 random * distance[i] ; 00532 if (x > problem_->upperLimit_[i]) 00533 x = problem_->upperLimit_[i] ; 00534 else if ( x < problem_->lowerLimit_[i]) 00535 x = problem_->lowerLimit_[i] ; 00536 00537 ((RealGene *)(children[2]->chromosome_->gene_[i]))->allele_ = x ; 00538 } // for 00539 } // if 00540 00541 // Generate C4 00542 if (numberOfChildren == 4) { 00543 random = random_.rndreal(0.0, 1.0) ; 00544 for (int i = 0; i < problem_->numberOfVariables_; i++) { 00545 double x ; 00546 x = ((RealGene *)(parent1->chromosome_->gene_[i]))->allele_ + 00547 random * distance[i] ; 00548 if (x > problem_->upperLimit_[i]) 00549 x = problem_->upperLimit_[i] ; 00550 else if ( x < problem_->lowerLimit_[i]) 00551 x = problem_->lowerLimit_[i] ; 00552 00553 ((RealGene *)(children[3]->chromosome_->gene_[i]))->allele_ = x ; 00554 } // for 00555 } // if 00556 00557 for (int i = 0; i < numberOfChildren; i++) 00558 combinedSolutions_->addIndividual(children[i]) ; 00559 00560 delete [] distance ; 00561 delete [] children ; 00562 } // Ssmo2:solutionCombination 00563 00568 int Ssmo2::removeDominatedIndividuals(Population * population) { 00569 int counter ; 00570 int index ; 00571 00572 if (population_->getPopulationSize() < populationSize_) 00573 counter = population_->getPopulationSize() ; 00574 else 00575 counter = populationSize_ ; 00576 populationRanking_->rankPopulation(counter) ; 00577 00578 if (populationRanking_->nonDominatedFront_[0]->getPopulationSize() > populationSize_) { 00579 populationRanking_->nonDominatedFront_[0]->crowdingDistanceAssignment() ; 00580 populationRanking_->nonDominatedFront_[0]->sortByRankAndCrowding() ; 00581 populationRanking_->copyFrontToPopulation(0, 00582 populationSize_, 00583 dummyPopulation_) ; 00584 } // if 00585 else { 00586 populationRanking_->copyFrontToPopulation(0, 00587 populationRanking_->nonDominatedFront_[0]->getPopulationSize(), 00588 dummyPopulation_) ; 00589 } // else 00590 00591 counter = population_->getPopulationSize() - 00592 dummyPopulation_->getPopulationSize() ; 00593 population_->removeAllIndividuals() ; 00594 while (dummyPopulation_->getPopulationSize() > 0) { 00595 int last = dummyPopulation_->getPopulationSize() - 1 ; 00596 population_->addIndividual(dummyPopulation_->extractIth(last)) ; 00597 } // while 00598 00599 return counter ; 00600 } // Ssmo2::removeDominatedIndividuals 00601 00609 int Ssmo2::removeIndividuals(Population * population, 00610 int finalPopulationSize) { 00611 int counter ; 00612 int index ; 00613 int individualsRemaining ; 00614 int frontCounter ; 00615 int individuals ; 00616 00617 if (population_->getPopulationSize() < finalPopulationSize) 00618 counter = population_->getPopulationSize() ; 00619 else 00620 counter = finalPopulationSize ; 00621 00622 populationRanking_->rankPopulation(counter) ; 00623 00624 frontCounter = 0 ; 00625 individualsRemaining = counter ; 00626 while (individualsRemaining > 0) { 00627 // Crowding 00628 populationRanking_->nonDominatedFront_[frontCounter]->crowdingDistanceAssignment() ; 00629 individuals = populationRanking_->nonDominatedFront_[frontCounter]->getPopulationSize() ; 00630 if (individuals <= individualsRemaining) { 00631 populationRanking_->copyFrontToPopulation(frontCounter, 00632 individuals, 00633 dummyPopulation_); 00634 } // if 00635 else { 00636 // Sorting 00637 populationRanking_->nonDominatedFront_[frontCounter]->sortByRankAndCrowding() ; 00638 00639 individuals = individualsRemaining ; 00640 populationRanking_->copyFrontToPopulation(frontCounter, 00641 individuals, 00642 dummyPopulation_) ; 00643 } // else 00644 individualsRemaining -= individuals ; 00645 frontCounter ++ ; 00646 } // while 00647 00648 population_->removeAllIndividuals() ; 00649 while (dummyPopulation_->getPopulationSize() > 0) { 00650 int last = dummyPopulation_->getPopulationSize() - 1 ; 00651 population_->addIndividual(dummyPopulation_->extractIth(last)) ; 00652 } // while 00653 00654 return counter ; 00655 } // Ssmo2::removeIndividuals 00656