Novel Relay Selection Algorithms for Machine-to-Machine Communications With Static RF Interfaces Setting

Machine-to-Machine (M2M) communications play a significant role in the Internet of Things (IoT). Cooperation of machines in M2M communications can improve network performance when the quality of connections between sources and their destinations is poor. Careful selection of machines as relays can play an effective role in improving the quality of communication in dense networks. Furthermore, the possibility of simultaneous use of different Radio Frequency (RF) interfaces can increase the capacity of data transmission over the network. In this paper, two novel M2M relay selection algorithms are proposed namely Optimal Relay Selection Algorithm (ORSA) and Matching based Relay Selection Algorithm (MRSA). ORSA is a centralized algorithm that transforms the relay selection problem to a k-cardinality assignment problem that can be solved using the Hungarian algorithm. MRSA is a decentralized algorithm that leverages concepts from matching theory to provide a stable relay assignment. In both proposed algorithms, static RF interfaces setting is applied to enable the simultaneous use of different interfaces. It is shown that ORSA results are optimal and MRSA results are stable. The simulations compare the capacity of data transmission of proposed and baseline algorithms. The results show that when the number of channels is not restricted, MRSA is only about 3% lower than ORSA and its results are higher than direct transmission and random relay selection, about 56% and 117%, respectively.


I. INTRODUCTION
Machine-to-Machine (M2M) communications is a notable part of the Internet of Things (IoT) [1]. In this kind of communication, machines can communicate with each other, without or with minimal human intervention. Cooperation between machines will improve the data rate and the bandwidth efficiency of wireless networks such as Long-Term Evolution-Advanced (LTE-A) cellular networks [1]- [3].
In the cooperation of machines, some machines can act as relays between other machines. Especially when the direct link between a source and its destination (e.g. the base station) is weak, relays may save transmission power [4] and increase network coverage and performance [3]- [7]. Appropriate assignment of relays to machines is a challenge for The associate editor coordinating the review of this manuscript and approving it for publication was Muhammad Imran . dense network communications, which is referred to as relay selection problem in this paper. This assignment of relays depends on various network condition parameters, such as Signal-to-Noise Ratio (SNR) which increases the complexity of this problem.
Some studies have used game theory and matching theory to solve relay selection problems in different networks [7]- [10]. Matching theory can provide an appropriate framework for analysis and designing the decentralized methods for interactions between the rational and selfish players [11]. There are some studies that have applied matching theory to model the relay selection problem [12], [13]. Some works have modeled the relay selection problem as a maximum weighted matching problem in bipartite weighted graphs and the Hungarian algorithm has been applied in the relay selection process, as a solution [12], [14]- [20]. VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ In M2M communications, machines can be equipped with different radio frequency (RF) interfaces, such as Long Term Evolution (LTE), Bluetooth, Wireless Fidelity (WiFi), or multiple of them simultaneously. Machines can use their RF interfaces to support the different Quality of Services (QoS) and different requirements of the users [1]. The simultaneous use of different RF interfaces to transmit data from a machine to other machines or base station can increase M2M communications average throghput in a very dense network [21], [22]. The authors are not aware of any relay selection algorithms for M2M communications which considered the possibility of machines using multiple RF interfaces simultaneously.
This simultaneous RF interfaces setting can be static or dynamic. For example, M2M communications can use WiFi interface to transmit data among machines and they can use LTE interface for machine to base station communications, statically. In another case, machines may use WiFi, Bluetooth or ZigBee interfaces to transmit data among machines, dynamically.
For instance, a smart city can be considered. In this city, there are several uses for sending data by machines. In some of these applications, fixed machines send their data at different times using RF interfaces such as LTE or WiFi. As an example, smart urban lighting systems can be mentioned as an application in the smart city. These systems are turned on and off only at certain hours of the day and night. Therefore, these systems usually do not require data exchange at other times.
Security systems such as anti-theft systems or fire alarms in the city also need to send data to a security center such as the fire department or the police. In this case, the machines are idle most of the time and at certain times need to transmit data quickly to the base stations. At the time of data transmission, due to channel conditions, the direct connection of each source with the base station may not be appropriate. In this case, other devices in the smart city that are not currently sending data can be utilized as relays. In this manner, the sources send their data to the base station through the relays and appropriate relay selection will improve the network transmission quality.

A. RELATED WORKS
Relay selection may be useful in order to forward data to the base station to deliver to its destination. The network condition parameters, such as SNR or Signal-to-Interferenceplus-Noise-Ratio (SINR), can be involved in selecting the appropriate relay [3], [23]. This relay selection can be very important, especially when the direct link between a source and its destination (e.g. the base station) is weak [7], the network coverage needs to be extended [6], [24], and the transmission power should be reducesd for increasing life time of the machine [25], [26]. Thus use of relays can increase network throughput [24]. In this subsection, some of the previous related works are summarized.
Recently, a relay selection algorithm based on the Basic Sequential Algorithmic Scheme (BSAS) is proposed for high density LTE networks [27]. Two layers of users are considered, in this work. The first layer users are directly connected to the base station and the second layer users use one of the first layer users as a relay to connect the base station. In this algorithm, the users form clusters and each cluster has a cluster head from the first layer nodes. These cluster heads transmit data of all other users in its cluster. The proposed algorithm improves the system capacity and energy consumption compared to other similar work [27].
Another paper provided two new approaches to modify the buffer-aided relay selection algorithms in equal maximum weight link conditions [28]. The authors proposed two metrics to use for this condition in each of the new approaches. The first parameter is used in one of the approaches is SNR. The results show that involving this parameter in relay selection improves the outage probability. The other parameter is prioritizing links between relays and destinations based on the occupied buffer space. Involving this parameter in the second approach can improve the delay and throughput performances [28].
In the other work, two relay selection schemes based on two different parameters, Signal-to-Interference Ratio (SIR) or location,for Machine-Type Communication (MTC) are proposed [29]. In this paper, gateways, as relays, receive MTC devices data and transmit it to the base station. In the relay selection based on SIR, gateways attempt to receive data from MTC transmitters that have the highest received power. The possibility of simultaneous data transmission by multiple MTC transmitters in this schema can lead to high interference and reduces the probability of successful data decoding. Furthermore, the data of each MTC transmitter may be received by the base station through multiple gateways. The relay selection based on location modifies the SIR based scheme, by assigning the nearest MTC transmitter to each gateway and farther MTC transmitters blocked by this gateway. Thus despite the cost of sending spatial data by MTC transmitters, the received interference by each gateway is reduced and the duplicate MTC data transmission to the base station is avoided [29].

