Exemple #1
0
 private static function crossover($indiv1, $indiv2)
 {
     $newSol = new individual();
     //create a offspring
     // Loop through genes
     for ($i = 0; $i < $indiv1->size(); $i++) {
         // Crossover at which point 0..1 , .50 50% of time
         if (algorithm::random() <= algorithm::$uniformRate) {
             $newSol->setGene($i, $indiv1->getGene($i));
         } else {
             $newSol->setGene($i, $indiv2->getGene($i));
         }
     }
     return $newSol;
 }