Esempio n. 1
0
 static function calcularComRegrasMaxVMSubProdOthers($scenario, $maxVM)
 {
     $indesejado = 0;
     $todas = array_product($scenario['rvm']);
     foreach ($scenario['rpm'] as $pmName => $pm) {
         $localUnwanted = 0;
         if ($pm > $maxVM) {
             $multi = Approximation::getOutsidersInsiders($pmName, $scenario)[0];
             for ($i = $maxVM + 1; $i <= $pm; $i++) {
                 $tmp = Approximation::calcCombination($pm, $i) * $multi;
                 $localUnwanted += $tmp;
             }
         }
         $indesejado += $localUnwanted;
     }
     return $todas - $indesejado;
 }
Esempio n. 2
0
 /**
  * @depends testMontarSumario
  */
 public function testgetOutsidersInsiders()
 {
     $placements = array(array('A:1', 'A:2'), array('B:1', 'B:2', 'B:3'), array('C:1', 'C:3'), array('D:1', 'D:2'), array('E:3'), array('F:4'), array('G:1', 'G:2', 'G:3'), array('H:1', 'H:2', 'H:3', 'H:4'));
     $scenario = Scenario::buildScenarioByPlacements($placements);
     $exp_insiders = array(2, 1, 0, 2, 3);
     list($out, $in) = Approximation::getOutsidersInsiders('3', $scenario);
     $this->assertEquals(4, $out, "# of Outsiders !match.");
     $this->assertEquals(array_sum($exp_insiders), array_sum($in), "Sum of Insiders !match");
     $this->assertEquals(array_product($exp_insiders), array_product($in), "Prod of Insiders !match");
     $this->assertEquals($exp_insiders, $in, "Array of insiders !match");
 }