MM1 - r if(DepartDis == 1) { D = randome(1,DepartRate) }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
mm1 <- function(ArriveDis,ArriveShape,ArriveRate,DepartDis,DepartShape,DepartRate) m { #ArriveDis can be 1-exp, 2-gamma. ex: mm1(1,0,1,1,0,1) if it is exp with rate 1 # #DepartDis can be 1-exp, 2-gamma. ex: mm1(1,2,3,1,2,3) if it is gamma with rate 3, shape 2 b n <-0 # number of units in queue n t <-0 # currrent time T<-10 # store close time Ta <-0 # arrival time a inf<-10000 i Td <- inf #departure time Na <- 0 #number of arrival Nd <- 0 # number of departure o cond <- 1 c A <-0 A D <-0 D counter = 0 c output <-NULL o i=0 i arrival <-NULL a departure <- NULL N waiting<- NULL w j <- 0 j k<- 0 k z<- 0 z while (cond >=1) w { cond1 <-0 cond2 <-0 < cond3 <-0 ######################################## if(ArriveDis == 1) 1 { A = randome(1,ArriveRate) } if(ArriveDis == 2) { A = randomg(1,ArriveShape,ArriveRate) }
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r if(DepartDis == 1) { D = randome(1,DepartRate) } if(DepartDis == 2) { D = randomg(1,DepartShape,DepartRate) } ######################################### # #case 1 if (Ta <= Td & Ta<=T) T { t <- Ta t arrival[j] <- Ta j <- j+1 if(n>0) { departure[k] <- t+ n*D { } else { departure[k] <- t+D t } k<- k+1 Na <- Na + 1 N n <- n + 1 n Ta <- Ta + A T if(n==1) { Td = Td + D T } cond1 <-1 c waiting[z]<- departure[z]- arrival[z] z<-z+1 } #case 2 if (Td <=Ta & Td <=T) { t=Td t Nd = Nd + 1 n = n-1 if (n>0) { Td =t + D T } else { Td= inf T } cond2 <-1 } #case 3 if (min(Ta, Td)>T & n>0) { t<- Td t Nd <- Nd + 1 n <- n-1 if(n > 0) { Td <- Td + D T } else e { Td <- inf } cond3 <-1 } counter=counter+1 c output[i] =n o i=i+1 i cond = cond1 + cond2+cond3 c } #return(output) # return(waiting) r } mm1(1,0,1,1,0,1)...
View Full Document

This note was uploaded on 11/16/2010 for the course STAT 340 taught by Professor Xu(sunny)wang during the Spring '09 term at Waterloo.

Ask a homework question - tutors are online