1) HUNGARIAN BASED RELAY SELECTION
The Hungarian algorithm is a solution for the maximum weighted matching problem in bipartite weighted graph [17]. Following, a review of Hungarian algorithm based relay selection schemes are mentioned: A relay selection algorithm has been proposed with subchannel reusing in the Device-to-Device (D2D) communications [19]. In this algorithm, a graph coloring algorithm is applied to arrange the D2D peers into nonconflicting groups that have minimum intergroup interference. Then a matrix of D2D peers power consumption is constructed, and relay selection of D2D peers is formulated as a weighted bipartite graph matching problem. In the next phase, this problem is solved by the Hungarian algorithm [19].
A study has been conducted on the effectiveness of relay selection in 3GPP Narrowband networks in Internet of Things 189990 VOLUME 8, 2020 (NB-IoT) [18]. To increase the chance of successful transmission, NB-IoT adopts a repetition-based transmission. To reduce the number of repetitions, relay selection can be utilized. In this work, relay selection is modeled as a weighted bipartite matching problem and a solution is obtained using the Hungarian algorithm [18].
The assignment problem and relay selection for the relay-aided D2D communications underlying cellular networks has been studied. It is known that this problem is NPcomplete, therefore researchers have proposed an Iterative Hungarian Method (IHM) to obtain a near-optimal solution for this problem [16].
A joint relay selection and resource allocation algorithm is investigated in cognitive networks [14]. In their study, these problems are modeled by bipartite weighted matching in two stages and are solved with the Hungarian algorithm [14].

2) MATCHING THEORY BASED RELAY SELECTION
Matching theory can provide an appropriate framework for analysis and designing the distributed methods for interactions between rational and selfish players [11]. Here, some papers that used from the matching theory in relay selection are summarized.
Jointly optimizing resource management, relay selection, spectrum allocation, and power control is an NP-hard problem [8]. A pricing-based two-stage matching algorithm is provided to maximize energy efficiency. Firstly, a twodimensional matching is modeled for the spectrum resources reused by relay-to-receiver links. Then, matching users, relays, optimal power control and the spectrum resources reused by transmitter-to-relay links are conducted by a three-dimensional matching [8].
A distributed satisfaction-aware relay assignment based on the many-to-one matching-game theory is provided [9]. In this work, sources request to relays, with limited resources, regarding their dynamic throughput requirements. Finally, the satisfaction and fairness of sources have been improved [9].
A distributed matching algorithm to select suitable relays among secondary users for primary users is proposed [7]. The secondary users negotiate with the primary users on the time of both cooperatively relaying the primary users data and allowed spectrum access [7].

B. MAIN CONTRIBUTIONS
In this paper, two relay selection algorithms are introduced for M2M communications with static RF interfaces setting. In summary, this paper makes the following contributions: -A new solver for the kAP is provided by converting it to a standard assignment problem and this new problem is solved by the Hungarian algorithm. The proof of optimality of this solver is provided in Subsection III-A3. -A novel centralized Optimal Relay Selection Algorithm (ORSA) is proposed to provide the optimal solution for the relay selection problem in Section III-B. The presented method converts the M2M relay selection problem to a k-cardinality assignment problem (kAP). -A novel decentralized Matching based Relay Selection Algorithm (MRSA) is proposed that is developed by using matching theory. In this algorithm, all nodes (machines and base station) only need local information. The result of this algorithm provides a stable matching between sources, relays, and the base station, based on the deferred acceptance procedure [30]. The proof of stability of this algorithm is introduced in Appendix A. MRSA provides results comparable to the optimal solution and it is applicable in practical situations. -In both of novel relay selection algorithms for M2M communications, the static parallel usage of different RF interfaces is considered. This static RF interfaces setting can enable simultaneous transmission among machines and machines with the base station. The rest of this article is organized as follows. The system model is described in section II. Then, the proposed centralized relay selection algorithm and the proposed decentralized relay selection algorithm are presented in sections III and IV, respectively. The simulation results are illustrated in section V. Finally, in section VI, the conclusion of this paper is provided.

II. SYSTEM MODEL
We consider a cell with one base station in the center of the cell, and N machines each equipped with two different RF interfaces. In this model, we consider only the uplink paths. The machines have fixed positions, and are divided to two sets, active machines (sources) and idle machines (relays). We denote active machines set as M a that includes N s = |M a | sources and each source wants to send data to the base station to deliver its message to its destination.
Moreover, the channel between the sources and the base station may have low communication quality, due to path loss, fading and shadowing. We denote the set of idle machines by M i , which contains N r = |M i | relays. In other words, M Total is considered as a set of machines, such that According to what was mentioned, N = N s + N r . It is assumed machines would cooperate with each other. The idle machines do not have data to send at that period of time, thus they can work as a relay. Therefore, when active machines need help, the idle machines can assist them as relays to increase data-rate. Unlike some works where one source can be connected to several relays at the same time [31], in our model, each source can not be connected to more than one relay.
The relays are using the Decode-and-Forward (DF) protocol. Fig. 1 shows the scheme of active and idle machines in the system model. These machines are randomly positioned with a uniform distribution.
The communication capacity or the maximum bit rate that can be used according to the link conditions between two nodes, i and j, in the network is denoted by C i,j , that according to the Shannon-Hartley equation, will be as: where B t is the bandwidth of the communication channel with technology t used by two nodes i and j and SINR i,j is the SINR of the channel with ith node as the transmitter and jth node as the receiver. The possibility of using different RF interfaces of the machines can help to provide high data rates. Therefore, for the static RF interfaces setting, we consider a WiFi interface for their M2M communication and an LTE interface for their direct communication with the base station. The frequency bands used by the LTE and WiFi interfaces are considered different from each other.
For the WiFi and LTE technologies, the achieved SINR of two nodes i and j is computed by the equations (2) and (3), respectively, which are described as: and where P WiFi i and P LTE i are transmission powers of ith node for the WiFi and LTE interfaces, respectively, σ 2 is noise power and h (i,j) is the gain of the channel between the ith and jth nodes. h (i,j) is modeled by considering path loss, shadowing, and small scale fading. In more exact terms, the following formulation is used: where path loss is modeled with path loss exponent β = 4 (equation 5). Shadowing (dB)is modeled by a Normal random variable with zero mean and standard deviation of 8 (N (0, 64)). Small scale fading (dB) is modeled by a Rayleigh random variable with scale parameter of σ r = 1.
where d 0 = 10(m), and d (i,j) is the euclidean distance between node i and node j.
The interference experienced at a relay receiver when communicating with a source on the WiFi interface is calculated based on the total power originated from other sources with WiFi interfaces. However, since the WiFi and LTE frequencies are different, the connection between the sources and the relays does not interfere with the connection of the machines (sources or relays) with the base station. Thus the interference of LTE transmitters at the base station will be zero. It should be mention, to simplify our simulations, we consider maximum probable interference on both RF interfaces, WiFi and LTE. We have simulated the worst possible interference conditions, so it can be expected the results of the real world scenarios would be better than our simulation results.
In this model, any source can select a direct path to the base station or a relay for two hop data forwarding to the base station, by using the matching algorithm. The relays receive the source data on the WiFi interface and send it to the base station on the LTE interface in a time slot. The capacity of the channel between a source and a base station in two hops based on DF relaying is given by [12], [32]: where C s,r is the communication capacity between the source and the relay and C r,d is capacity between the relay and the base station.

A. PROBLEM FORMULATION
In this paper, we propose an algorithm to assign link of the sources to their next hop, which can be either a relay or the base station. Some works have considered their selection criteria locally [23], for example based on the choice of the neighbor with the best channel conditions. But we seek to globally maximize the total connection capacity of the sources within the network. We formulated the problem of link assignment in equation (7). In the following, we presented two solutions for this problem: -an optimal relay selection that provides the highest capacity for all network sources, -A stable relay selection algorithm that provides a selection which is at least as well as the other possible stable selections for each network source.

Max
x,y,z Subject to 189992 VOLUME 8, 2020 The definition of the used variables is as follows: x i,j : is 1 if ith source has selected the jth relay and 0 otherwise, y j,k : is 1 if jth relay has selected the kth base station and 0 otherwise, z i,k : is 1 if ith source has selected the kth base station and 0 otherwise, c i,j : the capacity between ith source and jth relay, c i,k : the capacity between ith source and kth base station, c j,k : the capacity between jth relay and kth base station, -N s : the number of sources, -N r : the number of relays, -Q BS : quota or connection capacity of the base station.
This is equivalent to the number of LTE channels in the simulation scenarios. -The first summation in inequality (11) represents the constraint that each relay can only be assigned to a single source. -The second summation in inequality (11) represents the constraint that each relay can only be connected to a single base station. Although this constraint is written in a general form, however we have considered only one base station in our model. -The first summation in inequality (12) represents the constraint that each source can only be connected to a single relay. -The second summation in inequality (12) represents the constraint that each source can only be connected to a single base station. Although this constraint is written in a general form, however we have considered only one base station in our model. -The total number of two hop connections of sources to base station through relays (the first summation in inequality (13)) and total number of direct connections of sources to the base station (the second summation in inequality (13)) is less than or equal to the total number of available channels for connection to the base station (Q B S). Fig. 2 shows the scheme of the graph model of our relay selection problem.

III. PROPOSED CENTRALIZED RELAY SELECTION ALGORITHM
In this section, we propose a new solver for the k-cardinality assignment problem that finds k maximum weighted matching in a bipartite graph. The k-cardinality assignment problem can be solved by a polynomial solver [33]. Some papers proposed solutions [34], [35], but we provide a new simple approach for solving it. In the following, we first describe the proposed solver of the k-cardinality assignment problem and then explain the details of the proposed centralized optimal relay selection algorithm. In Subsubsection III-A3, we prove that the proposed k-cardinality assignment solver obtains a mathematically optimal solution for the k-cardinality assignment problem.
Then, we use this solver to introduce a centralized relay selection algorithm to solve the problem formulated by equation (7). For this purpose, we transform the relay selection problem to a k-cardinality assignment problem and solve the problem using the proposed k-cardinality assignment solver. In Section III-B, we show that the proposed relay selection algorithm provides an optimal solution for the relay selection problem.

A. A NEW SOLUTION FOR THE k-CARDINALITY ASSIGNMENT PROBLEM
In this section, we provide a solution for the k-cardinality assignment problem, which is a generalization of the standard assignment problem [35]. The k-cardinality assignment problem is defined as finding the maximum weight matching among all matchings with at most k edges in a bipartite graph.
The Hungarian algorithm is a common solution for the standard assignment problem [36], but it can not solve a k-cardinality assignment problem. Therefore, we transform the k-cardinality assignment problem to a standard assignment problem that would be solved by the Hungarian algorithm [37]. The complexity of the algorithm is O(N 3 ) where N is the number of vertices of the standard assignment problem [36], [38].
Our model is a bipartite weighted graph . We want to select k edges (k ≤ min{m, n}) so that sum of the weights of selected edges is maximized. If k = n or k = m, the new problem will be equivalent to the standard assignment problem without any constraint on the number of selected edges [34], [35]. The scheme of the bipartite graph model of the k-cardinality assignment problem is shown in Fig. 3.

1) STEP 1: TRANSFORMING THE k-CARDINALITY ASSIGNMENT PROBLEM TO A STANDARD ASSIGNMENT PROBLEM
In the first step, we want to transform the assignment problem with the constraint on the number of edges to a standard assignment problem. In the standard assignment problem, we are looking for a set of edges in the bipartite weighted graph with the maximum total weight. Now, we are going to transform the restricted problem into an unconstrained one, so that the results coming from both problems would be corresponding to each other.
For this purpose, we add some additional vertices to each side. The number of vertices that are added to each side is equal to the difference between the size of another side, m or n, and constrained number of edges, k. In other words, we add The weight of edges connected to new vertices with other new vertices on the other side is set to 0 and the weight of other added edges is set to a large enough value (A value ) such as 1 + e∈E w e or infinity. Intuitively, adding new vertices and their edges by this method causes the lower weight initial edges to be defeated by A value -weighted edges. In Lemma 1 proved that exactly ((m−k)+(n−k)) edges with A value -weight are selected, therefore, only k initial edges with maximum total weight can be selected in the optimal assignment. Now, we can find maximum weighted matching in the new bipartite graph by the Hungarian algorithm. Fig. 4 shows the transformation of a k-cardinality assignment problem to a standard assignment problem.

2) STEP 2: OBTAINING FINAL RESULTS OF THE TRANSFORMED ASSIGNMENT PROBLEM
The output of the Hungarian algorithm is a vector with m + n − k size. Every component of this vector represents a vertex of the V side. The value of any component contains the index of a vertex from the U side. Therefore, it is enough to separate the n first components of the output vector that represent the initial vertices and check their content. If the value of the component is less than m, it indicates an edge between a vertex of the V side that is represented by the component index and a vertex of the U side that is represented by the component value. Otherwise, if the value of the component is greater than or equal to m, it means that this vertex does not have any edge in the original problem. In this way, we can obtain the solution of the k-cardinality assignment problem from the solution of the transformed standard assignment problem. The proof of correctness of the new method for solving the k-cardinality assignment problem will be shown in the Theorem 1.

3) PROOF OF OPTIMALITY OF THE PROPOSED k-CARDINALITY ASSIGNMENT SOLVER
The mathematical formulation of finding a maximum matching with k-cardinality (k edges) in a weighted bipartite graph, is expressed in Equation (14) as: where S se is the set of selected edges of the original problem. The purpose of the discussion in this subsection is to prove that the method presented in Section III-A provides an optimal solution for equation (14).
The transformation from equation (14) to equation (15) can be summarized as adding new vertices with 0-weighted and A value -weighted edges to each side. It is proved that the optimal solutions of the transformed equation (15) are in one-to-one correspondence with the optimal solutions of the original equation (14). The transformed equation is expressed as: where n A s is the number of selected A value -weighted edges and S se is the set of selected edges of the transformed problem. Lemma 1: For maximization of the equation (15), the number of selected A value -weighted edges, or n A s , is a constant value and n A s = (m − k) + (n − k).
Proof: It is demonstrated by contradiction.
Step 1-We assume n A s < (m − k) + (n − k) and the summation of edge weights is equal to w sum . Therefore, at least  (14) and (16).
one of the new vertices does not connect to the initial vertices with a A value -weighted edge. Accordingly, for maximization of equation (15), we can replace at least an A value -weighted edge with the lowest weight edge (w min ). Hence, the new summation of edge weights (w sum new ) is greater than or equal to This number of A value -weighted edges contradicts the initial assumption. Therefore, n A s ≮ (m − k) + (n − k). Step Hence, it can be concluded that the number of A valueweighted edges is equal to Now, we rewrite the equation (15) as below: where n * A s = (n − k) + (m − k) is the number of selected A value -weighted edges for optimization of the equation (15), S se is the set of selected edges of the transformed problem and E A is the set of A value -weighted edges.
Theorem 1: Each optimal solution for the k-cardinality assignment problem corresponds to an optimal solution for the transformed standard assignment problem and vice versa.
Proof: We denote the set of optimal solutions of equation (14) as S and the set of optimal solutions of equation (16) as S * . Each solution has up to m + n − k edges. According to Lemma 1, the number of A value -weighted edges is equal to n * A s = (n − k) + (m − k) in optimal solutions. Hence, the number of edges other than A value -weighted edges is equal to k. Therefore, -To construct the corresponding item of S from an item of S * , it is enough to remove all the n * A s edges with A valueweight and the k remaining obtained edges are the S solution, and -To construct the corresponding item of S * from an item of S, it is enough that n * A S edges with A valueweight from the unassigned initial vertices are connected to the new vertices. Hence, the obtained edges are the S * solution, and the number of them is equal to m + n − k.  In this section, an optimal relay selection problem is solved. Thus we transform this problem in two steps to become a kAP. In the following, the optimal relay selection problem-solving process is described.
The configuration of our relay selection problem is shown in Fig. 2. As it can be seen in this figure, we have two sets of machines, the sources and the relays. The sources should be connected to the base station directly or by using a relay.
In the assignment, between the sources and relays through the original problem, each source can connect to only one relay and each relay can connect to only one source. Besides, the base station has Q BS channels for communication with the machines, whether a source or a relay. The conditions of the channels are considered similar. On the other words, each source or relay can connect to only one of the channels of the base station, and the base station can connect to up to Q BS machines. Therefore, in the final assignment, the total number of edges connected to the base station can be equal to Q BS .

1) STEP 1: TRANSFORM OUR OPTIMAL RELAY SELECTION PROBLEM TO A k-CARDINALITY ASSIGNMENT PROBLEM
In this step, the transformations of the relay selection problem (Fig. 2 ) to a bipartite graph model (Fig. 6 ) is presented. To model the relay selection problem as a bipartite graph, we consider N s vertices on the left side of the bipartite graph, where each vertex corresponds to a source of the network. On the right side of the bipartite graph, we consider N r + Q BS vertices where the first N r vertices each correspond to one of the relays and the second Q BS vertices each correspond to one of the Q BS channels of the base station.
The bipartite graph model of the relay selection problem is shown in Fig. 6. In this modeling, an edge from the ith vertex of the left side to one the top N r vertices of the right side, represents a connection from the i 1 th source to a relay, and a connection from that relay to the base station. Furthermore an edge from the i 2 th vertex of the left side to one of the Q BS vertices represents a direct connection from the i 2 th source to the base station without any relay.
The weight of the edge between two vertices on both sides of the graph is defined as follows: -the weight of the edge between a source and a relay is equal to the capacity of two hops path, that is minimum of the capacity of the source and the relay link and the capacity of the relay and the base station link, and -the weight of the edge between a source and each channel of the base station is equal to the capacity of the source and the base station link.
As mentioned, the original problem had the constraint of having at most Q BS connections from the machines to the base station. This constraint is modeled by the selection of at most Q BS edges in the bipartite graph assignment problem. VOLUME 8, 2020 From the modeling presented here, it is clear that the relay selection problem is equivalent to solving the k-cardinality assignment problem on this bipartite graph, with k = Q BS .

2) STEP 2: TRANSFORM OUR k-CARDINALITY ASSIGNMENT PROBLEM TO A STANDARD ASSIGNMENT PROBLEM WITHOUT EDGE NUMBER CONSTRAINT
We want to find Q BS edges that maximize their total weight in the new problem. The current problem is similar to the problem mentioned in Section III-A1. Therefore, it can be solved in the same way.
As stated in Section III-A1, we add new vertices to both sides, N r + Q BS − Q BS new vertices to the left side and N s −Q BS new vertices to the right side. Now, N s +N r vertices exist in both sides, and the new problem is a standard assignment problem that can be solved by a common solution such as the Hungarian algorithm. Fig. 7 shows the transformed bipartite graph model of the relay selection problem with the additional nodes.

3) STEP 3: OBTAINING FINAL RELAY SELECTION FROM SOLVED ASSIGNMENT PROBLEM
After the two-step transformation, it is necessary to derive the solution of the initial problem from the obtained solution. Similar to Section III-A2, we have to extract the corresponding edges of the main problem from the set of output edges of the Hungarian algorithm. When the Hungarian algorithm is applied to the transformed problem, if it has a solution, its result will be a vector with N s + N r components. The content of the ith component represents the index of the vertex of the right side (j), that is assigned to ith vertex of the left side by the Hungarian algorithm. But as mentioned earlier, in Section III-A2, the first N s elements of the result vector are related to the main problem.
The first situation indicates that the ith source connects to the base station with two hops by the jth relay. The second situation indicates that the ith source connects to the base station directly. Finally, the last situation indicates that the ith source can not connect to any next hop of the network.

4) CENTRALIZED ALGORITHM IMPLEMENTATION
This section describes how to implement the transformation of our optimal relay selection problem to a standard assignment problem. We construct a capacity matrix in two steps. To achieve this goal, in the first step, the first part of the matrix is filled by the link capacity of the sources and the relays and each of the base station channels. Hence, we have a capacity matrix of the new kAP denoted by M . Then, to transform our kAP to a standard assignment problem, the rest of the matrix cells are filled by A value , that For example, A value can be equal to (max(M i,j ) + 1) × (N s + N r + Q BS ). Now, to find the optimal assignment, the provided capacity matrix is given to an assignment problem solver such as the Hungarian algorithm. The Hungarian algorithm can be implemented in two different versions, one of which is used by default to find the maximum weighted matching and the other to find the minimum weighted matching. Therefore, if the Hungarian algorithm is implemented to find the maximum weighted matching, the capacity matrix and the number of vertices on each side are given as its inputs. Otherwise, If the Hungarian algorithm is implemented to find the minimum weighted matching, the negative matrix capacity and the number of vertices on each side are given as its inputs.
Finally, the desired output can be obtained from the output of the Hungarian algorithm using the method described in Section III-B3. The pseudo code of our proposed centralized matching relay selection algorithm is presented in Algorithm 1.

5) COMPLEXITY OF ORSA
ORSA is a centralized algorithm. So a central node should apply the proposed centralized relay selection algorithm. In this algorithm, we transform the relay selection problem to a standard assignment problem in two steps. Complexity of the transformation steps (Step 1 and item 1 to 4 of Step 2) is O((N s + N r ) 2 ). But complexity of solving the standard assignment problem using the Hungarian algorithm is [38]. Also Step 3 of Algorithm 1 has complexity of O(N s + N r ). Therefore, the total complexity of ORSA is O((N s + N r ) 3 ). If the number of relays (N r ) is constant and the number of sources is equal to N s = n, the complexity of ORSA is O(n 3 ).

IV. PROPOSED DECENTRALIZED RELAY SELECTION ALGORITHM
In this section, we propose a decentralized algorithm for relay selection based on matching theory to select a stable selection. First, we describe the matching theory elements, the proposed algorithm players and their preference lists. Then, the matching algorithm is presented to find a stable solution for the equation (7). The proof of stability of matching of MRSA is presented in Appendix A.

A. MATCHING THEORY
Matching theory is a framework to model interaction between the rational and selfish players. We are mapping our problem to a matching theory problem. Some elements of our matching problem are mentioned below.

1) THE PLAYERS
In our proposed algorithm, there are two types of players defined as follows: • Machines consist of sources and relays, • Base station. In other words, each machine or the base station in matching algorithm are the rational and selfish players that they want to maximize their communication capacity.

Algorithm 1 Proposed Centralized Optimum Relay Selection Algorithm
Step 1: Transform our optimal relay selection problem to a kAP 1: Construct the first part of the input capacity matrix of the standard assignment problem, M i,j , according to the following rules: Step 2: Transform our kAP to a standard assignment problem and solve it 2: 3: Construct the second part of the input capacity matrix of the standard assignment problem, M i,j , according to the following rules:

2) UTILITY FUNCTION
The Utility function of machines and the base station in our algorithm is based on the capacity of the paths between the machines and with the base station. As previously mentioned, the capacity of direct and two hop paths are formulated by the equation (1) and the equation (6), respectively.

3) PREFERENCE LISTS
The preference lists of machines or base stations are formed according to the node utility functions computed VOLUME 8, 2020 by received channel information between the node and its neighbors.
• Each source has a preference list of its neighbor relays and base stations as their candidate next hops.
• Each relay has two preference lists of its neighbors. The first list, or list of the candidate next hops list, ranks its neighbor base station as next hop for data forwarding of applicant sources. The second list, or the list of the previous hops, rank applicant sources that requested to this relay. For simplicity, in the proposed algorithm, the size of the second list is considered to be one.
• Each base station has a list of its neighbor applicant sources and relays that requested it. We show the preference list of their candidate next hops of the machines by PL NH and the preference list of the applicants of the base station and the relays by PL AP . Any source or relay sort candidate neighbors in the next hop preference list according to capacity in the path consist of this hop. Moreover, any relay or the base station sort the list of applications according to the capacity of the path traversed from that node.
In the following, we study the proposed decentralized relay selection algorithm players and the preference lists.

B. DECENTRALIZED MATCHING BASED RELAY SELECTION ALGORITHM (MRSA)
Due to high density of M2M communications, each machine can have local information from its neighbors and network conditions. On the other hand, although ORSA achieves optimal results, in practice, it can create a bottleneck in dense M2M communications. This bottleneck is either due to communication overhead between the central processor unit and the other nodes or the processing load on the central unit. In this regard, a decentralized algorithm for relay selection may be more suitable for this type of communication. The main idea of the proposed decentralized algorithm for each source is finding a stable matching to select a suitable path, direct path or two hop path, to the base station to reach its data to the destination. To achieve this aim, this algorithm provides a stable best relay selection.
The weak channel between sources and the base station causes a low data rate in the direct path of sources and the base station. Hence, if a relay is selected as the next hop of a source, the selected neighbor relay has two features. First, it must have enough connection capacity and second, the path containing that relay must have a higher data rate than the rate of the direct path between the source and the base station. Furthermore, the selected relay has an equal or higher data rate than the rate of the paths containing other neighbor relays with enough capacity.
The proposed decentralized matching based relay selection algorithm (MRSA) is executed in three steps. For simplicity, we assume the machines can synchronize with each other. Some methods are available to synchronize devices in a decentralized network [39], [40] which can be used for this manner.
Algorithm 2 presents the pseudo code of our proposed decentralized MRSA. At the beginning of the algorithm, the relays broadcast estimated capacity of data transmission with the base station, according to the estimated SINR with it. Therefore, the sources have enough information to sort the candidate next hops, the relays or the base station.
Furthermore, in the initialization section of the algorithm, the machines construct the preference list of their candidate next hops (PL NH ). In addition, the base station and the relays construct the preference list of their applicants (PL AP ). Then all of the sources are added to MATCHLIST. Any unmatched machines in MATCHLIST sort their candidate next hops List, according to channel conditions with their neighbors and received information from them, in the beginning of the matching time.
In step 1, every time the first unmatched machine in MATCHLIST requests its application to the first next candidate in its preference list.
On the other hand, each node receiving the request, either a relay or the base station, has a given quota as the connection capacity. The quota for relays is equal to one and the quota of the base station is equal to the number of LTE channels. Thus, any receiver node accepts to a maximum of its quota from the best applicant machines and rejects other machines.
If the relay or base station that received the machine application has enough quota (connection capacity), the applicant machine will be added to the relay or base station preference list. Otherwise, if the new applicant machine is preferred over the worst current applicant machine it will be replaced with it. If neither of these cases hold, the new applicant machine is rejected by the current relay or the base station. Then, the applicant machine requests to its next best hop candidate, until no candidate remains in its preference list of their candidate next hops.
If a relay that receives a request from a source, does not have a specified next hop, it will be added to MATCHLIST to specify its next hop. Besides, if the relay does not find any next hop, it will reject its applicant sources.
The algorithm continues until no machine remains in MATCHLIST. During the execution of step 1 of the algorithm, no machine forwards its data to the destination. In step 2, any nodes match with the final best candidate in preference lists of next hops or applicants. Then, any machine sends data to the base station by the matched next hop that is selected in the previous step.

