! Multi-period, multi-server queue model in LINGO. (QueueMP.lng)
  ! Key words: queue, M/M/C queue, waiting line, staffing, Call center;
SETS:
  PERIOD: ARATE, NSRVRS;
ENDSETS
DATA: !The 15 minute time intervals; PERIOD = T0800 T0815 T0830 T0845 T0900 T0915 T0930 T0945; ! Arrival rate in customers/minute; ARATE = 2.2 2.3 2.6 2.9 3.4 3.3 3.2 3.1; ! Number of servers staffed for the period; NSRVRS = 8 8 9 10 11 11 11 10; ST = 2.75; ! Mean service time/customer in minutes, same for all intervals; DW = .5; ! Desired max wait in minutes; ENDDATA CALC: ! Compute statistics for a multi-server queueing system (QMMC) with Poisson arrivals, exponential service time distribution; ! Run the patient customers case; @SET("TERSEO",2); ! Turn off default output; ! Generate a little report; @WRITE('Case: Patient customers - wait until served.',@NEWLINE(1),' Mean service time =',@FORMAT(ST,"6.3F"), ' minutes. Target wait=',@FORMAT(DW,"6.3F"),' minutes.',@NEWLINE(1)); @WRITE(' Arrival Uncond. Condnl.',@NEWLINE(1)); @WRITE(' Period Rate Servers PR{Wait>0} PR{Wait>Target} Wait Wait(>0) ', @NEWLINE(1)); @FOR( PERIOD(t): ! Average no. of busy servers; LOAD = ARATE(t) * ST; ! Patient customers case; ! Fraction of calls that wait, the Erlang C calculation. Assumes Poisson arrivals, exponential service time distribution. ; PWAIT = @PEB( LOAD, NSRVRS(t)); ! Conditional expected wait, i.e., for customers who must wait, what is their average wait; WAITCND = ST/( NSRVRS(t) - LOAD); ! Unconditional expected wait, including those who wait 0; WAITUNC = PWAIT * WAITCND; ! Fraction calls with wait > DW}; FWD = PWAIT*@EXP(-DW*(NSRVRS(t)/ST - ARATE(t))); @WRITE(' ', PERIOD,' ',@FORMAT(ARATE(t),"5.3F"),' ',@FORMAT(NSRVRS(t),"4.0F"), ' ', @FORMAT(PWAIT,"4.3F"),' ',@FORMAT(FWD,"4.3F"),' ', @FORMAT( WAITUNC,"4.3F"),' ',@FORMAT( WAITCND,"4.3F"),' ', ' ' ,@NEWLINE(1)); ); ! End @FOR( PERIOD...; ! Impatient customers case; @WRITE(@NEWLINE(2)); @WRITE('Case: Impatient customers - Depart if no server immediately available.', @NEWLINE(1),' Mean service time =',@FORMAT(ST,"6.3F"),@NEWLINE(1)); @WRITE(' Arrival',@NEWLINE(1)); @WRITE(' Period rate/min Servers Fraction customers lost', @NEWLINE(1)); @FOR( PERIOD(t): ! Average no. of busy servers; LOAD = ARATE(t) * ST; ! Fraction of calls lost, the Erlang-B calculation. Assumes Poisson arrivals, arbitrary service time distribution. ; FLOST = @PEL( ARATE(t) *ST , NSRVRS(t)); @WRITE(' ', PERIOD,' ', @FORMAT(ARATE(t),"5.3F"),' ',@FORMAT(NSRVRS(t),"4.0F"),' ', ' ', @FORMAT(FLOSt,"4.3F"),@NEWLINE(1)); ); ! End @FOR( PERIOD...; ENDCALC