コード例 #1
0
ファイル: _modules.php プロジェクト: angelogarcia/chits
	}
}
if (file_exists('../modules/philhealth/class.philhealth.php')) {
	include '../modules/philhealth/class.philhealth.php';
	$philhealth = new philhealth;
	if (!$module->activated('philhealth') && $initmod) {
		$philhealth->init_sql();
		$philhealth->init_menu();
		$philhealth->init_deps();
		$philhealth->init_lang();
		$philhealth->init_help();
	}
}
if (file_exists('../modules/population/class.population.php')) {
	include '../modules/population/class.population.php';
	$population = new population;
	if (!$module->activated('population') && $initmod) {
		$population->init_sql();
		$population->init_menu();
		$population->init_deps();
		$population->init_lang();
		$population->init_help();
	}
}
if (file_exists('../modules/ptgroup/class.ptgroup.php')) {
	include '../modules/ptgroup/class.ptgroup.php';
	$ptgroup = new ptgroup;
	if (!$module->activated('ptgroup') && $initmod) {
		$ptgroup->init_sql();
		$ptgroup->init_menu();
		$ptgroup->init_deps();
コード例 #2
0
ファイル: algorithm.php プロジェクト: piiskop/pstk
 private static function poolSelection($pop)
 {
     // Create a pool population
     $pool = new population(algorithm::$poolSize, false);
     for ($i = 0; $i < algorithm::$poolSize; $i++) {
         $randomId = rand(0, $pop->size() - 1);
         //Get a random individual from anywhere in the population
         $pool->saveIndividual($i, $pop->getIndividual($randomId));
     }
     // Get the fittest
     $fittest = $pool->getFittest();
     return $fittest;
 }
コード例 #3
0
ファイル: ga.php プロジェクト: piiskop/pstk
echo "\n\\    \\_\\  \\  ___/|   |  \\  ___/|  | |  \\  \\___ ";
echo "\n\\______  /\\___  >___|  /\\___  >__| |__|\\___  >";
echo "\n       \\/     \\/     \\/     \\/             \\/ ";
echo "\n-----------------------------------------------";
echo "\nUniformRate (crosssover point  where to break gene string) :" . algorithm::$uniformRate;
echo "\nmutationRate (what % of genes change for each mutate) :" . algorithm::$mutationRate;
echo "\nPoolSize (crossover # of  individuals to select in each pool ):" . algorithm::$poolSize;
echo "\nInitial population # individuals:" . $initial_population_size;
echo "\nelitism (keep best individual each generation true=1) :" . algorithm::$elitism;
// Set a candidate solution static class
fitnesscalc::setSolution($solution_phrase);
echo "\nMax Fitness is :" . fitnesscalc::getMaxFitness();
echo "\n-----------------------------------------------";
// Create an initial population
$time1 = microtime(true);
$myPop = new population($initial_population_size, true);
// Evolve our population until we reach an optimum solution
while ($myPop->getFittest()->getFitness() > fitnesscalc::getMaxFitness()) {
    $generationCount++;
    $most_fit = $myPop->getFittest()->getFitness();
    $myPop = algorithm::evolvePopulation($myPop);
    //create a new generation
    if ($most_fit < $most_fit_last) {
        // echo " *** MOST FIT ".$most_fit." Most fit last".$most_fit_last;
        echo "\n Generation: " . $generationCount . " (Stagnant:" . $generation_stagnant . ") Fittest: " . $most_fit . "/" . fitnesscalc::getMaxFitness();
        echo "  Best: " . $myPop->getFittest();
        $most_fit_last = $most_fit;
        $generation_stagnant = 0;
        //reset stagnant generation counter
    } else {
        $generation_stagnant++;