Ejemplo n.º 1
0
 function System_Creator($num, $test = NULL)
 {
     //Creation and rating of chromosomes of future systems
     $ratings = array();
     $chromosomes = array();
     for ($i = 0; $i < $num; $i++) {
         $chromosome = $this->Random_Chromosome();
         $rating = $this->Rate_Chromosome($chromosome);
         $ratings[] = $rating;
         $chromosomes[] = $chromosome;
     }
     rsort($ratings);
     foreach ($ratings as $key => $value) {
         $this->queue[$key] = array('rating' => $value, 'chromosome' => $chromosomes[$key]);
     }
     //Spreading energy between most perspective systems in first launch
     $count = $this->simultaneous_systems_count;
     $energy_per_system = $this->energy / $count;
     //Creating systems
     $threads = new Threads();
     for ($i = 0; $i < $count; $i++) {
         $threads->newThread('D:/web/www/lh/tests/fuzzy/system/system.php', $this->queue[0]);
         //Delete first element and reindex queue
         unset($this->queue[0]);
         $this->queue = array_values($this->queue);
     }
     while (false !== ($result = $threads->iteration())) {
         echo $result . "\r\n";
     }
     //$this->Run_Test($test);
 }
Ejemplo n.º 2
0
                }
                //запускаем Линуксовый поцесс на дисплее, номер которого в имени файла после _X
                $pipe_id = $threads->newXThread($path, $display);
            }
        } else {
            $pipe_id = $threads->newThread($path);
        }
        $pipes[$pipe_id] = $path;
        echo "OK" . PHP_EOL;
    }
}
echo "ALL CYCLES STARTED" . PHP_EOL;
if (!is_array($restart_threads)) {
    $restart_threads = array('cycle_execs.php', 'cycle_main.php', 'cycle_ping.php', 'cycle_scheduler.php', 'cycle_states.php', 'cycle_webvars.php');
}
while (false !== ($result = $threads->iteration())) {
    if (!empty($result)) {
        //echo "Res: " . $result . PHP_EOL . "---------------------" . PHP_EOL;
        $closePattern = '/THREAD CLOSED:.+?(\\.\\/scripts\\/cycle\\_.+?\\.php)/is';
        if (preg_match_all($closePattern, $result, $matches) && !file_exists('./reboot')) {
            $total_m = count($matches[1]);
            for ($im = 0; $im < $total_m; $im++) {
                $closed_thread = $matches[1][$im];
                foreach ($restart_threads as $item) {
                    if (preg_match('/' . $item . '/is', $closed_thread)) {
                        //restart
                        DebMes("RESTARTING: " . $closed_thread);
                        echo "RESTARTING: " . $closed_thread . PHP_EOL;
                        registerError('cycle_stop', $closed_thread);
                        $pipe_id = $threads->newThread($closed_thread);
                    }