## Appendix B
The variable routingMode is for selecting the routing mode, with 0 is selected the ROUTING_MODE_DEFAULT, which uses the loaded travel times through traci.edge.adaptTraveltime('segment_name', _actualizar_) for finding a convenient (with the least travel time) route (with ID _routelD_). A vehicle is generated if _li_existo[vehID]! = 0_, the vehicle name (or ID) is _vehID_ (when used as a name it needs to be converted to a string since it is a number) which also works as an index. The vehicle is generated with the function traci.vehicle.add() which has several parameters: the vehicle _vehID_ with route _routeID_ with vehicle type ID 'pasajero' will depart at the current time step (_step_), departLane = 'random' is for selecting a random lane for the vehicle to be inserted, departPos = 'base' indicates that the vehicle will appear at the beginning of the edge, departSpeed = '8.3333' indicates that the vehicle is tried to be inserted with a speed \(\cong\) 8.33 m/s, arrivalLane = 'current' indicates that the vehicle will arrive at the final edge (the last edge of its route) by the lane in which will be traveling at that time, arrivalPos ='max' indicates that the vehicle will drive to the end of the final edge, arrivalSpeed = 'current' indicates that the vehicle will not change its current speed when reaching its destination. Algorithm A6 presents the code for selecting vehicles that will not be generated in the next simulations. ```
per1 = per1 + 1; if per1 == intervalo: per1 = 0; for i in range(entradas): if vehID + 1 >= nt: break vehID = vehID + 1 rutal = traci.simulation.findRoute(origen[i], destino][i_de[vehID]], vType = 'pasajero', depart = step, routingMode = 0) rutal = list(rutal.edges) if rutal in lista_Routes: routeID = lista_Routes.index(ruta1) else: lista_Routes.append(ruta1) routeID = lista_Routes.index(ruta1) r taci.route.add(str(routeID), ruta1) if li_existo[vehID] == 0: pass else: track.vehicle.add(str(vehID), str(routeID), typeID = 'pasajero', depart = step, departLane = 'random', departPos = 'base', departSpeed = '8.3333', arrivalLane = 'current', arrivalPos ='max', arrivalSpeed = 'current') try: temporal = traci.vehicle.getMaxSpeed(str(vehID)) total + 1 li_ru.append(ruta1) except: pass
```
**Algorithm A5** Function sim10, part 3. Generating vehicles and routes  
If _par_impar%_0 == 0, we are in a SS. At the end of a simulation, in _eliminar_ is assigned a copy of _li_mi_, thus in _eliminar[espacio]_ we have the low-speed segments detected in _espacio_ (the period index). If the current simulation time is in the range (0, 90], _espacio_ = 0, if it is in the range (90, 180], _espacio_ = 1, and so on. To proceed with the selection of vehicles, for the segments in _eliminar[espacio]_ with traffic lights, the current time (_new_step_, which restarts every 90 s to be in line with the traffic lights' cycle) should fall inside the measurement range, for the segments without traffic light no condition regarding the time applies. Then, if a vehicle is in a low-speed segment and considering the time condition if applies, if _ubicacion_ > \(d1\) and _ubicacion_ < _(longitud-d2)_, and if its current speed is less than _v1_ = (_vel_nor_/2)\(\times\)_factor_, the vehicle is selected for not being generated in the following simulations, therefore we set _li_existe[vehID]_ = 0. The variable _ubicacion_ is the vehicle position with respect to the segment and _longitud_ is the segment' length, \(d1\) is the distance required by the vehicle to overcome \(v1\) if it enters the segment at the low-speed \(v0=~{}10~{}\text{km}/\text{h}\cong 2.77~{}\text{m}/\text{s}\), and _longitud-d2_ is the distance required by the vehicle for reducing its speed from \(v1\) to \(v0\) (if the vehicle is leaving the segment at the low-speed \(v0\)). The area of the segment for which _ubicacion_ > \(d1\) and _ubicacion_ < (_longitud-d2_) is called the segment' selection area.