# Priority-Driven Resource Allocation with Reuse for Platooning in 5G Vehicular Network
## 4 System Modeling and Resource Allocation Algorithm
### Proposed Resource Allocation Algorithm
```
2:Step 2: Resource Allocation for Platoon Vehicles for each vehicle \(i\in\mathcal{P}\)do
4:for each resource block \(j\in\mathcal{R}\)do if\(j\) is unused then
6: Allocate \(j\) to requesting vehicle \(i\) else if\(j\) are used by another vehicles \(i^{(1)}...i^{(n)}\) in \(\mathcal{P}\) and they are in another platoon then
8: Platoon vehicle \(i\) send packet to next platoon vehicle \(k\)
10: Platoon vehicle \(i^{(n)}\) send packet to next platoon vehicle \(k^{(n)}\)
10: Compute SINR for platoon vehicle \(i\) with another vehicles in \(j\): \[\gamma^{(j)}_{i,k}=\frac{P_{0}\cdot I^{(j)}_{i,k}}{N_{0}+\sum_{j^{\prime}\
eq i }x_{j^{\prime}}\cdot P_{0}\cdot I^{(j)}_{i^{\prime},k}}\]  Compute SINR for platoon vehicle \(i^{(n)}\) with another vehicles in \(j\): \[\gamma^{(j)}_{i^{(n)},k^{(n)}}=\frac{P_{0}\cdot I^{(j)}_{i^{(n)},k^{(n)}}}{N_{ 0}+\sum_{j^{\prime}\
eq i^{(n)}}x_{j^{\prime}}\cdot P_{0}\cdot I^{(j)}_{i^{ \prime},k^{(n)}}}\]
12:if\(\gamma^{(j)}_{i,k}\geq\) threshold and \(\gamma^{(j)}_{i^{(n)},k^{(n)}}\geq\) threshold, \(\forall i^{(n)}\in\mathcal{P}\)then
14: Reuse \(j\) for requesting vehicle \(i\)
14:else
15: Continue to next resource block \(j\)
16:endif
17:endif
18:endfor endfor
```  
**Algorithm 2** Resource Allocation for Platoon Vehicle  
Algorithm 3 manages the resource allocation for general vehicles once the allocation process for platoon vehicles is complete. The base station searches for a resource block that can be allocated to the requesting general vehicle. If the resource is unoccupied, it is immediately allocated. If the resource is already in use by another vehicle, the base station first checks whether the resource is allocated to a platoon vehicle. If so, the base station calculates the SINR of the platoon vehicle using the resource and does not permit reuse if the SINR of the platoon vehicle falls below the threshold when the general vehicle reuses the resource. Reuse is allowed only if the SINR remains above the threshold. If the resource is in use by another general vehicle, the base station checks whether all general vehicles using the resource are separated by a distance greater than or equal to the resource reuse distance from the requesting vehicle. If this condition is met, the resource can be reused. After resource allocation is completed, the identifier of any general vehicle that failed to receive a resource, along with the number of resource allocation failures, is recorded as Score and stored. This Score is subsequently used to determine the priority of resource allocation for future requests. ```
Step 3: Resource Allocation for General Vehicles
3:for each vehicle \(i\in\mathcal{G}\)do for resource blocks \(j\in\mathcal{R}\)do if\(j\) are unusedthen
6: Allocate \(j\) to requesting \(v\) and reset \"Score\" elseif\(j\) are used by a vehicle then if\(j\) are used by a vehicles \(i^{(1)}\_i^{(n)}\) in \(\mathcal{P}\)then
9: Platoon vehicle \(i^{(n)}\) send packet to next platoon vehicle \(k^{(n)}\)  Compute SINR for platoon vehicle \(i^{(n)}\) with another vehicles in \(j\): \[\gamma^{(j)}_{i^{(n)},j^{(n)}}=\frac{P_{0}\cdot h^{(j)}_{i^{(n)},j^{(n)}}}{N_{ 0}+\sum_{j^{(n)}\in\mathcal{G}}x_{j^{(n)}}\cdot P_{0}\cdot h^{(j)}_{j^{(n)},j^{ (n)}}}\] if\(\gamma^{(j)}_{i^{(n)},j^{(n)}}\geq\text{threshold},\;\forall i^{(n)}\in \mathcal{P}\)then
12: Check whether general vehicles reuse resources else Continue to next \(j\) endif if if\(j\) are used by another vehicle \(i^{(1)}\_i^{(n)}\) in \(\mathcal{G}\)then
18: Compute distance \(d_{i,j^{(n)}}\) between vehicle \(i\) and vehicles \(i^{(1)}\_i^{(n)}\) if\(d_{i,j^{(n)}}\geq\text{reuse distance},\;\forall i^{(n)}\in \mathcal{G}\)then
19: Reuse \(j\) for the requesting \(i\) and reset \"Score\"
20:else Continue to next \(j\) endif
21:endif if endif
22:endfor if resource allocation fails for a vehicle in \(\mathcal{G}\)then  Record failure count as \"Score\" and store with vehicle ID
23:endif
```  
**Algorithm 3** Resource Allocation for General Vehicles