COS2611 Final Project 2024 solution
Highway traffic flow analyser
Final Practical Project - Mark contributes to the final examination mark.
Study the scenario that will monitor and analyse traffic patterns to determine if the road can handle the volume or if it
requires expansion
Follow the instructions to develop, test and submit the project.
Click on ADD SUBMISSION to see the details and activity instructions.
Highway traffic flow analyser
Scenario:
Imagine a single-lane road in a suburb of Cape Town that experiences varying traffic flow throughout the day. Over a
period of 6 days, traffic engineers need to monitor and analyse these patterns to determine if the road can handle the
volume or if it requires expansion. They contacted you, as a student in Computer Science to assist them.
1. Data Collection
The traffic department of Cape Town provides you with the data in a text file () - see attached.
Typical data in the :
Timestamp; Vehicle Type; Speed (km/h)
:00:00; Motorbike; 45
:14:23; Bus; 115
2. Your C+++ Console Program
Your task is to, using C++, develop a traffic flow analyser that monitors and analyses the flow of cars on a specific stretch
of single lane road.
The program will read the captured data from the file and, using appropriate methods and functions, analyse trends,
calculate averages, identify peak traffic times, and generate a report to assist road planners in making informed decisions
about future road development. You may use any of the functions or methods we have studied throughout the year in this
project, but you must include comments in your code explaining each step and your reasoning for choosing specific
methods or functions. Additionally, you may include documentation within the comments to help the examiner understand
your logic and decisions.
3. Choose any three (3) of the following reports to generate
Report 1. Traffic Summary Report
Total vehicles: The total number of vehicles recorded over the specified period.
Vehicle count per day: A breakdown of the number of vehicles passing per day.
Vehicle type distribution: The number and percentage of each vehicle type (e.g., cars, buses, bikes).
Example output:
Traffic Summary Report:
-----------------------
Total vehicles: 1200
Day 1: 250 vehicles
Day 2: 300 vehicles
...
Vehicle distribution:
- Cars: 800 (66.67%)
- Buses: 100 (8.33%)
- Motorbikes: 300 (25.00%)
Report 2. Peak Traffic Times Report
Hourly peak traffic: Identify the hours with the highest traffic volume.
Daily peak traffic: Determine which day had the most traffic.
Time intervals with maximum congestion: Specific times where the road was most congested.
Example output:
Peak Traffic Times Report:
--------------------------
Peak traffic time (overall): 17:00 - 18:00 with 150 vehicles
Peak traffic by day:
- Day 1: 16:00 - 17:00, 45 vehicles
- Day 2: 17:00 - 18:00, 60 vehicles
...
Report 3. Speed Analysis Report
Average speed of vehicles: Display the average speed of vehicles passing over the specified period.
Speed ranges: Categorize vehicle speeds (e.g., slow, medium, fast) and report on how many falls into each category.
Example output:Speed Analysis Report:
----------------------
Average speed: 55.4 km/h
Speed distribution:
- Slow (0-30 km/h): 50 vehicles
- Medium (30-60 km/h): 600 vehicles
- Fast (60+ km/h): 550 vehicles
Report 4. Congestion Level Report
Congestion trends: Identify periods where traffic flow is significantly higher than average, indicating congestion.
Congestion by day/hour: Report on the most congested times of each day and the overall period.
Example output:
Congestion Level Report:
------------------------
Average congestion level: Moderate
Most congested period: Day 3, 17:00 - 18:00, with 80 vehicles
Congestion breakdown by day:
- Day 1: Low (200 vehicles)
- Day 2: High (300 vehicles)
...
Report 5. Custom Time Interval Report
User-specified time intervals: Allow the user to specify custom time intervals (e.g., "report from 09:00 to 12:00 over 5
days") to generate tailored traffic data.
Example output:
Custom Interval Report (09:00 to 12:00):
----------------------------------------
Total vehicles: 400
Average speed: 52.3 km/h
Most congested time: 11:00 - 12:00, 80 vehicles
Report 6. Vehicle Type-Specific Report
Traffic trends for specific vehicle types: Provide a report focusing on a particular type of vehicle (e.g., just cars, or buses).
Example output:
Vehicle Type Report (Buses):
----------------------------
Total buses: 150
Peak time: 18:00 - 19:00, 25 buses
Average speed: 40.2 km/h4. Develop, test and compile your C++ code. When you are ready to submit, add your student number and name
in the FIRST line of the .cpp as a comment. Any classes and/ or packages that you either develop or import
should be part of the .cpp code. The folder for the .txt file should refer to C:data (the examiner
will use a different set of data to test your systems).
5.Save your file as yourStudentNumber_FP.cpp, for example, _FP.cpp. Replace with YOUR
student number. Upload it on or before the due date. The due date is not the day to start this project; it is the day
by which you must submit it. Keep in mind potential issues such as internet problems, load shedding, myUNISA
unavailability, etc.
Any file that does not include your student details and/or saved with your student number, will NOT BE
ASSESSED.
6. The following rubric will be used to assess your three projects and code:
Criteria
Student
Marks Mark
Description
Report 1 Generation (10 Marks)
Correctness of Data
Report accurately reflects the correct data and performs correct
calculations.
2
Completeness of ReportIncludes all required elements (e.g., totals, peak times, averages).2
Data Presentation and ClarityWell-formatted, easy to read, and presents data clearly.2
Trend AnalysisIdentifies and explains trends (e.g., peak times, congestion).2
Allows customisation and easy interaction for generating reports.2
User Interaction and
Customization
Report 2 Generation (10 Marks)
Correctness of Data
Report accurately reflects the correct data and performs correct
calculations.
2
Completeness of ReportIncludes all required elements (e.g., totals, peak times, averages).2
Data Presentation and ClarityWell-formatted, easy to read, and presents data clearly.2
Trend AnalysisIdentifies and explains trends (e.g., peak times, congestion).2
Allows customisation and easy interaction for generating reports.2
User Interaction and
Customization
Report 3 Generation (10 Marks)
Correctness of Data
Report accurately reflects the correct data and performs correct
calculations.
2
Completeness of ReportIncludes all required elements (e.g., totals, peak times, averages).2
Data Presentation and ClarityWell-formatted, easy to read, and presents data clearly.2
Trend AnalysisIdentifies and explains trends (e.g., peak times, congestion).2
User Interaction and
CustomizationAllows customisation and easy interaction for generating reports.2
FunctionalityCode functions as expected, generating correct reports without
errors.4
Code Structure and ReadabilityWell-organized, follows good practices, and is easy to understand.2
Commenting andWell-commented code with explanations for key decisions andDocumentationmethods used.Error HandlingAppropriate error handling for invalid input, file errors, etc.
Coding Quality (10 Marks)
Vista previa del contenido
COS2611 2024 FINAL PROJECT
SOLUTION(100% working)
Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187
Copy and run the code and submit what you are suppose to submit
, OUTPUT
Source Code
// Student Number:
// Name:
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
// Struct to hold traffic data
struct TrafficData {
string timestamp;
string vehicleType;
int speed;
};
// Function to read traffic data from file
vector<TrafficData> readTrafficData(const string &filePath) {
vector<TrafficData> data;