void arrivals() // this model segment spawns departing customers { create("arrivals"); while(clock < 1440.) // { hold(expntl(10)); // exponential interarrivals, mean 10 minutes if(newCustomer()){ // see if customer balks after looking at line arr_cust(); // new customer enters line } } }
void departures() // this model segment spawns departing customers { create("departures"); while(clock < 1440.) // { hold(expntl(10)); // exponential interarrivals, mean 10 minutes long group = group_size(); for (long i=0;i<group;i++) dep_cust(); // new customer appears at the car lot } }
void sim(int argc, char *argv[]) { set_model_name("M/M/1 Queue"); create("sim"); cnt = NARS; for(int i = 1; i <= NARS; i++) { hold(expntl(IAR_TM)); // interarrival interval customer(); // generate next customer } done.wait(); // wait for last customer to depart report(); // model report theory(); mdlstat(); // model statistics }
void customer() // arriving customer { float t1; create("cust"); t1 = clock; // record start time qtbl.note_entry(); // note arrival f.reserve(); // reserve facility hold(expntl(SRV_TM)); // service interval f.release(); // release facility tbl.record(clock - t1); // record response time qtbl.note_exit(); // note departure if(--cnt == 0) done.set(); // if last customer, set done }