PHP - Erlang And Sigma Notation
Okay so I was scouring the web looking for PHP examples of ways to use php to get an estimation of wait time my customers would have to wait for my service technicians to get their location. I found Erlang C Equation. I then looked for php examples on the web and had no luck. So for anyone who is interested, here is my code based on the erlang C Equation found at http://www.had2know.com/technology/erlang-c-formula-calculator.html
Code: [Select] /** * Erlang C formlua based on equation from http://www.had2know.com/technology/erlang-c-formula-calculator.html * */ /** * * @param unknown_type $T Average Minutes per call * @param unknown_type $C Number of Calls per day */ function Erlangs($T=900, $C=20){ $seconds_in_a_day = 86400;//static variable //Get number of Erlangs $E1 = $seconds_in_a_day/($T);//$minutes per call * 60 to get seconds $E = $C/$E1; return $E; } /** * @param $E Number of Erlangs * @param $N Sigma formula Start number * @param $M number of trunks/phone lines * @param $C Number of Calls per day * @param $T Average minutes spent per call in seconds. */ function ErlangCProbabilityOfWait($E, $N=0,$M=2,$C=20,$T=900){ //try to mimic the mathematical sigma function //where when a zero appears that is factored and evaluated as 1 and then use the real 1. for($N=0;$N<=$M-1;$N++){ $sigma_formula += bcpow($E,$N,4)/gmp_strval(gmp_fact($N)); } //get queued wait period/probability queued $Pqueued_wait = (bcpow($E,$M,4)/gmp_strval(gmp_fact($M))) / ( (bcpow($E,$M,4)/gmp_strval(gmp_fact($M))) + (1-$E/$M)*$sigma_formula ); return $Pqueued_wait; } /** * * @param unknown_type $T Average minutes spent per call in seconds. * @param unknown_type $Pqueued_wait Probability of call being placed in wait queue * @param unknown_type $M number of trunks/phone lines * @param unknown_type $E Number of Erlangs */ function ErlangCWaitTime($T,$Pqueued_wait,$M,$E){ //now that the above equation works we can estimate wait time ASA // ASA = (T*Pqueued)/(M-E) $ASA = ($T*$Pqueued_wait)/($M-$E); echo round($ASA,1) . ' Seconds';//return value in seconds //if value is over 60 seconds display minutes. } $Average_call_time_in_seconds = 900; $Calls_per_day = 480; $Number_of_phone_lines = 10; $Sigma_formula_Start_number = 0; //number of erlangs $Erlangs = Erlangs($Average_call_time_in_seconds,$Calls_per_day); //probability of Wait $Probability_of_wait = ErlangCProbabilityOfWait($Erlangs, $Sigma_formula_Start_number, $Number_of_phone_lines, $Calls_per_day, $Average_call_time_in_seconds); // echo ErlangCWaitTime($Average_call_time_in_seconds, $Probability_of_wait, $Number_of_phone_lines, $Erlangs); This works but I need to modify to calculate mileage and travel time. Any thoughts. Similar TutorialsI am fairly new to php coding and completely new Drupal 8 coding. I am having trouble understanding some regular notation I see in passing arguments to functions. Here is an example function mymodule_form_alter(&$form, Drupal\Core\Form\FormStateInterface $form_state, $form_id) I am not sure what "Drupal\Core\Form\FormStateInterface $form_state" means. Does is mean that $form_state will be passed in from FormStateInterface? How can one create an array for the set,A={x:1<=x<=100, x is perfect square}, using php programming? |