R erlang
Rewrote the ExcelVBA code from Erlang.xlsx sheet for call center calculations.
ErlangB <- function(servers,intensititys)
{
z <- if(servers < 0) 0
z <- if(intensititys < 0) 0
MaxIterate <- as.integer(servers)
Val <- intensititys
Last <- 1
for( i in 1:MaxIterate)
{ z <- (Val * Last) / (i + (Val * Last))
Last <- z
}
z<-ifelse(z<0,0,z)
z<-ifelse(z>1,1,z)
print(z)
z
}
ErlangC <- function(server,intensitity)
{
x <- if(server < 0) 0
x <- if(intensitity < 0) 0
B <- ErlangB(servers=server,intensititys=intensitity)
C <- B / (((intensitity / server) * B) + (1 - (intensitity / server)))
C<-ifelse(C<0,0,C)
C<-ifelse(C>1,1,C)
x <- C
print(x)
x
}
ErlangASA <- function(Agents,CPH,AHT)
{ BirthRate <- CPH
DeathRate <- 3600 / AHT
TrafficRate <- BirthRate / DeathRate
Server <- Agents
Utilisation <- TrafficRate / Server
Utilisation <-ifelse(Utilisation>=1,.99,Utilisation)
print(BirthRate)
print(DeathRate)
print(TrafficRate)
print(Agents)
print(Utilisation)
C <-ErlangC(server=Agents,intensitity=TrafficRate)
AnswerTime <- C / (Server * DeathRate * (1 - Utilisation))
AveAnswer <- as.integer(AnswerTime * 3600 +.5)
ASA <- AveAnswer
ASA
print(ASA)
}
output <- ErlangASA(Agents=50,CPH=300,AHT=924)
print(output)