Inull save them for later usage matrix rbindmatrix

This preview shows page 5 - 7 out of 7 pages.

lostppl = rbind(matrix[lostppl.i,],NULL) # save them for later usage, matrix = rbind(matrix[-lostppl.i,],NULL) # remove them from our work. if (length(matrix) == 0) { cat("No one made it to the doctor.","\n")
Image of page 5

Subscribe to view the full document.

cat("The following is stage 2's output:","\n") return(justincase) } justincase = NULL matrix = rbind(matrix[order(matrix[,10]),],NULL) # sort ascending by arrive_s3 n = length(matrix[,1]) # number of people entering S3 Ta = matrix[1,10] # first arrival, take first entry since already sorted Td = inf TaIndex = 1 TdIndex = 1 system = NULL while (min(Ta,Td) < T) { if (Ta <= min(Td,T)) { t = Ta ss = ss+1 TaIndex = TaIndex+1 # just go to next one, since already sorted if (TaIndex > n) Ta = inf if (TaIndex <= n) Ta = matrix[TaIndex,10] if (ss == 1) Td = t + rexp(1,1/4) } if (Td <= min(Ta,T)) { t = Td ss = ss-1 system = rbind(matrix[which(matrix[,10]<t &[,11])),],NULL) # identify the system system = rbind(system[order(system[,5],decreasing=TRUE),],NULL) # sort descending by priority TdIndex = which(matrix[,12]==system[1,12]) # identify person with highest priority and arrived matrix[TdIndex,11] = Td Td = t+rexp(1,1/4) if (ss == 0) Td = inf } } Wait_S3 = matrix[,11] - matrix[,10] OverallWait = matrix[,9] + Wait_S3 # add on to previous overall matrix = cbind(rbind(matrix[,-9],NULL),Wait_S3,OverallWait) # remove previous overall lostppl = cbind(lostppl[,-9],NA,NA) # to match dimensions with matrix matrix = rbind(matrix,lostppl) # put back the lost ppl matrix = matrix[order(matrix[,11]),-11] # sort according to original position; remove persons column rownames(matrix) = NULL cat("NOTE: Persons with NA entries are those lost in the system.","\n") return(matrix) } ER = function(ArriveRate=1/20,DepartRate=1/16,T=400) { s1 = MM1(ArriveRate,DepartRate,T) s2 = PRIQ(s1,T) s3 = stage3(s2,T) return(s3) } cat("To run code, enter ER(arrival rate, departure rate, end time)","\n") # ie. ER(1/18,1/13,200)
Image of page 6
cat(" For faster access, just enter ER() for default rates and T = 400.","\n") # ie. ER() is equiv. to ER(1/20,1/16,400) # Sample Run ER(T=500)
Image of page 7
  • Spring '09
  • ChristianeLemieux

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern