## 1 Introduction
### Contributions  
Noting that D2D TX-RX pairs (TRs), RSs, the first hop spectrum and the second hop spectrum should be matched effectively, thus, in our paper, we solve the mixed integer nonlinear programming problem using matching theory [28], which considers two side preferences in a traditional form and provides a low-complexity solution. However, the proposed joint optimization involves four dimension variables that cannot be solved by a traditional matching algorithm. Therefore, we first decompose the problem into a two-dimensional matching and a three-dimensional matching with a low dimension reduction error and then solve the two matching problems based on a pricing mechanism. The power control process is coupled with the three-dimensional matching, and the optimal transmit power maximizes the total EE of the two-hop link. The auction algorithm has been used in some previous works to solve the resource allocation problems under the D2D scenario [29; 30]. In [29], the authors proposed a two-phase auction-based resource allocation algorithm for underlying D2D communication. Additionally, in [30], the authors proposed a two-step distributed algorithm of channel allocation and mode selection for mobile stations with the objective of capacity maximization. Compared to these works, we consider a much more complicated problem with multidimensional variables that cannot be solved by the above-mentioned auction algorithm, which includes only two dimension variables, i.e., bidders and bidding items. The similarity is just that we use the pricing strategy when the conflicts appear in the matching algorithm, and we employ the idea of price rising in an auction. **Remark 1**. : _The [PERSON] auction algorithm and Munkres' Hungarian algorithms are not considered in this work. However, the joint optimization involved in this work is a high complexity problem with multidimensional variables, which cannot be solved directly by a traditional matching algorithm or auction algorithm. Therefore, we decompose the original problem into a two-dimensional matching and a three-dimensional matching with a low dimension reduction error and then solve the two matching problems based on a pricing mechanism. Although the employed pricing-based matching algorithm is similar to the auction algorithm, to solve the joint optimization problem, both of them should be modified in the same way, which is the focus of this work. The innovation of this work is not only the proposed pricing-based matching algorithm, but also the idea of problem simplification._  
The main contributions of this paper are summarized as follows:  
* We design a two-hop D2D relay strategy for the transmitter-receiver pair with an inferior direct link to improve system performance. Specifically, we propose a joint relay selection, power optimization and spectrum allocation problem, which involves the matching between D2D TRs and relay stations and the matching between two-hop D2D links and the respective spectrum resources and can be formulated as four-dimensional matching to maximize the EE of D2D UEs. * The joint relay selection and resource allocation problem is intractable and belongs to the class of NP-hard problems; thus, we simplify the problem into one two-dimensional matching between D2D TRs and the second hop spectrum resources and one three-dimensional matching among D2D TRs, relays and the first hop spectrum resources. By solving these two matching problems, we can achieve a sub-optimal solution, which can approach the performance of the exhaustive optimal algorithm with a much lower complexity. The two-dimensional matching problem is solved by using a pricing strategy directly, which decides the winner when more than one D2D TRs propose the same spectrum resource for the second hop. For the three-dimensional matching, we transform it into a two-sided matching, in which the preference lists of D2D TRs from one side over the combinations of RSs and spectrums for the first hop from the other side are established based on the achievable maximum EE.