program that implements an event-driven simulation of a line of customers at a bank.Each customer enters a queue, waits until reaching the front of the queue, performs a transaction with a teller (bank employee), and then leaves the bank. You may assume that the bank has only one queue and one teller.
A list of arrival events will be provided to your program from a text file.
The main goal of the program is to determine when departure events occur (i.e., when customers leave the bank), and compute statistics based on the length of time that customers spend in the bank. program needs to maintain a queue of customers, and an event list.The event list is an ADT that 1) keeps track of arrival and departure events that will occur but have not yet occurred, and 2) contains at most one arrival event and one departure event

Dani AI

Generated

Brief implementation notes and design guidance that extend 's specification without posting a full solution (per 's request).

The simulation model

  • Single FIFO queue + one teller. The event list stores at most one future arrival and one future departure. Advance a simulation clock to the next event time (the smaller of the two). Between events accumulate time-weighted statistics (queue-length area, teller busy time).
  • Input: a text file of arrival times (optionally with service durations). If service durations are not supplied, choose a reproducible method (fixed value, read a second column, or sample a distribution with a fixed RNG seed).

Minimal data layout (illustrative)

enum EventType { ARRIVAL, DEPARTURE };
struct Customer { int id; double arrival, service, startService; };
std::queue<Customer> q;
double nextArrival = INFINITY; bool hasArrival = false;
double nextDeparture = INFINITY; bool hasDeparture = false;
int departureId = -1;

Event loop (concept)

  • Repeat while hasArrival or hasDeparture:
    • advance time to t = min(nextArrival, nextDeparture)
    • accumulate stats: queueArea += q.size() * (t - now); if tellerBusy then busyTime += (t - now)
    • if hasDeparture and nextDeparture <= nextArrival (break ties by processing DEPARTURE first) → process departure: mark teller free, record customer completion, if q not empty immediately start next service and schedule nextDeparture
    • else → process arrival: enqueue customer; if teller free schedule departure immediately

Statistics to collect

  • countServed, totalWait = sum(startService - arrival), totalService, maxQueueLength, averageQueueLength = queueArea / totalSimTime, utilization = busyTime / totalSimTime.

Cautions

  • Use a small epsilon when comparing floating times. Ensure no departure is scheduled when the queue is empty. Keep RNG seeds for reproducibility. Tracking time-weighted queue area yields correct average queue length over simulation time.

Could you please implement the event-driven simulation for us too.

Please provide snippets of your work or possible questions rather than pasting your assignment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.