Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Calculate rankings for all chromosomes. High ranking numbers denote very fit chromosomes.
- */
- private function computeFitnessRankings() {
- // recalc the fitness of each chromosome
- for ($i = 0; $i < $this->chromosomeDim; ++$i) {
- //$chromosome instanceof Chromosome;
- $this->chromosomes[$i]->fitness = $this->getFitness($i);
- }
- for ($i = 0; $i < $this->chromosomeDim; ++$i) {
- $this->chromosomes[$i]->fitnessRank = $this->getFitnessRank($this->chromosomes[$i]->fitness);
- }
- $rBestFitnessVal;
- $rWorstFitnessVal;
- for ($i = 0; $i < $this->chromosomeDim; ++$i) {
- if ($this->chromosomes[$i]->fitnessRank == $this->populationDim - 1) {
- $rBestFitnessVal = $this->chromosomes[$i]->fitness;
- $this->bestFitnessChromIndex = $i;
- } else
- if ($this->chromosomes[$i]->fitnessRank == 0) {
- $rWorstFitnessVal = $this->chromosomes[$i]->fitness;
- $this->worstFitnessChromIndex = $i;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement