# DMRVR: Dynamic Milk-Run Vehicle Routing Solution Using Fog-Based Vehicular Ad Hoc Networks
## 3 DMRVR Solution
### Uninterrupted Milk-Run Cycle  
This situation is observed when the vehicle is able to perform, in a tour, the complete milk-run cycle, collecting all the components from the various suppliers and delivering them to the central OEM company in due time. The vehicle starts at the OEM premise to load the empty containers into the truck used to transport the components. It takes \(t^{(1)}_{OEM}\) minutes to perform this action. Next, the vehicle travels towards supplier 1. Along the way, it spends a time \(t^{(tr)}_{1}\), which includes effective vehicle travel, delays on the route, bypasses, etc., to supplier 1. At supplier 1, the vehicle may be subjected to a tardiness time \(t^{(tr)}_{1}\), due to manufacturing problems. The loading time at supplier 1 is \(t^{(ld)}_{1}\). All variables are random. This process continues tentatively performing the planned visits until the last supplier \(n\). When the last supplier \(n\) is served, the vehicle travels to the OEM facility, spending a time \(t^{(tv)}_{n+1}\). The unloading time at the OEM is \(t^{(2)}_{OEM}\). Suppose the vehicle is at supplier \(k\). The stochastic regeneration point (i.e., the transition stage) of the truck evolution process is assumed to be the instant when the vehicle has finished the collecting task at supplier \(k\) and is ready to depart to the next supplier \(k+1\). The accomplished cycle time up to this stage \(k\) is:  
\[T^{(past)}_{\gets k}=t^{(1)}_{OEM}+\sum_{i=1}^{k}\left[t^{(tv)}_{i}+t^{( trd)}_{i}+t^{(ld)}_{i}\right] \tag{1}\]  
where \(T^{(past)}_{\gets k}\) is the historical vehicle elapsed time up to the regeneration stage \(k\). Hence, \(T^{(past)}_{\gets k}\) is a deterministic variable because it represents the sum of times that effectively have occurred. From stage \(k\) on, one deals with variable expectation times, here represented generally by \(\tau(.)\). Adding up all the feature times from stage \(k\), to the delivery of components at the OEM company, one has:  
\[\tau^{(forw)}_{k\to}=\sum_{i=k+1}^{n}\left[\tau^{(tr)}_{i}+\tau^{( trd)}_{i}+\tau^{(ld)}_{i}\right]+\tau^{(tr)}_{n+1}+\tau^{(2)}_{(OEM)} \tag{2}\]  
where \(\tau^{(forw)}_{k\to}\) is the expected cycle time from stage \(k\) up to final delivering components to the OEM production line. In fact, Equation (1) deals with real observed variable values, whereas (2) represents projected values. It is assumed that variables \(\tau^{(tr)}_{i}\), \(\tau^{(trd)}_{i}\), \(\tau^{(ld)}_{i}\), \(\tau^{(tr)}_{n+1}\) and \(\tau^{(2)}_{(OEM)}\) are statistically independent, and \(n\) is sufficiently large. Then, \(\tau^{(forw)}_{k\to}\) can be approximated by a normal distribution (due to the central limit theorem of Statistics). Thus, adding up the variances of the variables in (2), one gets \(var[\tau^{(forw)}_{k\to}]\). Let \(T=T^{(past)}_{\gets k}+\tau^{(forw)}_{k\to}\), which is the total cycle time. Let \(T^{(max)}\) be the limiting time imposed by the OEM to receive the components from the logistics operator at the assembling line. The effective available time, at stage \(k\), to accomplish the complete routing cycle, collecting components from the \(n-k\) remaining suppliers, is \(\Delta T=T^{(max)}-T^{(past)}_{\gets k}\), with \(var[\Delta T]=0\), since \(T^{(max)}\) and \(T^{(past)}_{\leftarrow k}\) are deterministic variables. Letting \(\mu=E[\tau^{(forw)}_{k\to}]\) and \(\sigma^{2}=var[\tau^{(forw)}_{k\to}]\), one has \(\tau^{(forw)}_{k\to}\sim N(\mu,\sigma^{2})\). Let \(\beta\) the probability that \(\tau^{(forw)}_{k\to}>\Delta T\), as follows:\[\beta=1-\int_{-\infty}^{\Delta T}\frac{1}{\sqrt{2\pi\sigma^{2}}}\exp\left(-\frac{(x -\mu)^{2}}{2\sigma^{2}}\right),\text{with }x=\tau_{k\to}^{(forw)} \tag{3}\]  
and let \(\epsilon\) be the acceptable upper limit for probability \(\beta\), or, in other words, the OEM company requires from the suppliers and the logistics operator that \(\beta\leq\epsilon\).