Esempio n. 1
0
 public function testScenarioComRegras()
 {
     $placements = array(array('A:2', 'A:3'), array('B:1', 'B:2'), array('C:2', 'C:3'), array('D:1', 'D:2', 'D:3'));
     $scenario = Scenario::buildScenarioByPlacements($placements);
     $resp = Approximation::calcularComRegras($scenario);
     $this->assertEquals(24, $resp);
 }
Esempio n. 2
0
if (!file_exists(FNPL)) {
    convertDataToPlacements();
}
if (!file_exists(FNSC)) {
    convertPlacementToScenario();
}
$pms = json_decode(file(FNPM)[0], true);
$vms = json_decode(file(FNVM)[0], true);
$scenario = json_decode(file(FNSC)[0], true);
$tmp = array();
foreach ($vms as $vm) {
    $tmp[$vm['name']] = 0;
}
$fmt = "\nVM-UUIDs(%s) | VM-Names(%s) | PMs(%s) | PossiblePlaces(%s) | APR(%s)\n";
echo sprintf($fmt, count($vms), count($tmp), count($pms), array_sum($scenario['rpm']), array_sum($scenario['rpm']) / (count($tmp) * count($pms)));
$semConstraint = Approximation::calcularComRegras($scenario);
echo "With Rules:" . $semConstraint . PHP_EOL;
$result = Approximation::realTreeSearchApproach($scenario);
echo "Real Possibilities: " . $result . PHP_EOL;
function sig_handler($signo)
{
    global $ctd;
    echo 'Estados ' . $ctd . PHP_EOL;
    die;
}
pcntl_signal(SIGINT, "sig_handler");
pcntl_signal(SIGTERM, "sig_handler");
function convertPlacementToScenario()
{
    $placements = json_decode(file(FNPL)[0], true);
    $scenario = Scenario::buildScenarioByPlacements($placements);
$formato = "%s %s %s\n";
$saida_sem = '';
$saida_com = '';
$saida_sum = '';
$saida_sub = '';
$saida_prod = '';
$saida_real = '';
$saida_2d = "VMs PMs Sem Com Sum Sub Prod Real\n";
$saida_2d = "VMs PMs Com Tree\n";
$saida_delta = '';
$flag = null;
foreach ($scenarios as $key => $value) {
    printf("%s - VM(%s) - PM(%s) ", date(DATE_RFC2822), $value['nvms'], $value['npms']);
    $max = 5;
    //$sem = QuantidadeDeResultados::calcularSemRegras($value);
    $com = Approximation::calcularComRegras($value);
    echo "\ncom({$com}) \n";
    //$sum = QuantidadeDeResultados::calcularComRegrasMaxVMSum($value,3);
    //$sub = QuantidadeDeResultados::calcularComRegrasMaxVMSub($value,3);
    //$prod= QuantidadeDeResultados::calcularComRegrasMaxVMProd($value,3);
    //$real_r = Combinations::GenerateAllCombinations(array_values($value['placements']));
    //$real = count(Combinations::FilterCombinationsByMaxVm($real_r,3));
    $tre = Approximation::treeSearchApproach($value, $max);
    //echo " - Real($real) \n";
    $delta = 5;
    //100*($sum/$real);
    echo "\ncom({$com}) tree({$tre}) \n";
    //Quebra a linha quando muda de VM. Necessario para o funcionamento do GnuPlot PM3D
    if (!is_null($flag) && $flag != $value['nvms']) {
        $saida_tre .= "\n";
        $saida_sem .= "\n";
Esempio n. 4
0
    $scenario = Scenario::getScenarioFromJSON($_GET['state']);
} elseif (isset($_GET['file']) && file_exists('others/' . $_GET['file'])) {
    $scenario = array_pop(json_decode(file('others/' . $_GET['file'])[0], true));
} else {
    $scenarios = Scenario::geraScenarios($apr, array($nvm), array($npm));
    $scenario = array_pop($scenarios);
}
$json = Scenario::toDataTableJSON($scenario);
//$memcache = memcache_connect('localhost', 11211);
//$accordion = isset($_GET['cache']) ? false : memcache_get($memcache, 'accordion');
//$accordion = false;
//if ($accordion == false) {
//echo "<script>alert('Not Cached');</script>";
$accordion = new Accordion();
$sem = Approximation::calcularSemRegras($scenario);
$com = Approximation::calcularComRegras($scenario);
$last = Approximation::calcularComRegrasMaxVMSub($scenario, $max);
$tree = Approximation::treeSearchApproach($scenario, $max);
$test1 = 0;
//Approximation::calcularComRegrasMaxVMOutIn($scenario, $max);
$test_c_a = 0;
//Approximation::calculateAvgCombSplitterApproach($scenario, $max);
$test_c_s = 0;
//Approximation::calculateSumCombSplitterApproach($scenario, $max);
$test_s_p = 0;
//Approximation::calculateProdSequencialSplitterApproach($scenario, $max);
$test_s_s = 0;
//Approximation::calculateSumSequencialSplitterApproach($scenario, $max);
//$filtered = Combinations::GenerateAllCombinationsMaxVM($scenario['placements'], $max);
$real = 0;
//count($filtered);