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
        echo "Starting " . $path . " ... ";
        if (preg_match("/_X/", $path)) {
            //для начала убедимся, что мы в Линуксе. Иначе удаленный запуск этих скриптов не делаем
            if (!IsWindowsOS()) {
                $display = '101';
                //Попробуем получить номер Дисплея из имени файла
                if (preg_match("/_X(.+)_/", $path, $displays)) {
                    if (count($displays) > 1) {
                        $display = $displays[1];
                    }
                }
                //запускаем Линуксовый поцесс на дисплее, номер которого в имени файла после _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]);