## Appendix B
= -1: lista_medicion2[k].append(speed_green) densidad2[k].append(traci.edge.getLastStepVehicleNumber(edge)) k = k + 1```
con1 = con1 + 1 if con1 == periodo: if len(li_mi) < con3 + 1: li_mi.append([]) k = 0 for edge in lista_Edgeld: if len(lista_medicion2[k])!= 0:  vp = sum(lista_medicion2[k])/len(lista_medicion2[k])  DENSIDAD2[k].append((sum(densidad2[k])/len(densidad2[k]))/ (lista_LaneNumber[k]*lista_EdgeLength[k]) else:  DENSIDAD2[k].append(0)  vp = vel_nor lista_vp[k].append(vp) if vp <= v_b and edge not in negar: li_mi[con3].append(edge) lista_vg[k].append(sum(lista_medicion1[k])/len(lista_medicion1[k])) DENSIDAD[k].append((sum(densidad[k])/len(densidad[k]))/ (lista_LaneNumber[k]*lista_EdgeLength[k]))  difl = dif2 = dif3 = inf; peso1 = peso2 = peso3 = 0; parte0 = parte1 = parte2 = parte3 = 0; parte0 = lista_TravelTime[k]; lista_TravelTime[k] = lista_EdgeLength[k]/(lista_vg[k][-1]) parte1 = lista_TravelTime[k]; parte3 = lista_usual[k] if con3 >= 1:  difl = abs(parte0-parte1)  difl3 = abs(parte3-parte1) if con3 >= 2:  vg_pro = sum(lista_vg[k][0:con3])/len(lista_vg[k][0:con3])  dif2 = abs((lista_EdgeLength[k]/vg_pro)--parte1) min2 = min([dif1,dif2,dif3]); if min2!= inf: if (dif1 == min2):  lista_count[k][0] = lista_count[k][0] + 1 if (dif2 == min2):  lista_count[k][1] = lista_count[k][1] + 1 if (dif3 == min2):  lista_count[k][2] = lista_count[k][2] + 1  cuenta_t = lista_count[k][0] + lista_count[k][1] + lista_count[k][2]
```
if cuenta_t!=0:  peso1 = lista_count[k][0]/cuenta_t  peso2 = lista_count[k][1]/cuenta_t  peso3 = lista_count[k][2]/cuenta_t  vg_pro = sum(lista_vg[k])/len(lista_vg[k])  parte2 = (lista_EdgeLength[k]/vg_pro)  actualizar = (parte1*peso1) + (parte2*peso2) + (parte3*peso3) if actualizar!=0:  traci.edge.adaptTraveltime(edge, actualizar) else:  traci.edge.adaptTraveltime(edge, lista_TravelTime[k])  lista_medicion1[k] = []lista_medicion2[k] = []densidad[k] = [];  densidad2[k] = [];  k = k + 1  con1 = 0;  con3 = con3 + 1;
```
**Algorithm 4**_Cont_. Each _periodo_ = 90 s, the _vg_ and _vp_ of each segment are calculated, also we estimate the travel time of each segment with the procedure presented in Algorithm 4. The variable _vp_ is the average of the content in _lista_medicion2[k]_, if the condition _vp_ < _v_b_ is True, then the \(k\) segment is considered a low-speed segment and is added to the list _li_mi[son3]_, with _con_3 being the period index. The current _vp_ value is added to _lista_vp[k]_. The variable _vg_, which is the average of the data in _lista_medicion1[k]_, is added to _lista_pg[k]_. The travel time of the \(k\) segment is set with _actualizer_ = (_parte1*peso1_) + (_parte2*peso2_) + (_parte3*peso3_). The variable _parte1_ = _lista_EdgeLength[k]/vg_ is the travel time calculated with the current _vg_, _parte2_ is the travel time calculated with the average of _vg_ values (from the first period to the last), and _parte3_ is a constant travel time. The weights (_peso1_, _peso2_ and _peso3_) are recalculated at each period incrementing the weight of the respective variable (_parte1_, _parte2_ or _parte3_) that is likely to be similar to the travel time (_parte1_) of the next period. Algorithm 5 presents the code to generate vehicles and routes. The destination of a vehicle is in the list _li_de_ (the ID of a vehicle is used as the position index of its destination), the destinations were sorted in a way that a destination is not repeated until all (fifteen) destinations have been selected. The built-in SUMO function for generating a route is: traci.simulation.findRoute(_origen_, _destino_, vType = 'pasajero', depart = _step_, routingMode = 0), where _origen_ and _destino_ are the variables referencing the names of the entry and exit segments, respectively. The parameter Vtype is equal to 'pasajero', the parameters values of a vehicle with _id_ = 'pasajero' have already been explained (in the vehicles' parameters section). The variable depart is to establish the time at which the vehicle enters the network (_step_ is the current time step).