Example #1
0
 function __construct($populationSize, $initialise = false)
 {
     if (!isset($populationSize) || $populationSize == 0) {
         die("Must specify a populationsize > 0");
     }
     for ($i = 0; $i < $populationSize; $i++) {
         $this->people[$i] = new individual();
     }
     //instantiate a new object
     // Initialise population
     if ($initialise) {
         // Loop and create individuals
         for ($i = 0; $i < count($this->people); $i++) {
             $new_person = new individual();
             $new_person->generateIndividual(count(fitnesscalc::$solution));
             $this->saveIndividual($i, $new_person);
         }
     }
 }