Reducing CO2 Emissions by Optimizing Bus Schedules Using IoT

by Jonathanrjpereira in Workshop > Science

434 Views, 3 Favorites, 0 Comments

Reducing CO2 Emissions by Optimizing Bus Schedules Using IoT

Asset 10.png

The project aims to optimize public transport bus schedules to lower costs and reduce carbon emissions using passenger occupancy data.

A Dynamic Thresholding algorithm is applied to the passenger occupancy data to improve the efficiency of the system.

Using the dynamic thresholding algorithm, it is possible for our university's transport system to reduce fuel consumption by ~960 gallons/year thereby reducing the total fuel cost by ~$1,440/year and that's all for a single bus. Additionally, the algorithm reduces CO2 emissions by more than 2000lbs/year for a single bus.

Generating Data

Asset 4.png
Asset 5.png

Optical infrared sensors mounted on the bus doors can count the number of passengers that enter or exit the bus.

There are two sensors mounted next to each other placed close to the door. Each sensor contains a transmitter and a receiver. The transmitter constantly sends out pulses of light.

When a passenger walks in front of the sensor (sensor tx/rx pair is triggered), the transmitted light is reflected back to the receiver.

The system can sense two scenarios: Enter and Exit.

Enter: When Sensor 1 is triggered before Sensor 2, it is assumed that a passenger has entered the bus.

Exit: When Sensor 1 is triggered after Sensor 2, it is assumed that a passenger has exited the bus.

The data is then sent via MQTT to a public database that can be accessed through an open API.

Data Collection

The passenger occupancy data for a particular bus route is sampled periodically via the transport agency's public API and stored in a database.

In this tutorial, the Transloc API is used to gather passenger occupancy data for my university's off-campus buses.

Data Sampling

This step can be generalized to a specific city's/university's public bus transport system.

In our example. the data of several buses and bus routes can be sampled and stored in a database. Our example will focus on one particular data sample for a single bus that plys a single bus route. The data snippet is for the Weekend RIT Inn bus and was sampled in March for approximately 5 hours (6 PM to 10:40 PM) in the evening (The data collection was limited due to the Coronavirus pandemic). The bus route consists of 6 separate stops and a round trip takes 35 minutes to complete. The bus schedule begins at 7:00 AM and ends at 1:40 AM. The full bus schedule can be found here.

Data Processing

Asset 7.png

The data is sampled just below the APIs rate limit (~2.2/min) and stored in a CSV file. First, the data is averaged for each minute (1-minute bins). This ensures each minute of the total sampling time period (approx. 5 hours) contains a single passenger occupancy value associated with it. The data is also averaged for 5-minute bins. Since the round trip time is 35 minutes, the data is also averaged for 35-minute bins. The 35-minute bins will be the basis upon which the schedule will be optimized. The figure below shows the average passenger occupancy (%) for the 1 minute, 5 minute, and 35 minute bins.

In the above figure, we can observe, the average passenger occupancy for each of the eight 35 minute round trips. The highest average passenger occupancy occurs for the 1st round trip which started at 18:05 PM.

Passenger Occupancy Thresholding

To optimize the bus schedule, we can set a threshold value for whether a bus should operate for a particular round trip timeslot. To begin with, we can assume a threshold of 10% passenger occupancy i.e. a bus will operate for a particular round trip timeslot only if the average passenger occupancy for that timeslot is greater than equal to 10% of the bus's total capacity. The first row in the figure below shows the 35-minute time slots for a 10% threshold. The yellow block indicates that the average passenger occupancy for that time slot was greater than or equal to 10% while the remaining blue blocks did not meet the threshold value.

Dynamic Thresholding

daw.JPG

If we were to use a single threshold value, for example, 10%, a condition may arise when no bus is scheduled for a long period of time since passenger occupancy is extremely low during non-peak hours especially in the evening once most classes are over. This can be observed by several adjacent blue-colored time slots in the first row of the figure above.

By creating separate thresholds for typical working/class hours (9 AM to 7 PM) and non-working hours (7 PM onwards), we can further optimize the bus schedule whilst ensuring a convenient service for passengers. For example, if a threshold of 5% is used for all time slots beginning around 7 PM, we can see an increase in the number of yellow blocks indicating that the bus will operate for that particular time slot as depicted by the second row in the above figure.

Schedule Optimization

grgn.JPG

The last row in the figure below shows how the bus schedule can be optimized by implementing dynamic thresholding i.e. 10% during working hours and 5% during non-working hours. The green blocks indicate time slots for which a bus will operate while the red blocks indicate that a bus will not run during that particular timeslot. For this 5-hour data snippet, the schedule was optimized such that the bus operates for only 4/8 time slots or 50% of the total operation window. Even at this rate, the bus will not meet its full capacity i.e. overcrowding will not take place.

Results

The results published in this section are specific to the bus system used at our university. The results will vary based on the city/university's public transport infrastructure.

From the previous step's figure, we can observe that the bus will run for half the time it typically does as a result of the dynamic thresholding optimization algorithm. The round trip Weekend RIT Inn bus route is approximately 10 miles. Hence for the 5-hour time slot, the distance covered by the bus will decrease by 40 miles.

According to the US Department of Energy, the average fuel economy for a transit bus is 3.26 miles per gallon of gasoline[1]. The round trip Weekend RIT Inn bus route is approximately 10 miles. Hence a single round trip should consume around 3 gallons of fuel. For this 5-hour data snippet itself, the optimized schedule will save around 12 gallons of fuel per day, 24 gallons per Weekend, and around 960 gallons per year (assuming 40 working weeks).

At $1.5 per gallon of fuel, the total fuel cost can be reduced by approximately $1,440 per year (for just a single bus based on 5 hours of data).

According to the US Department of Transportation, bus transit emits 0.64 lbs of CO2 per passenger mile[2]. Hence for 40 miles x 2 days x 40 weeks x 0.64, a single bus (5-hour time slot) can reduce its CO2 emissions by more than 2000lbs. Note: Passenger miles = vehicle miles x average number of passengers on the vehicle. Normalizing by passenger miles allows for comparison between vehicles carrying different numbers of passengers

Code

The code will help you to gather and store the data in a CSV file. It will also help you to create and visualize optimized bus schedules.

GitHub Code Repository

Prerequisites:
You can install the necessary dependencies by running the requirements.txt file.

  • Python 3x
  • Numpy
  • Pandas
  • Matplotlib
  • Seaborn
  • Requests

Transloc API:
The Transloc API provides API calls that can be used to retrieve a list of Agencies. Using an Agency ID, we can get a list of routes for a particular agency. We can also get location, arrival time, compass, and passenger occupancy data for buses operating on a particular route. More information can be found on the Transloc API website.

We use the Requests library to make API requests and retrieve the passenger occupancy data. The code factors in the API request rate limit and ensures that it does not exceed the limit.

Storing the Data:
The sampled passenger occupancy data for each bus is stored in a new line within a CSV file along with the current timestamp using the CSV library.

Data Visualization:
A Pandas data frame is created for each bus route (CSV columns) and the heatmaps and thresholding graphs were created using the Seaborn and Matplotlib heatmap functionality.