Esempio n. 1
0
 function run()
 {
     $data = array();
     $adam = new HelloWorld();
     $eve = new HelloWorld();
     $ga = new GA();
     $ga->population = array($adam, $eve);
     add_data_for_chart($ga->population);
     $ga->fitness_function = array('HelloWorldProgram', 'fitness');
     //Uses the 'total' function as fitness function
     $ga->num_couples = 1;
     //4 couples per generation (when possible)
     $ga->death_rate = 2;
     //No kills per generation
     $ga->generations = 50;
     //Executes 100 generations
     $ga->crossover_functions = array('string' => 'avg_char_code');
     //Array with functions, like $property=>$func
     $ga->mutation_function = 'char_gradual_change';
     //Uses the 'inc' function as mutation function
     $ga->mutation_rate = 60;
     //10% mutation rate
     $ga->evolve();
     //Run
     add_data_for_chart($ga->population);
     //add_data_for_chart(GA::select($ga->population, $ga->fitness_function, 1)); //The best
     $this->show_stats($ga);
 }
Esempio n. 2
0
 function run()
 {
     $data = array();
     $adam = new Digit();
     $eve = new Digit();
     $ga = new GA();
     $ga->population = array($adam, $eve);
     //add_data_for_chart($ga->population);
     $ga->fitness_function = array('DigitProgram', 'fitness');
     //Uses the 'total' function as fitness function
     $ga->num_couples = 1;
     //4 couples per generation (when possible)
     $ga->death_rate = 2;
     //2 kills per generation
     $ga->generations = 50;
     //Executes 100 generations
     $ga->crossover_functions = array('digit' => 'crossover');
     //Array with functions, like $property=>$func
     $ga->mutation_function = 'mutation';
     //Uses the 'inc' function as mutation function
     $ga->mutation_rate = 60;
     //10% mutation rate
     $ga->evolve();
     //Run
     echo "<pre>";
     //print_r($ga);
     echo "</pre>";
     //add_data_for_chart($ga->population);
     //add_data_for_chart(GA::select($ga->population, $ga->fitness_function, 1)); //The best
     //$this->show_stats($ga);
 }
Esempio n. 3
0
 function devices()
 {
     $this->init();
     $data = $this->conf_data;
     /* 		$this->conf_data['css'] = array('index.css','ui-lightness/jquery-ui-1.8.21.custom.css');
     		$this->conf_data['js'] = array('common.js','jquery.min.js','jquery-ui-1.8.21.custom.min.js','raphael-min.js','popup.js','analytics2.js');
     		$this->conf_data['content_view'] = 'content/devices.php';
     		$data = $this->conf_data;
     		Doo::loadClass('Movie');
     		$mv = new Movie();
     		$data['content_data_graph'] =  $mv->get_devices_graph();
     		$data['content_data'] =  $mv->get_devices(); */
     $data['title'] = 'UseeTV - Devices';
     $data['content_view'] = 'content/new_devices.php';
     if (!$this->start) {
         $this->start = 0;
     }
     $data['limit'] = $this->limit;
     $data['gdtto'] = $this->gdtto;
     $data['gdtform'] = $this->gdtform;
     Doo::loadClass('GA');
     $ga = new GA();
     $data['content_data'] = $ga->get_devices_bydate($this->start_date, $this->end_date, $this->start, $data['limit']);
     $data['graph'] = $ga->get_devices_graph($this->start_date, $this->end_date);
     $data['filter_action'] = 'devices';
     $data['table_row_option'] = array(20, 100, 500, 1000, 10000);
     $data['label'] = 'devices';
     $data['filter_tipe'] = false;
     $this->view()->renderc(Doo::conf()->language . '/t3', $data);
 }
