Q Lecture - mm1 <-

Info iconThis preview shows pages 1–2. 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) { cond1 <-0 cond2 <-0 < cond3 <-0 ######################################## if(ArriveDis == 1) 1 { A = randome(1,ArriveRate) } if(ArriveDis == 2) { A = randomg(1,ArriveShape,ArriveRate) } 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 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 + 1 Ta <- Ta + A T if(n==1) { Td = Td + D } cond1 <-1 < waiting[z]<- departure[z]- arrival[z] z<-z+1 } #case 2 if ( { t=Td Nd = Nd + 1 n = n-1 if (n>0) { Td =t + D T } else { Td= inf } cond2 <-1 } #case 3 # { t<- Td Nd <- Nd + 1 n <- n-1 < if(n > 0) { Td <- Td + D } else { Td <- inf { } cond3 <-1 } counter=counter+1 output[i] =n o i=i+1 cond = cond1 + cond2+cond3 } #return(output) # return(waiting) r } mm2 <- function(ArriveDis, ArriveShape, ArriveRate, DepartDis, DepartShape, DepartRate)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 3

Q Lecture - mm1 <-

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online