1) COMPLEXITY OF MRSA
MRSA can be implemented in a decentralized way for each source. We applied the deferred acceptance procedure [30] to implement this algorithm (Algorithm 2). In worst case, complexity of this procedure is O(|MATCHLIST| 2 ). In MRSA, |MATCHLIST| = N s + N r , so the complexity of MRSA is O ((N s + N r )  the number of sources is equal to N s = n, the complexity of MRSA is O(n 2 ).

C. PROOF OF STABILITY AND OPTIMAL STABILITY OF MRSA
This proposed decentralized algorithm is based on the deferred acceptance procedure. It is proved that the result of this algorithm is a stable solution [30].
The following definitions are required in the proofs: -Definition (in terms of matching theory): In a stable matching, there are no two nodes that they want each other but they match with another node.

Algorithm 2 Proposed Decentralized Matching Based Relay Selection Algorithm (cont.): Step 2
Step 2: Finish matching section and Start data forwarding 1: -Match each source with the first element in the Preference List of next hops, 2: -Match each relay with the first element in the Preference List of next hops, and with the first element in the Preference List of applicant machines, 3: -Match base station with the first element in the Preference List of applicant machines, 4: -Any machine sends data to the matched next hop.
-Definition (in terms of matching theory): The possible matching between an applicant node and another node means there exists at least one stable matching that assigns the applicant node to the other node.

1) STABLE RESULT
We claim that after algorithm 2 is finished, the achieved matching result will be stable.
Proof: It is demonstrated by contradiction. We assume the proposed matching result is not stable, so there are two nodes, for example, i and j, that prefer each other to the current matched node. Therefore, applicant node i, before requesting to the current matched node, has requested to node j and node j rejected node i. This means that node j prefers current matched node to node i. Thus it is a contradiction and the provided matching is stable.
It is important to note that in order to achieve stability in this procedure, it is necessary that the device' s priority is not the same when selecting a path. In our scenario, according to a random location and channel condition between devices, the probability of equal capacity between two devices is near to zero. Therefore, it does not hinder the proof of the stability of the problem.

2) OPTIMAL STABLE RESULT FOR SOURCES
Moreover, we claim for each source (as applicant node in matching theory), the provided stable matching is at least as well as any other stable possible matching using the same nodes.
Proof: We prove by induction. By the induction assumption, it is assumed that up to some point there is no applicant node that is rejected by a recipient node which was possible for the applicant node. Now, consider that at this point, an applicant node A is rejected by recipient node R. Now, we prove for the induction step that R is impossible for A. The recipient node keeps q of the best requests (q is the quota of the recipient node), such as s 1 , . . . , s q and other requests, such as A, are rejected. It is clear that for each of s i where 1 ≤ i ≤ q, s i prefers R to another recipient node except those that have rejected s i . Now, we assume by contradiction that R is possible for A (i.e. a stable matching exists which has matched A with R). It is clear that in this matching, at least one VOLUME 8, 2020 of the s i s will be matched to a recipient with lower preference for it and rejected by R. However this matching is unstable because s i and R could be matched which is preferred by both of them (due to the induction assumption). This means that the matching is unstable, and this is a contradiction. Therefore R is impossible for A and this proves the induction step. Therefore, we proved by induction that the matching is an optimal stable matching for sources.
In the following, we investigate the simulation results of the proposed algorithms in comparison with the direct transmission of data without a relay selection algorithm, as well as a completely random selection algorithm.

V. SIMULATION RESULTS
To evaluate the performance of the proposed relay selection algorithms, we simulate our algorithms in a square environment, 590 × 590 (m 2 ). In this square, N machines are randomly placed with a uniform distribution. Because of the random nature of the scenarios, the algorithm runs n = 1000 times and the average value is provided by considering these runs. In each run, the number of sources is constantly N a , and the rest of the N i machines relays, where N i = N − N a . In these simulations, the LTE uplink frequency range is considered 1900 − 1920(MHz), and the WiFi uplink frequency range for outdoor connections is considered 5590 − 5610(MHz).
The simulations are implemented in the C++ language. The simulations were executed on a device with a 4-core Intel(R) CPU (Intel Core i7-4710HQ @ 2.50GHz) and 16 GB of RAM. The simulation parameters are given in Table 1.
We compare the proposed relay selection algorithms (ORSA and MRSA) results with two baseline algorithms namely the direct transmission Without any Relay Selection Algorithm (WRSA) and the fully Random Relay Selection Algorithm (RRSA).
WRSA is a decentralized algorithm. In WRSA, the sources do not select any relays and only select the neighbor base station (i.e. base stations that can transmit and receive messages to the source). In this algorithm, each source requests to the neighbor base stations and creates a connection if possible. For each applicant source, if the base station has connection capacity, it accepts the source and they are assigned to each other. Hence, if the number of sources is of order n, the complexity of the algorithm will be O(n).
RRSA is also implemented in a decentralized way. In RRSA, each source selects its next hop completely randomly only once among all the relays and the base station. In RRSA, each source only requests a single relay or the base station, and if the request was possible a connection would be established, otherwise, no other request would be made. If the source selects a relay, and the relay is unable to communicate with the base station for any reason, such as lack of connection capacity or inability to communicate with the base station, the source will not change its selected choice. Additionally, if the source selects the base station, and the base station can not communicate with the source, the source will not change its selected choice. Thus the complexity of RRSA is O(n).
It is noticeable that in WRSA only one type of RF interface (LTE) is used for direct communication of the machines to the base station, But when using relays in ORSA, MRSA, and RRSA, according to the static setting of the RF interfaces, two types of interfaces (LTE and WiFi) are used simultaneously and communication between machines does not affect the direct communication of the machines to the base station. Table 1 provides the default parameters in our simulations. In the following, we compare the algorithms in different aspects and investigate the impact of some different parameters by changing the default values of parameters in the different scenarios that are discussed below.
The different scenarios are described below: • Scenario 1: The aim of this scenario is to compare all algorithms when the total number of network machines is constant and the number of relays and sources change proportionally.
• Scenario 2: In this scenario, all algorithms are compared where the number of relays is constant and the number of sources is varied in a specific range.
• Scenario 3: The impact of changing the relay number for ORSA and MRSA is investigated in this scenario.
• Scenario 4: The impact of changing the number of the base station LTE channels for ORSA and MRSA is investigated in this scenario.
The evaluation metrics considered in the scenarios are as follows: -Average Capacity of Connections between Sources and the Base station: The capacity of each link is the maximum bit rate that can be used according to the link conditions. The average capacity of connections between sources and the base station after completing the execution of the algorithms. Hereinafter, this parameter is briefly referred to as the average capacity of sources. The average duration time of the proposed algorithms (ORSA and MRSA) execution is measured and recorded for all scenarios. The curves of time values are plotted as a scatter with smooth lines and markers. To better visualize the trend of these curves, we calculated the trendline of these time curves using the trendline feature of Microsoft Office. We selected the polynomial trendline that had a good fit with the main curve. As this paper discusses uplink communication, it is important to transmit data of sources to their destinations via the base station as a bridge linking machines with the broadband infrastructure network. Therefore, the evaluation metrics include the average capacity of connections between matched sources and the base station and the number of unmatched sources.
A. SCENARIO 1 In this scenario, we investigate the difference of four algorithms, WRSA, RRSA, ORSA and MRSA, assuming the number of the base station LTE channels is a large enough constant and it does not restrict source assignment to it, directly or by one hop. Besides, the total number of network machines is constant and the number of relays and sources change proportionally.
We compare WRSA, RRSA, ORSA and MRSA in terms of the average capacity of sources, the number of unmatched sources and the complexity in equal conditions compared as in Table 2. 1) Capacity Fig. 8 shows a comparison of the average capacity of sources of WRSA, RRSA, ORSA and MRSA. The curves of ORSA, MRSA and RRSA are in a descending trend. This is because of the following reasons: -increasing the number of sources along the graph increases the interference of the transmitters (sources) on the shared WiFi channel, and -decreasing the number of relays across the graph reduces the improvement of capacity created due to the help of the relays. Due to path loss, shadowing and fading effects, attenuation of direct communication between the sources and the base station occurs. ORSA and MRSA, which select the relays to achieve optimal or stable assignment respectively, generally yield more average capacities of sources than WRSA and RRSA. On the other hand, ORSA and MRSA converge to WRSA at the end of the curve because these algorithms have similar functionality in the absence of any relays. Furthermore, WRSA curve almost follows a constant trend along the graph. This is due to the fact that all of the assigned sources directly connect to an LTE channel of the base station with the same bandwidth. The small possible difference of WRSA points is related to the different channel conditions with each of the sources. Additionally, as can be observed, ORSA has the best average capacity of sources among these algorithms. This is a direct result of the optimality of ORSA compared to other algorithms (that is shown in Section III-B

2) Unmatched Source Number
Due to the fading and shadowing effects in all scenarios, as shown in Fig. 9, a number of sources still are not connected to the base station. This can be explained in more details as follows: -Using WRSA, all sources try to connect directly to the base station. However, as can be seen from the simulation results, the presence of fading and shadowing effects attenuates the direct connection channels. Without a relay, there is no other way to connect the sources to the base station when the direct channel conditions are poor. Therefore, as the number of sources increases, an approximately constant proportion of them are not matched to the base station. -Using RRSA, according to the fully random nature of RRSA, each source selects between the direct connection or connection through the relays to the base station with 50-50% probability. In other words, a request to connect any source to connect to the base station occurs in two forms: -Direct connection to the base station with a probability of 50%, in which case the conditions will be like WRSA. -Connection to the base station through random selection between relays with a probability of 50%, in which case the connection may not be established due to the lack of communication capacity of the randomly selected relay. Therefore, as shown in Fig. 9, the number of unmatched sources of the RRSA algorithm is even higher than WRSA. -As mentioned in the previous section, ORSA and MRSA increase the average capacities of sources compared to WRSA and RRSA, by selecting the optimal or stable relays. As a result, it is natural that the number of unmatched sources after the execution of ORSA and MRSA is less than the other two algorithms. Given that in Scenario 1 the total number of machines was fixed at 100, increasing the number of sources means decreasing the number of idle machines or relays. Hence up to the point where the number of sources is less than or equal to 50, the number of relays is more than or equal to the number of sources. Since each relay can help a maximum of one source to send data, after this point even if each source neighbors at least one relay, some sources still are not able to connect to relays to compensate the weakness of their direct connection with the base station. Therefore the pace of the increase in the number of unmatched sources in the second half of the ORSA and MRSA curves is greater than in the first half.
In addition, it is clear that the optimal allocation in ORSA has been able to increase the number of unmatched sources compared to MRSA by an average of 0.5 sources and at maximum of 1.6 sources. The higher average of ORSA capacity compared to MRSA, observed in Fig. 8, is also in accordance with the aforementioned fact.

3) Actual Execution Time of Proposed Algorithms
Measured the actual execution time of our proposed algorithms is shown in Fig. 10. In the curve trendline, the coefficient of n 3 is near zero and this shows that the complexity of execution time is of order O(n 2 ). Therefore, as seen in Fig. 10, the order of trendline of actual execution time is at least less than or equal to the complexity of both of algorithms, ORSA and MRSA, that is calculated in Subsection III-B5 and IV-B1. Furthermore, it can be seen that ORSA actual execution time is more than MRSA actual execution time. According to Fig. 8, the algorithms can be ordered as ORSA, MRSA, WRSA and RRSA, in terms of the average capacity,. However, in terms of complexity, WRSA and RRSA, have lower complexity than MRSA and ORSA, respectively. Therefore, these algorithms possess a trade off between the better average capacity of sources and lower complexity and vice versa.
It should be noted that in this scenario, as the number of sources increases, the number of relays decreases. As both sources and relays have an equal impact on the execution time, the worst case happens when the number of sources and the number of relays is equal in the middle point of the curve.

B. SCENARIO 2
This scenario is similar to Scenario 1 with a large enough constant number of LTE channels and the number of sources is varied in a specific range. But, it has a fixed number of relays. In the following, each of the four algorithms is compared under the same conditions as in Table 3. 1) Capacity The comparison of the average capacity of sources of WRSA, RRSA, ORSA and MRSA is shown in Fig. 11. Due to the fact that WRSA does not use relays, the difference in the number of relays in Scenario 2 has no effect on its chart compared to    [1,25), the number of relays is less than the same range in Scenario 1. Also, in the range [25,100], the number of relays is more than the same range is in scenario 1. Therefore, in Scenario 2, for all three algorithms in the range [1,25), there are fewer options of next hops for the sources, which makes the average capacity a less than Scenario 1. In contrast, in the range [25,100], sources have more options to select the next hop, and the average container is higher than Scenario 2.
To verify this scenario results, we analyze them by the standard deviation of the results on all runs of the algorithms. The standard deviation of the results is equal to 0.27, 0.33, 0.15 and 0.15 for WRSA, RRSA, ORSA and MRSA, respectively.

2) Unmatched Source Number
As mentioned in the analysis of Fig. 11, in the range [25,100], sources have more relays available to select as the next hop, and more sources can match with the base station by a relay. Therefore, ORSA, MRSA and RRSA which are dependent on relays have less unmatched sources with respect to Scenario 1. But as seen in Fig. 12, since WRSA does not use relays, the difference in the number of relays in Scenario 2 has no effect on the number of unmatched sources compared to Scenario 1.

3) Actual Execution Time of Proposed Algorithms
In this scenario, the actual execution time of our proposed algorithms is measured where the number of relays is relatively high constant (N r = 75). As shown in Fig. 13, the ORSA execution time has a small coefficient of n 2 and the MRSA execution time is almost linear. For both of these curves, having an upper bound of O(n 3 ) for ORSA and O(n 2 ) for MRSA is observed, which was previously discussed in subsection III-B5 and IV-B1 respectively.

C. SCENARIO 3
The purpose of simulating this scenario is to investigate the effect of changing the number of relays on both ORSA and MRSA. We simulate ORSA and MRSA according to the parameters in Table 4.

1) Capacity
The results shown in Fig. 14

2) Unmatched Source Number
As shown in Fig. 15, Existence of more relays in the network will connect more sources to the base station and reduce the number of unmatched sources. As expected, ORSA unmatched sources are lower than MRSA.

3) Actual Execution Time of Proposed Algorithms
As see in Fig. 16, the average actual execution time trendline calculated in multiple settings (N r = 25, N r = 50 and N r = 75) of Scenario 3 simulations   D. SCENARIO 4 In this scenario, we want to evaluate the influence of changing the number of the base station LTE channels for ORSA and MRSA. Other parameters of this scenario are listed in Table 5.

1) Capacity
The results of the simulation of this scenario are presented in Fig. 17. These curves illustrate the following observations: -Regarding the fact that the total LTE bandwidth has a constant value (20MHz as stated in Table 1), a lower number of channels causes a greater capacity portion for each source. The optimal results show that despite a lower channel number in total, the ORSA-25 channel curve has the highest average capacity. -Optimal results provided by ORSA, show that when the number of LTE channels is 25 the average capacity of sources is higher than when the number of LTE channels is 50, and when the number of LTE channels is 50 the average capacity of sources is higher than when the number of LTE channels is 75. -When the number of sources reaches the number of channels (25, 50 and 75), all curves show the average capacity drop. This is due to the fact that when the number of sources exceeds the number of available LTE channels some sources to be unable to connect to the base station. The average standard deviation of the average capacity when the number of channels are 25, 50 and 75 are equal to 0.14, 0.13 and 0.14 for ORSA and 0.14 for MRSA in all cases., respectively.

2) Unmatched Source Number
As it can be seen in Fig. 18, when the base station has fewer LTE channels to communicate with machines, the number of sources able to communicate with the base station decreases and the number of unmatched sources increases. Also, The simulation results show that in both ORSA and MRSA, as long as the number of sources is less than the number of LTE channels available, most sources can be connected to the base station, and only a small number remain unaddressed due to conditions such as channel attenuation. Afterwards, bypassing the  number of sources through the number of channels, it is seen that as the number of sources increases, the number of unmatched sources also increases linearly. the number of channels available to the sources determines the number of sources that can be connected to the base station, and the remaining sources over the number of available LTE channels are not matched. For example, when the number of LTE channels is equal to 25, until the number of sources in the graph is less than or equal to 25, there are no unmatched sources. But when the number of channels exceeded the number of channels available, additional sources can not be matched. Therefore, regardless of the type of relay selection algorithm, since the number of LTE channels of the base station determines the number of machines that can be connected to the base station, the restriction of the number of LTE channels directly affects the number of unmatched sources.

3) Actual Execution Time of Proposed Algorithms
The actual execution time of ORSA and MRSA and their trendlines is shown in Fig. 19. In this scenario with a constant relay number (N r = 100) and variable source number, it is again observed that the coefficient of n 2 for ORSA is relatively small and the trendline of MRSA is linear. Therefore, in this scenario, as in the previous scenarios, the time complexity calculated in subsections III-B5 for ORSA and IV-B1 for MRSA is not violated.

VI. CONCLUSION
In this paper, two novel algorithms were proposed for relay selection in M2M communications. The first method (ORSA) is a centralized algorithm to find the optimal relay selection. ORSA is implemented by two transformations. Throughout this algorithm a new solution for the k-cardinality assignment problem is provided. The second method (MRSA) is a decentralized algorithm designed based on concepts from matching theory. The result of MRSA is a stable solution for relay selection. In all of the algorithms, static RF interfaces setting is considered to allow the parallel use of interfaces for data transmission. This type of simultaneous usage can help to improve the performance of the network. In the future, a dynamic RF interfaces setting can be considered in the design of the relay selection method. The results show that ORSA has the optimal average capacity, providing solutions about 3% higher than MRSA, when there is no restriction on the number of channels. Following ORSA, MRSA leads to solutions with average capacity higher than WRSA and RRSA, about 56% and 117%, respectively. Moreover, the comparison of both proposed algorithms with WRSA and RRSA, shows that ORSA and MRSA are more successful in increasing the average capacity of connections between sources and the base station and decreasing the number of unmatched sources.

APPENDIX A PROOF OF STABILITY AND OPTIMAL STABILITY OF MRSA
This proposed decentralized algorithm is based on the deferred acceptance procedure. It is proved that the result of this algorithm is a stable solution [30].
The following definitions are required in the proofs: -Definition (in terms of matching theory): In a stable matching, there are no two nodes that they want each other but they match with another node. -Definition (in terms of matching theory): The possible matching between an applicant node and another node means there exists at least one stable matching that assigns the applicant node to the other node.

1) STABLE RESULT
We claim that after algorithm 2 is finished, the achieved matching result will be stable.
Proof: It is demonstrated by contradiction. We assume the proposed matching result is not stable, so there are two nodes, for example, i and j, that prefer each other to the current matched node. Therefore, applicant node i, before requesting to the current matched node, has requested to node j and node j rejected node i. This means that node j prefers current matched node to node i. Thus it is a contradiction and the provided matching is stable.
It is important to note that in order to achieve stability in this procedure, it is necessary that the device' s priority is not the same when selecting a path. In our scenario, according to a random location and channel condition between devices, the probability of equal capacity between two devices is near to zero. Therefore, it does not hinder the proof of the stability of the problem.

2) OPTIMAL STABLE RESULT FOR SOURCES
Moreover, we claim for each source (as applicant node in matching theory), the provided stable matching is at least as well as any other stable possible matching using the same nodes.
Proof: We prove by induction. By the induction assumption, it is assumed that up to some point there is no applicant node that is rejected by a recipient node which was possible for the applicant node. Now, consider that at this point, an applicant node A is rejected by recipient node R. Now, we prove for the induction step that R is impossible for A. The recipient node keeps q of the best requests (q is the quota of the recipient node), such as s 1 , . . . , s q and other requests, such as A, are rejected. It is clear that for each of s i where 1 ≤ i ≤ q, s i prefers R to another recipient node except those that have rejected s i . Now, we assume by contradiction that R is possible for A (i.e. a stable matching exists which has matched A with R). It is clear that in this matching, at least one of the s i s will be matched to a recipient with lower preference for it and rejected by R. However this matching is unstable because s i and R could be matched which is preferred by both of them (due to the induction assumption). This means that the matching is unstable, and this is a contradiction. Therefore R is impossible for A and this proves the induction step. Therefore, we proved by induction that the matching is an optimal stable matching for sources. MOSTAFA MAHDIEH received the B.Sc. and M.Sc. degrees in computer engineering from the Sharif University of Technology, Tehran, Iran, in 2010 and 2012, respectively, where he is currently pursuing the Ph.D. degree in computer engineering with the Software Quality Research Laboratory. His research interests include software engineering, software testing, machine learning, and algorithms.