Example #1
0
File: nm-run.php Project: 0-php/AI
<?php

require "lib/controller.class.php";
$app = new Controller();
$app->inc("nmesh");
$data = $app->model->get("network")->get($_GET['n']);
$nn = $app->model->get("network")->nn;
set_time_limit(0);
function buildGraph($input, $width = 25)
{
    // get percentage
    $perc = ($input + 1) / 2;
    //add one to shift out of negatives
    $bar1 = '<font color="#303030">|</font>';
    $bar2 = '<font color="#e0e0e0">|</font>';
    $bars = ceil($perc * $width);
    $output = str_repeat($bar1, $bars);
    $output .= str_repeat($bar2, $width - $bars);
    return $output;
}
if ($_POST) {
    $data = $app->model->get("cache")->getCache($_GET['n'] . implode("|", $_POST['input']));
    if ($data === null) {
        if (count($_POST['input']) != $nn->inputs) {
            throw new Exception("Incorrect number of entries!");
        }
        $outputs = $nn->run($_POST['input']);
        //save into cache
        $app->model->get("cache")->saveCache($_GET['n'] . implode("|", $_POST['input']), $_GET['n'], implode("|", $outputs));
    } else {
        $outputs = explode("|", $data);