Question: Write a program (Java or C)of bus simulation: Create a data structure (a balanced tree, or simply a doubly-linked ring), which keeps the events sorted

Write a program (Java or C)of bus simulation:

Create a data structure (a balanced tree, or simply a doubly-linked ring), which keeps the events sorted by time; this is initialized by a dummy event scheduled for time 0 Generate events based on the system we are simulating; as the result, a generated event enters the structure in an appropriate place Execute the program by repeatingthe following steps until simulated current time exceeds the defined time limit

There are three actions

1.person:A person arrives in the queue at a bus stop Action:After a random (exponentially-distributed inter-arrival) time, another person is scheduled to arrive in the queue 2.arrival:A bus arrives at a bus stop Action: If there is no one in the queue, the bus proceeds to the next stop, and the event of its arrival there is generated; otherwise, the event to be generated (at present time!) is the first person in the queue boarding the bus; 3.boarder:A person boards the bus Action: The length of the queue diminishes by 1; If the queue is now empty, the bus proceeds to the next stop, otherwise the next passenger boards the bus

Assme: It takes everyone the same time to enter the bus As many people (on average) exit the bus as enter it, and the time to exit the bus is negligible. Consequence: we do not consider the exit event in our model The stops are equally spaced in a circle The buses may not pass one another

Data: 15 bus stops; 5 buses;

The time to drive between any two contiguous stops is 5 minutes; The passengers mean arrival rate at each stop is 5 persons/min

The boarding time is 2 seconds for each passenger; The total simulation time is 8 hours.

The purpose of the simulation is to observe the behavior of the system, and answer the following questions: 1. Does the distance between the adjacent buses remain the same? If not, what should be done to ensure that it be the same? 2. What is the average size of a waiting queue at each stop (and what are its maximum and minimum)? (You may provide this information on an hourly [simulation time] base.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!