Skip to content

Instantly share code, notes, and snippets.

@smzn

smzn/MyMMS

Created May 12, 2017
Embed
What would you like to do?
<?php
class MyMMS{
private $lambda, $mu, $row, $Q, $L, $W, $U, $s;
public function __construct($lambda, $mu, $s){
$this->lambda = $lambda;
$this->mu = $mu;
$this->s = $s;
}
public function factorial($n){
$fact = 1;
if($n == 0)
return $fact;
else{
for($i = $n; $i>0; $i--)
$fact *= $i;
return $fact;
}
}
public function functionP0($a, $row){
$temp = 0;
for($k = 0; $k <= $this->s - 1; $k++){
$temp += (pow($a, (double)$k) / $this->factorial($k));
}
$temp +=( pow($a,(double) $this->s)/ ($this->factorial($this->s)*(1.0 - $row)));
$p0 = pow($temp,-1);
return $p0;
}
public function functionMMs(){
//$p0, $a;
$a = $this->lambda / $this->mu;
$this->row = $a/(double) $this->s;
$p0 = $this->functionP0($a, $this->row);
$this->Q = (pow((double) $this->s,(double) $this->s) * pow($this->row,(double) $this->s + 1.0)) / ($this->factorial($this->s) * pow(1.0 - $this->row,2.0)) * $p0;//待ち人数
$this->L = $this->Q + $a;//系内人数
$this->W = $this->Q / $this->lambda;//待ち時間
$this->U = $this->W + (1/$this->mu);//系内時間
$this->UU = $this->L / $this->lambda;//系内時間
}
public function getrow() {
return $this->row;
}
public function getQ() {
return $this->Q;
}
public function getL() {
return $this->L;
}
public function getW() {
return $this->W;
}
public function getU() {
return $this->U;
}
public function getResult(){
$this->functionMMs();
$result = array(
'lambda' => $this->lambda,
'mu' => $this->mu,
's' => $this->s,
'row' => $this->row,
'Q' => $this->Q,
'L' => $this->L,
'W' => $this->W,
'U' => $this->U,
'UU' => $this->UU
);
return $result;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment