# Dynamic Multi-Compartment Vehicle Routing Problem for Smart Waste Collection +
## 5 Methods and Results
### Genetic Algorithm for Solving the DM-CVRP
#### 5.2.2 Solving Phase  
A GA strategy is executed for each static VRP created as described above. Each chromosome in a population represents a possible solution to a static VRP. Encoding the Solutions  
For each time slice \(t_{l}\), each solution is composed of routes for vehicles and collection bins. The following table represents the solution for a vehicle \(v\). In the example illustrated in Table 3. Route 1 is served by vehicle 1, which visits the ordered list from station 2, starting with \(0^{\circ}_{l}\) (\(0^{\circ}_{l}\) is the last station operated by vehicle \(v\) at time slice \(t_{l-1}\)), until the last station 1 before visiting the transfer station to unload the collected quantities, and then returns to the depot. Vehicle 1 collects types 1 and 3 in station 2; it collects types 2, 3, and 4 at station 5, and it collects types 1 and 4 at station 1. Figure 8: The steps of our genetic algorithm. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \(Types\)\(Stations\) & \(\mathbf{0^{1}_{1}}\) & \(\mathbf{2}\) & \(\mathbf{5}\) & \(\mathbf{1}\) & \(\mathbf{0}\) \\ \hline \(T_{1}\) & / & \(q_{21}\) & \(0\) & \(q_{11}\) & / \\ \hline \(T_{2}\) & / & \(0\) & \(q_{52}\) & \(0\) & / \\ \hline \(T_{3}\) & / & \(q_{23}\) & \(q_{53}\) & \(0\) & / \\ \hline \(Types\)\(T_{4}\) & / & \(0\) & \(q_{54}\) & \(q_{14}\) & / \\ \hline \(T_{1}\) & / & \(0\) & \(q_{31}\) & \(0\) & \(q_{41}\) & / \\ \hline \(T_{2}\) & / & \(q_{82}\) & \(q_{32}\) & \(0\) & \(q_{42}\) & / \\ \hline \(T_{3}\) & / & \(q_{83}\) & \(0\) & \(0\) & \(0\) & / \\ \hline \(T_{4}\) & / & \(q_{84}\) & \(q_{34}\) & \(q_{11,4}\) & \(0\) & / \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Example of a solution of 3 vehicles with 11 stations and 4 types. Initial Population  
A routing solution based on a list of integer numbers, where 1 to \(n\) represent stations, \(n+1\) represents the transfer station, and 0 represents the depot. The heuristic constructs the routing of available vehicles beginning with the first one by inserting the request's origin and destination in its trajectory to find a suitable solution for DM-CVRP. If the compartment capacity of the vehicle is reached, we move on to the second vehicle, up to all the stations that have been served. This heuristic is divided into two steps, the first step is for the first time slice, and the second step is for the other time slices:  
**The initial population of the first time slice:**  
The working day begins with the first time slice \(N_{t_{1}}\) that indicates that depot 0 is inserted, and every time, if a station respects the capacity constraint must be inserted in the route (remaining vehicle capacities for the types triggering the alarm) until all the stations in the \(N_{t_{1}}\) list have been affected. If the vehicle compartment capacity is reached for all waste types, the vehicle visits the transfer station and then returns to the depot. If the vehicle capacity constraint is not respected for any remaining station in the \(N_{t_{1}}\) list, the current vehicle will move to the transfer station, then to the depot. The algorithm marks the last station visited, and this station is considered a depot for the next time slice \(N_{t_{2}}\). This heuristic is based on the following algorithm:  
**The initial population of the other time slices:**  
The second step of the heuristic create the initial solutions for the time intervals \(l=2,\ldots,b\). The same process as the first step is used to generate the initial solutions in the time slices \(l=2,\ldots,b\), except that the list of stations considers already programmed stations in the current time slice and the new stations triggering the alarm in the previous time slice. A station can be visited more than once in the same working day because each time a type in a station triggers the alarm, this station will enter the list of stations to be visited in the next time slice.