# Provision of Energy- and Wavelength-Efficient Traffic
## 3 Traffic Grooming Algorithm Design
### Traffic Aggregation and Sub-Wavelength Assignment Algorithm
In the scenario of traffic aggregation, each sub-wavelength is allowed to propose to more than one connection request so long as the minimum total energy consumption is guaranteed. Based on the defined preference relation, each connection request can decide the swap operations for different groups. To quickly obtain the matching results, each unmatched sub-wavelength \(\mathcal{U}_{i}\) proposes to an unmatched connection request \(\mathcal{S}_{n}\) to match with, which satisfies  
\[(\mathcal{S}^{*},\mathcal{U}^{*})=\arg\min_{\mathcal{S}_{n}\in\mathcal{S} \mathcal{U}_{i}\in\mathcal{U}\cup\varnothing,\mathcal{S}_{n}\cap\mathcal{U}_{i }=\varnothing}\Xi(\mathcal{S},\mathcal{U}) \tag{12}\]  
The whole matching algorithm for traffic aggregation is presented in detail as Algorithm 1. At first, connection requests are allocated to different groups according to the path affiliation. Then, the proposing and rejecting operations are performed to aggregate all theconnection requests into different sub-wavelengths. The following compare-and-swap operations ensure that each connection request is aggregated into the target sub-wavelength. The iterations will not stop until no connection request is willing to be a part of other groups anymore. ```
Input: Sets of connection requests \(\mathcal{S}\) and its corresponding paths \(L_{\mathcal{S}}\), sub-wavelengths (groups) \(\mathcal{U}\), and the matching utility function \(\Xi(\mathcal{S},\mathcal{U})\). Output: Matching pairs between connection requests and sub-wavelength. 1. Initialization
2. Allocate all connection requests initially to groups according to the path affiliation. 3. **Proposing and rejecting**
4. **while** at least one connection request is unmatched do
5. Sub-wavelength \(\mathcal{U}_{m}\) proposes to connection request \(\mathcal{S}_{n}\) according to (12). 6. if connection request \(\mathcal{S}_{n}\) is proposed by more than one sub-wavelength then. 7. Connection request \(\mathcal{S}_{n}\) selects the sub-wavelength \(\mathcal{U}_{m}\) with the minimum sum energy consumption \(\Xi(\mathcal{S},\mathcal{U})\) from the candidates and rejects other proposals. 8. else
9. Connection request \(\mathcal{S}_{n}\) is matched with the proposing sub-wavelength. 10. Connection request \(\mathcal{S}_{n}\) is removed from \(\mathcal{S}\). 11. end if
12. end while
13. Compare-and-swap operations
14.repeat
15.for connection request \(n=1\to N\), where \(\mathcal{S}_{n}\in\mathcal{S}\)
16. for group \(\mathcal{U}_{m}=\mathcal{U}_{1}\to\mathcal{U}_{M}\),where \(\mathcal{U}_{k}\cap\mathcal{U}_{l}=\varnothing\), \(1\leq k,l\leq M\)
17. Calculate the sum energy consumption for group \(\mathcal{U}_{k}\) and \(\mathcal{U}_{l}\). 18. Connection request \(\mathcal{S}_{n}\) moves from group \(\mathcal{U}_{k}\) to group \(\mathcal{U}_{l}\). 19. Calculate the sum energy consumption for the updated group \(\mathcal{U}_{k}\) and \(\mathcal{U}_{l}\), respectively. 20. Compare the change of the sum energy consumption. 21. if the sum energy consumption decreases by the swap operation
22. Connection request \(n\) stays in group \(\mathcal{U}_{l}\). 23. else connection request \(n\) moves back to \(\mathcal{U}_{k}\). 24. end if
25. end for
26. end for
27. until no connection request is willing to be a part of other groups. 28. return the sets of matching pairs. ```  
**Algorithm 1**TAASA algorithm