# A Digital Twin for Intelligent Transportation Systems in Interurban Scenarios
## 4 Digital Twin Implementation
### Traffic Simulator Module  
To feed the digital twin presented in this paper, traffic data from sensors deployed along the C-32 highway has been used. The data includes vehicle intensity (vehicles per hour) at each entrance, exit, and turn of the highway, with a 5-min resolution. These data enter the Traffic Simulator through the Pre-processing module shown in Figure 2.  
The Aimsun Next tool [28] is used to simulate highway traffic and to test different strategies. Aimsun Next is a powerful multi-resolution and multi-modal mobility simulator capable of simulating any personalized scenario. The highway has been recreated in the simulator by building a map divided into different sections, each located between two consecutive entrances and exits of the highway (cf. Section 5). The map has been created by specifying the location, length, shape, and speed limit of each section. The traffic data measured in these sections has been processed to apply the strategies to improve different parameters depending on the type of incident, i.e., congestion or pollution.  
To study the impact of incidents over a long period of time and to test possible ways to alleviate their effects, we have chosen to conduct simulations that replicate the real traffic conditions for 1 h. The input data, collected at 5-min intervals, consists of traffic flows of vehicles entering, exiting, and turning at highway entrances and exits. The simulations start with an empty map and have an additional transitory period until the vehicles fill the road and reach a permanent regimen. Each simulation is performed 10 times, changing the initial seed, and averaging the results.  
Different vehicle types can be inserted into the simulation. The pollution use case considers trucks, cars, and motorbikes. In addition, other characteristics related to the vehicles can also be specified, such as speed limit, acceptance of the speed limit, and cooperation with other vehicles. Vehicle type percentages must also be defined to provide more realistic results, especially when calculating vehicle emissions.  
Incidents are detected in the Pre-processing module and are replicated in the simulator to reproduce the real scenario. They can be placed at any point on the map to simulate an accident, with specific configurations for location, duration, length, and lane of the incident.  
The simulator module outputs the following KPIs for performance evaluation: vehicle travel time, defined as the duration a vehicle requires to complete its journey; vehicle speed; vehicle speed deviation, defined as the difference in speeds between vehicles traveling in the same direction; number of vehicles in the highway; vehicle intensity, measured as the number of vehicles per hour; vehicle occupancy, defined as the number of vehicles per km; and emission levels for the pollutants CO, NOx, and PM2.5, expressed as g/km. The KPIs are collected and averaged across the entire highway in the direction of the incident and are defined as total travel time, average speed, average speed deviation, average number of vehicles, average intensity, average occupancy, average CO, average NOx, and average PM2.5.