Roles in Short term - smart-fm/simmobility-prod GitHub Wiki

Every person, at any given point during the simulation, has a role. The role defines what the person will do in each time step of the simulation. The role is aligned with the person current trip chain item.

The following roles are implemented in the Short-term simulator:

  • Driver
  • Bus driver
  • Passenger
  • Pedestrian
  • Wait bus activity
  • Activity performer

For every role, we create a specific class derived from the generic Role class. This class is used to capture the properties of the role. Additionally, we create movement facet classes derived from the MovementFacet class for every role. These are used to capture the movement behaviours for the respective roles. The frame_init(), frame_tick() and the frame_tick_output() methods are the entry points into the MovementFacet class. frame_init() is performed only once, before the first simulated time step of the person. Initialisation related steps are performed here. frame_tick() is executed every update step and all the role specific functions are executed from within this method. frame_tick_output() is used to store the result of the time step into the output file.

The details of the implementation of each role are given below.

Driver

The specialised classes for this role are Driver and DriverMovement. These two classes are implemented in Driver.*pp and DriverFacets.*pp respectively. As these files are specific for the Short-term, they are located under the driver folder at short/entities/roles/.

The Driver class stores information about the driver, such as the reaction time, perceived values of speed and acceleration and the positional information among others. Some of this information is stored in shared variables, so that other drivers may access it to make certain decisions.

The DriverMovement class is responsible for capturing the driver's decisions and the corresponding movements of the vehicle. In this class, the initialisation mainly involves deciding the route to be taken. As mentioned above, it is done through the frame_init() method. In the frame_tick() method, the driver performs the following tasks:

  • Look for the nearby vehicles
  • Decide whether to change lanes or stay in the current lane using the lane changing model
  • Decide whether to accelerate or decelerate based on the car-following & intersection driving models
  • Drive with the computed values of speed and acceleration

The actual movement of the vehicle along the lane is the responsibility of the DriverPathMover class. It uses the lane poly-lines to guide the vehicle along the lane.

Bus Driver

The BusDriver class is a specialisation of the Driver class. In addition to the information held by the Driver class, the BusDriver holds information like the bus route, the bus stops, passengers in the bus and so on. Similarly, the BusDriverMovement class is a specialisation of the DriverMovement class. As a result, the movement of the BusDriver is done by the same methods as the generic Driver, but that movement is guided by the bus stops along the route to be taken. The BusDriver and the BusDriverMovement classes are implemented in the the BusDriver.*pp and the BusDriverFacets.*pp files respectively. They are also located under the driver folder at short/entities/roles/.

The frame_init() method of the BusDriverMovement is responsible for retrieving the bus line and the corresponding bus route along with the stops. The frame_tick() method calls the Driver's frame_tick() method in order to perform the driving tasks. Additionally, it notifies the BusStopAgent corresponding to the arriving BusStop of the imminent arrival of the bus. This allows the BusStopAgent to notify the waiting persons, who can then decide on whether or not to board the bus. The BusDriver handles messages from the waiting person for boarding.

Passenger

Like the other roles, this role is implemented with the help of the Passenger and the PassengerMovement classes. These are implemented in the Passenger.*pp and PassengerFacets.*pp files. They are located under the passenger folder at short/entities/roles/.

The frame_init() method in the PassengerMovement class simply sets the start and end points and the frame_tick() method checks whether the end point has been reached. The Passenger class handles messages from the BusDriver for making the alighting decision.

Pedestrian

The Pedestrian role and movement behaviour are implemented in the files Pedestrian.*pp and PedestrianFacets.*pp respectively. These files are located under the pedestrian folder at short/entities/roles/.

Due to the absence of a pedestrian movement model, the PedestrianMovement class is rudimentary. The frame_init() method simply computes the euclidean distance between the start and end points and the 'frame_tick()' method updates the distance covered every time step.

Wait Bus Activity

The specialised classes for this role are WaitBusActivity and WaitBusActivityMovement. These two classes are implemented in WaitBusActivity.*pp and WaitBusActivityFacets.*pp respectively. They are located under the waitBusActivity folder at short/entities/roles/.

This role act as a filler. As a result, it does nothing but increase the waiting time in the frame_tick() method. The WaitBusActivity class tracks the waiting time along with the number of times the person failed to board the bus.

Activity Performer

This role is shared. It is implemented in the classes ActivityPerformer and ActivityPerformerMovement and the files ActivityPerformer.hpp and ActivityFacets.hpp are located in the activityRole folder under shared/enitites/roles/.

The ActivityPerformer class holds information about the start and end times of the activity. The ActivityPerformerMovement simply updates the time remaining for the activity to be completed in the frame_tick() method.