Created
May 12, 2017 08:28
-
-
Save smzn/8bdf88af0d518af4f067cd774e16ca7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function mms($id = null) { | |
if (!$this->Zone->exists($id)) { | |
throw new NotFoundException(__('Invalid zone')); | |
} | |
$options = array('conditions' => array('Zone.' . $this->Zone->primaryKey => $id),'recursive' => 2); | |
$this->set('zone', $this->Zone->find('first', $options)); | |
$zone = $this->Zone->find('first', $options); | |
$doctor = 0; | |
$hospital_num = 0; | |
$population = 0; | |
$rate_65 = 0; | |
foreach($zone['Region'] as $region){ | |
$population += $region['allpopulation']; | |
$rate_65 += $region['rate_population65']; | |
foreach($region['Hospital'] as $hospital){ | |
$doctor += $hospital['doctor']; | |
$hospital_num ++; | |
} | |
} | |
$rate_65 = $rate_65 / count($zone['Region']); | |
$lambda = $population * $rate_65 /100 /24; | |
$mu = 12 * $doctor / $hospital_num; | |
App::import('Vendor', 'MyMMS'); | |
$mymms = new MyMMS($lambda, $mu, $hospital_num); | |
$mms = $mymms->getResult(); | |
print_r($mymms->getResult()); | |
$data = array( | |
'id' => $zone['Zone']['id'], | |
'lambda' => $mms['lambda'], | |
'mu' => $mms['mu'], | |
'server' => $mms['s'], | |
'rho' => $mms['row'], | |
'q' => $mms['Q'], | |
'l' => $mms['L'], | |
'w' => $mms['W'], | |
'u' => $mms['U'], | |
); | |
$this->Zone->save($data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment