Advertisement
h-collector

Untitled

Dec 2nd, 2011
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. /**
  2.      * Calculate rankings for all chromosomes. High ranking numbers denote very fit chromosomes.
  3.      */
  4.     private function computeFitnessRankings() {
  5.         // recalc the fitness of each chromosome
  6.         for ($i = 0; $i < $this->chromosomeDim; ++$i) {
  7.             //$chromosome instanceof Chromosome;
  8.             $this->chromosomes[$i]->fitness = $this->getFitness($i);
  9.         }
  10.         for ($i = 0; $i < $this->chromosomeDim; ++$i) {
  11.             $this->chromosomes[$i]->fitnessRank = $this->getFitnessRank($this->chromosomes[$i]->fitness);
  12.         }
  13.  
  14.         $rBestFitnessVal;
  15.         $rWorstFitnessVal;
  16.         for ($i = 0; $i < $this->chromosomeDim; ++$i) {
  17.             if ($this->chromosomes[$i]->fitnessRank == $this->populationDim - 1) {
  18.                 $rBestFitnessVal = $this->chromosomes[$i]->fitness;
  19.                 $this->bestFitnessChromIndex = $i;
  20.             } else
  21.             if ($this->chromosomes[$i]->fitnessRank == 0) {
  22.                 $rWorstFitnessVal = $this->chromosomes[$i]->fitness;
  23.                 $this->worstFitnessChromIndex = $i;
  24.             }
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement