In this section, we describe the procedure followed when attempting to obtain an accurate OD matrix for the city of Valencia, Spain, where nowadays such essential data still remain unavailable. Notice that many of the cities around the world rely on this method and often lack any other sources of data beyond it. The most critical data for simulation experiments to be representative is the number of vehicles that are injected into the network and their destination (OD matrix). In this regard, the DFROUTER tool is able to generate data encompassing routes and the number of vehicles associated with each route. Although not strictly an OD matrix, such a matrix can be generated based on these data.
Below we describe the methodology followed to accomplish our goal of obtaining realistic traffic flow data, starting with an analysis of DFROUTER’s output, followed by the proposed heuristic, gradually reducing the number of vehicles passing through the induction loops and readjusting the number of vehicles to be injected in each segment until approaching the reference traffic, which is then validated against real data.
4.2. Proposed Iterative Heuristic
Considering the mismatch between DFROUTER’s output and real data described in the previous section, we now propose an adjustment heuristic to compensate this error and make the number of vehicles in our simulation environment as realistic as possible.
To achieve our goal, we propose a heuristic called “iterative” that regulates global traffic by affecting all streets in a proportional manner, thereby allowing one to adjust the traffic volume according to the reference data. In particular, since there are dependencies between induction counts on different streets and the traffic injected, the iterative process is required to find the best fit. The proposed heuristic is shown in Algorithm 1.
As input data, we have the information concerning vehicular traffic at a specific time, available as detector counts, and the associated street segment ID.
An initial run of DFROUTER is required for obtaining routes and the OD matrix using the reference induction loop data as input. The outcome of this first run returns an excess of 138.9% in terms of traffic volume, a value that is then refined using our proposed heuristic. In particular, it will adjust iteratively the number of vehicles injected in every street as provided to DFROUTER so that, when the output converges, the total number of vehicles accounted in the output of DFROUTER approaches the reference value. For this purpose, given a maximum number of iterations
${n}_{max}\in \mathbb{N}$ and a maximum admissible error
$\epsilon >0$, we will build a succession of intervals
${\left(\right)}_{\left(\right)}^{{\phi}_{min}^{n}}n=0k$ of traffic flow adjustment factors, with
$k\le {n}_{max}$ and
$\left(\right)open="["\; close="]">{\phi}_{min}^{n+1},{\phi}_{max}^{n+1}\forall n$, as well as a succession
${\left(\right)}_{{\phi}_{n}}^{}$ with
${\phi}_{n}\in \left(\right)open="["\; close="]">{\phi}_{min}^{n},{\phi}_{max}^{n}$, so that, for each iteration
n, we will modify the number of vehicles injected on every street
s as input to DFROUTER, and denoted by
${\tau}_{s,n}$, by relying on Equation (
1):
where
${\sigma}_{s}$ is the smallest number of vehicles detected among all segments of the street
s,
${\omega}_{s}$ is the number of segments that conform to street
s and
$\lfloor x\rfloor $ represents the largest integer number less than
x. This formula ensures that the load corresponding to a street, according to our induction loop data, is evenly distributed among the different segments on that street. Then, we apply the traffic flow adjustment factor
${\phi}_{n}$ to each street segment of that street.
Algorithm 1 Iterative heuristic. 
 Require:
Road Network, flow, detectors files, ${n}_{max}$ and $\epsilon $  Ensure:
VehicleStreetSegmentinfo file  1:
$\alpha \leftarrow $ calculate reference number of vehicles  2:
${\phi}_{min}^{0}\leftarrow 0$,${\phi}_{0}\leftarrow {\phi}_{max}^{0}\leftarrow 1$,${\tau}_{s,0}\leftarrow \lfloor \frac{{\sigma}_{s}}{{\omega}_{s}}\xb7{\phi}_{0}\rfloor $  3:
Process input files with DFROUTER  4:
$n\leftarrow 1$  5:
${\beta}_{1}\leftarrow $ Vehicle count per street ID  6:
${\phi}_{1}\leftarrow \frac{\alpha}{{\beta}_{1}}$  7:
${\tau}_{s,1}\leftarrow \lfloor \frac{{\sigma}_{s}}{{\omega}_{s}}\xb7{\phi}_{1}\rfloor $  8:
Create a file with information about vehicles, segments and streets  9:
Apply ${\tau}_{s,1}$ to all street IDs (${\tau}_{s,n}$)  10:
${\phi}_{min}^{1}\leftarrow {\phi}_{min}^{0}$, ${\phi}_{max}^{1}\leftarrow {\phi}_{max}^{0}$  11:
while $\left\frac{{\beta}_{n}}{\alpha}1\right>\epsilon $ and $n<{n}_{max}$ do  12:
Process input files with DFROUTER  13:
$n\leftarrow n+1$  14:
${\beta}_{n}\leftarrow $ Vehicle count per street ID  15:
if $\left\frac{{\beta}_{n}}{\alpha}1\right>\epsilon $ then  16:
if ${\beta}_{n}>\alpha $ then  17:
${\phi}_{max}^{n}\leftarrow {\phi}_{n1}$,${\phi}_{min}^{n}\leftarrow {\phi}_{min}^{n1}$  18:
else if ${\beta}_{n}<\alpha $ then  19:
${\phi}_{max}^{n}\leftarrow {\phi}_{max}^{n1}$,${\phi}_{min}^{n}\leftarrow {\phi}_{n1}$  20:
end if  21:
${\phi}_{n}\leftarrow \frac{{\phi}_{max}^{n}+{\phi}_{min}^{n}}{2}$  22:
${\tau}_{s,n}\leftarrow \lfloor \frac{{\sigma}_{s}}{{\omega}_{s}}\xb7{\phi}_{n}\rfloor $ to all street IDs (${\tau}_{s,n}$)  23:
end if  24:
end while

As the initial step in our iterative algorithm, we assign initial values to the different variables involved as detailed in Equation (
2):
Then, a relationship between the number of vehicles per street ID and the reference value (
$\phi $) is calculated according to Equation (
3):
where
$\alpha $ is the real number of total vehicles passing through all street IDs (reference value) and
${\beta}_{1}$ is the simulated number of total vehicles passing through all street IDs, as provided by the initial execution of DFROUTER. In our case,
$\alpha =$ 409,499,
${\beta}_{1}=$ 978,339, and therefore,
${\phi}_{1}=0.41857$ (see
Table 1). Note that we will always have
$\alpha \le {\beta}_{1}$, although the value of
$\beta $ should converge to
$\alpha $.
For the iterations that follow (
$n>1$), the following equation applies:
We then proceed to execute DFROUTER in a loop by successfully refining the input values and obtain as output the total number of vehicles per street ID (
${\beta}_{n})$. The process continues converging until the error is close to zero by obtaining a sequence of values for
${\phi}_{max}^{n}$ and
${\phi}_{min}^{n}$ based on the relationship between
$\alpha $ and
$\beta $, so that, if
${\beta}_{n}>\alpha $, we consider that
${\phi}_{max}^{n}={\phi}_{n1},{\phi}_{min}^{n}={\phi}_{min}^{n1}$, and in the opposite case, if
${\beta}_{n}<\alpha $, we instead consider that
${\phi}_{max}^{n}={\phi}_{max}^{n1},{\phi}_{min}^{n}={\phi}_{n1}$. Then, a new
${\phi}_{n}$ value is obtained for the next iteration using Equation (
5):
A new value of
${\tau}_{s,n}$ (see Equation (
1)) can then be derived and used as input to DFROUTER. The new
$\beta $ value following each iteration
n, denoted as
${\beta}_{n}$, will be considered final when the error (
$\frac{{\beta}_{n}}{\alpha}1$) is below
$\epsilon $, or the maximum number of iterations is reached, as stated in Equation (
6):
Experimental results in
Table 1 show that, initially, the value of
$\frac{{\beta}_{n}}{\alpha}1$ will fluctuate between positive and negative values, until convergence near zero is achieved, as illustrated in
Figure 2. For instance, from
Table 1, we have that the DFROUTER output value
${\beta}_{2}$ is 439,738, which is greater than
$\alpha $, and
$\frac{{\beta}_{n}}{\alpha}1=0.07384$. Since we want a small error, from interval
$\left(\right)open="["\; close="]">{\phi}_{min}^{1},{\phi}_{max}^{1}$ and
${\phi}_{1}$ = 0.41857, the heuristic creates interval
$\left(\right)open="["\; close="]">{\phi}_{min}^{2},{\phi}_{max}^{2}$ and value
${\phi}_{2}$ = 0.20928.
Convergence is guaranteed in the scope of the proposed iterative heuristic, as we prove next:
On the one hand, we have that:
Therefore,
which implies that:
On the other hand,
${\phi}_{n}\in \left(\right)open="["\; close="]">{\phi}_{min}^{n},{\phi}_{max}^{n}$. Consequently, applying the sandwich criterion, we have that:
which in turn implies that:
Note that values ${\tau}_{s,n}$ must be integers because they represent numbers of vehicles. Therefore, the existence of the above limits implies that $\exists {n}_{0}\in \mathbb{N}$ such that ${\forall}_{n}\ge {n}_{0}$ and $\forall s\phantom{\rule{3.33333pt}{0ex}}\phantom{\rule{3.33333pt}{0ex}}{\tau}_{s,n}={\tau}_{s,{n}_{0}}$. That is, from iteration ${n}_{0}$, the input data to DFROUTER are always the same, and as DFROUTER is deterministic, its output data will also be always the same. This guarantees the existence of $\underset{n\to \infty}{lim}{\beta}_{n}$, which does not necessarily coincide with $\alpha $ because both $\alpha $ and the limit are integer values, but according to the construction of the successions in the algorithm, it must be very close to $\alpha $. Hence, given a reasonable upper bound to the number of iterations ${n}_{max}$ and a reasonable error $\epsilon >0$, it is expected that for some $n\le {n}_{max}$, $\begin{array}{c}\frac{{\beta}_{n}}{\alpha}1\end{array}<\epsilon \phantom{\rule{0.0pt}{0ex}}$. Otherwise, the algorithm will stop in value ${\beta}_{{n}_{max}}$.
When the execution of Algorithm 1 ends, we generate two files that contain traffic information associated with the various street segment IDs. The first one is composed by a tuple of two elements, where each tuple includes: (1) street segment ID and (2) the number of vehicles per segment ID. The second file aggregates different street segment IDs belonging to the same street, and it includes a set of three elements: (1) street ID, (2) associated segment ID and (3) segment ID with the lowest number of vehicles, where the latter corresponds to the number of vehicles injected that start on that particular street.