Overview

This was a coursework carried out individually in the course Computer Science Large Practical with the purpose of training us on creating a complex system. The coursework was done in C.

The task was to build an on-demand public transport system simulator where users requests (desired pickup time, source and destination stops) are scheduled. And minibus are dispatched to pick up users with similar journey.

Essentially, the system received the below arguments as input and from these arguments, the system generated events that moved the simulation forward in simulation time.

  • Bus Capacity: specify the maximum number of passengers in the minibus.
  • Boarding Time: specify the time in second to board a minibus.
  • Request Rate: specify the rate to which to generate the next request per hour.
  • Pickup Interval: specify the average pickup time between the request and the desired pickup time.
  • Max Delay: specify the maximum delay that a minibus can wait for a passenger beyond his/her desired pickup time.
  • Number of Minibuses: the number of minibuses in the service network.
  • Number of Stops: the number of bus station in the region.
  • Map: the service network or bus stations. Modelled as directed graph, where the cost of edges correspond to minute time it takes to travel from one station to another station.

An example of the end result of transforming a map to a directed weighted graph:

map_example

  • Stop Time: the duration of the simulation, specified in hours.

Actions:

I broke down the system into these subsystems:

  • Request system:  responsible to generate request, departure and destination station for individual users.
  • Parser system: responsible to parse the inputs and validate whether the inputs are well-formed.
  • Route manager system: responsible for managing routes of the different minibuses.
  • Minibus system: responsible for maintaining the states of the minibus and keep track of the statistics associated with a minibus.
  • Output system: display on the terminal the events associated with the simulation. Displayed below.
  • Scheduler system: takes as inputs: request, minibuses and routes and determine whether the request is accommodated or not.    
  • Events system: decide which event to compute next, and compute the state of each minibus. The events included state such as:
    • Generate Request: if this event is fired, the system will have to generate a new request.
    • Arrive: tells the system that a minibus has just arrived at a station
    • Leave: tells the system that a bus is supposed to leave a station
    • Board: tells the system that a passenger has to board.
    • Disembark: tells the system that a passenger has to disembark.
    • Wait: tells the system that the current bus has to wait. Or is idle
    • Outofservice: tells the system that the current minibus is not accommodating any passenger at the moment and is out of service.

Example of inputs that determine some states of the system:

An example of input that was fed into the system

And from this, it generates the output as the example below:

Output example

 

90%
80%
80%
75%
70%