Esempio n. 1
0
 public function testGetFitnessScoreMaximum()
 {
     $individual = new Individual(5);
     // Set to a binary string of 0000000000000000000000000000000000000000
     $individual->setGene(0, new Byte(0));
     $individual->setGene(1, new Byte(0));
     $individual->setGene(2, new Byte(0));
     $individual->setGene(3, new Byte(0));
     $individual->setGene(4, new Byte(0));
     // 0000000000000000000000000000000000000000 as a binary string,
     // so the score should be 40 (the max fitness).
     $score = $individual->getFitnessScore(chr(0) . chr(0) . chr(0) . chr(0) . chr(0));
     $this->assertEquals($individual->getMaxFitness(), $score);
 }