Esempio n. 4
0
    print_r($x);
    echo '</pre>';
}
//This will be the mutation function. Just increments the property.
function inc($x)
{
    return $x + 1;
}
//This will be the fitness function. Is just the sum of all properties.
function total($obj)
{
    return $obj->p1 + $obj->p2;
}
$t1 = new Test(1, 4);
$t2 = new Test(3, 2);
$ga = new GA();
$ga->population = array($t1, $t2);
$ga->fitness_function = 'total';
//Uses the 'total' function as fitness function
$ga->num_couples = 1;
//1 couple per generation
$ga->death_rate = 0;
//1 death per generation
$ga->generations = 10;
//Executes 10 generations
$ga->crossover_functions = 'max';
//Uses the 'max' (built-in) function as crossover function
$ga->mutation_function = 'inc';
//Uses the 'inc' function as mutation function
$ga->mutation_rate = 1;
//1% mutation rate
Esempio n. 5
0
<?php

Doo::loadClass('UserSession');
Doo::loadClass('GA');
$ga = new GA();
$usession = new UserSession();
$username = $usession->uget('username');
?>
<div class="list_wrapper">
	<?/*<h1>User List</h1>*/ ?>
	<content>
		<?php 
$pg_link = $_GET['page'] ? '&page=' . $_GET['page'] : '';
$sch_link = $_GET['search'] ? '&search=' . $_GET['search'] : '';
$utype_link = $_GET['userProvider'] ? '&userProvider=' . $_GET['userProvider'] : '';
$uregional_link = $_GET['speedyRegional'] ? '&speedyRegional=' . $_GET['speedyRegional'] : '';
?>
		<?php 
if (!$_REQUEST['print'] && false) {
    ?>
			<div style="margin:5px;">
				<form class="navbar-search pull-right" action="<?php 
    echo DOO::conf()->SUBFOLDER . $data['filter_action'];
    ?>
" method="POST" >
					<input type="text" class="search-query" placeholder="Search" value="<?php 
    echo $_GET['search'] ? $_GET['search'] : '';
    ?>
" name="search" autocomplete="off">
				</form>
				<div class="clear"></div>
Esempio n. 6
0
 function moviestat()
 {
     Doo::loadClass('GA');
     $ga = new GA();
     $ppv = $ga->get_viewed_tovi($this->ppv_cat_code);
     $svod = $ga->get_viewed_tovi($this->svod_cat_code);
     $out = array('ppv' => $ppv, 'svod' => $svod);
     var_dump($out);
     //echo json_encode($out);
     exit;
 }
Esempio n. 7
0
 function moviePpv()
 {
     Doo::loadHelper('DooPager');
     Doo::loadClass('Movie');
     Doo::loadClass('GA');
     $ga = new GA();
     $mv = new Movie();
     $data = $this->conf_data;
     $data['title'] = 'UseeTV - PPV Movie';
     $data['content_view'] = 'content/ppv_movie.php';
     $data['ga_stats'] = $ga->get_viewed_tovi($this->ppv_cat_code);
     $data['content_data'] = $mv->get_movie_by_category($this->ppv_cat_code, $this->gsearch);
     /* $data['mv_name'] 	  = array_map(create_function('$k,$v','return array($v["show_name"]=>$v["small_image1"]);'), array_keys($data['content_data']),array_values($data['content_data'])); */
     $data['ppv_start_date'] = $this->ppv_start_date;
     $data['filter_action'] = 'ppv/movie';
     $data['table_row_option'] = array(20, 100, 500, 1000, 10000);
     $data['label'] = 'Movie PPV';
     $this->view()->renderc(Doo::conf()->language . '/t3', $data);
 }
<?php

set_time_limit(0);
ini_set("memory_limit", "256M");
require_once './lib/ga.php';
//echo mt_rand() % 100;
//exit();
//CREAMOS UN NUEVO OBJETO GA
//exit('222');
$ga = new GA(1);
//ESTABLECEMOS EL OBJETIVO
$ga->setObjective(0, 1080);
//INICIALIZAMOS EL OBJETO
$ga->startUp(0);
//EMPEZAMOS LA EVOLUCIÓN
$bests = $ga->start(0);