Пример #1
0
 public function test3()
 {
     $m = new Markov();
     $m->add_item(6000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(30000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(20000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(50000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(20000);
     $m->insert_in_cart();
     $m->add_state(1);
     $m->calculate_constants();
     $m->calculate_prob_state();
     $this->assertEquals('high', $m->test_gauss());
 }
Пример #2
0
} else {
    $email = $_SESSION['name'];
    $name1 = $_SESSION['pname'];
    $price = $_SESSION['pprice'];
    $mysqli = new mysqli('localhost', 'root', 'password', 'transaction_store');
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    for ($i = 0; $i < $qt; $i++) {
        $q = $mysqli->query("select object from object_store where Email='{$email}' ");
        $r = $q->fetch_assoc();
        if ($r['object'] === NULL) {
            $m = new Markov();
            $m->add_item($price);
            $m->insert_in_cart();
            $m->make_dict();
            $m->add_state();
            $mysqli->query("update object_store set object='" . serialize($m) . "'  where Email='{$email}' ");
        } else {
            $d = unserialize($r['object']);
            $d->add_item($price);
            $d->insert_in_cart();
            $d->make_dict();
            $d->add_state();
            $mysqli->query("update object_store set object='" . serialize($d) . "'  where Email='{$email}' ");
        }
    }
    $response = 'success';
}
echo $response;
Пример #3
0
<?php 
error_reporting(-1);
ini_set('display_errors', true);
require 'Markov.php';
echo "<em>" . "Tests" . "</em>";
echo "<br><br>";
echo "<em>" . "Test1" . "</em>";
echo "<br>";
$m = new Markov();
$m->add_item(6000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(15000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(21000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(3000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(25000);
$m->insert_in_cart();
$m->add_state(1);
$m->view_state();
$m->parse_dict();
$m->calculate_constants();
$m->display_constants();
$m->calculate_prob_state();
$m->test_gauss();