# Dynamic Multi-Compartment Vehicle Routing Problem for Smart Waste Collection +
## 5 Methods and Results
### Crossover Procedure  
Crossover is a genetic operator that combines two chromosomes called \"parents\" to produce a new solution called \"child\". The purpose of using crossover is that the new solution can be better than both parents can if it takes the best characteristics from each parent.  
Two parents' p1 and p2, are selected from the population. The proposed crossover takes place in two phases:The first phase randomly chooses a crossing point k for each arc (the red line in Figures 9 and 10). The crossover procedure used in this paper is eluted as follows: the first part of the first parent is copied as the first part of child 1, and then the elements of the second part of this parent are considered the second part of child 2. The first part of the second parent is copied as the first part of child 2, and then the elements of the second part of this parent are considered the second part of child 1. The two parts for each child are combined to form a new path (See Figure 9).
* After crossing, the result does not always correspond to a feasible solution. We illustrate this situation with the example in Figure 10.  
Figure 10: Example to build the second phase in the crossover procedure.  
Figure 9: Example of the first phase in the crossover procedure.  
We assume that we have four types of waste and that the trucks have four compartments.  
We assume that each truck has a capacity of 23 tons distributed as follows: The first compartment capacity is 7 tons, the second compartment capacity is 5 tons, the third compartment capacity is 6 tons, and the fourth compartment capacity is 5 tons.  
Note that the obtained result does not present a feasible solution (see Figure 10), for child 2, the sum of the quantities transported in compartments 2 and 4 is more significant than the capacities of the corresponding compartment. Therefore, we have to make some adjustments, so the second phase is testing the feasibility of these new chromosomes using the heuristic illustrated in the following algorithm for child 1 (the same algorithm is applied to modify child 2):  
```
For each vehicle \(\mathbf{v}\) For each station \(\mathbf{j}\) in the path of child 1 For each waste type \(\mathbf{w}\) in the station \(\mathbf{j}\) \(\mathbf{w}=\mathbf{p}\)  While \((\mathbf{w}<~{}\mathbf{in}~{})\) If \((\mathbf{q}_{\mathbf{wi}}+\ldots+\mathbf{q}_{\mathbf{wi}^{\prime}+\mathbf{i}^{\prime}}+\ldots+ \mathbf{q}_{\mathbf{w}^{\prime}+\mathbf{m}^{\prime}}\leq~{}\mathbf{C}\mathbf{q}_{\mathbf{w}})\)  Collected all waste type \(\mathbf{w}\) (if \(\mathbf{b}_{\mathbf{w}\mathbf{j}}=\mathbf{q}_{\mathbf{w}\mathbf{j}}\)) in the corresponding compartment of vehicle \(\mathbf{v}\) for child \(\mathbf{1}\) Else Repeat For \((j\)=\mathbf{i}^{\prime}+\mathbf{j}^{\prime}\ldots\ \ \mathbf{i}^{\prime}+\mathbf{m}^{\prime})\)  Calculate \((\mathbf{q}_{\mathbf{wi}}+\ldots+\mathbf{q}_{\mathbf{w}\mathbf{j}})\) If \((\mathbf{q}_{\mathbf{wi}}+\ldots+\mathbf{q}_{\mathbf{w}\mathbf{j}}>\mathbf{C}\mathbf{q}_{\mathbf{w}})\)  Replace \(\mathbf{q}_{\mathbf{w}\mathbf{j}}\) by 0 for child 1 Else Collected the waste type \(\mathbf{w}\) in the station \(\mathbf{j}\) in the corresponding compartment of vehicle \(\mathbf{v}\) for child 1, and calculate \(\mathbf{q}_{\mathbf{wi}}\)\(\ldots+\mathbf{q}_{\mathbf{w}\mathbf{j}}+\mathbf{q}_{\mathbf{w}\mathbf{j}+1}\) \(j\gets j+1\) get back to 11 End If End For  End If  While \((j=i^{\prime}+\mathbf{m}^{\prime})\)  End While \(p=p+1\) End While End For End For
```  
**Algorithm 2**Modification of the crossover operator.