## 2 Distributed Fair Rate Allocation Algorithm
### Problem Formulation under Fairness Considerations  
Let us consider the following optimization problem [16]  
\[ \begin{array}{ll}\max\limits_{\{r_{j}\}}&\sum_{j=1}^{N}U_{j}(r_{j})\\ s.t.&m_{j}\leq r_{j}\leq M_{j},\ \ j=1,\ldots,N\\ &\mathbf{Ar}\preceq\mathbf{c}\end{array}  \tag{1}\]  
with variables \(r_{j}\in\mathbb{R}^{+}\) that represent the rate allocated to the j-th sensor. The functions \(U_{j}:\ \mathbb{R}^{+}\rightarrow\mathbb{R}\) are strictly concave, increasing and differentiable in \(\{r_{j}\mid m_{j}\leq r_{j}\leq M_{j}\}\), where \(M_{j}>m_{j},\ m_{j}\in\mathbb{R}^{+}\). The vector \(\mathbf{c}=[c_{1},\ldots,c_{L}]^{T}\) contains the maximum transmission rate in the \(L\) channels of the network and the matrix \(\mathbf{A}\) represents the network topology. Note that each wireless channel connects one parent node to its child nodes and that each entry \(A_{k,j}\) is either \(1\) if the flow from the j-th sensor crosses the k-th channel or \(0\) otherwise. Note also that Problem (1) defines a convex optimization problem [17; 18]. Finally, we assume that there exists at least one strictly feasible solution to the problem, _i.e._, a point that satisfies \(\mathbf{Ar}\prec\mathbf{c}\) and \(m_{j}<r_{j}<M_{j}\;\forall j\), so that [PERSON]'s constraint qualifications [18] (Section 5.2.3) are fulfilled and thus strong duality holds. The optimization framework in Problem (1) is known to provide a fair distribution of resources if the utility functions \(U_{j}\) are adequately chosen [19; 20]. Moreover, we can specify the desired degree of fairness by fixing the parameter \(\gamma\) in the following family of utility functions [21] (Lemma 2) in Equation (2). Furthermore, \(w_{j}\in\mathbb{R}^{+}\) is defined as the priority of the j-th flow and it is used to balance the flow allocation towards the j-th sensor once the value of \(\gamma\) is fixed (the higher the value of \(w_{j}\), the larger the allocation). \[U_{j}(r_{j};w_{j},\gamma)=\left\{ \begin{array}{rl}w_{j}\,\log \,(r_{j}),&\gamma=1\\ w_{j}\frac{r_{j}^{(1-\gamma)}}{1-\gamma},&\gamma\
eq 1\end{array} \right. \tag{2}\]  
Roughly speaking, with \(\gamma\rightarrow\infty\) we get a max-min fair solution, that is, we do not allow to increase the rate of the i-th flow in the network if it implies (due to the constraints) decreasing the j-th flow given that initially \(r_{j}<r_{i}\). That is the most stringent definition of fairness. The opposite situation is for \(\gamma=0\) and then the goal is to maximize the weighted network throughput. This solution is totally unfair since, depending on the network constraints, some sensors would have no transmission opportunities at all. An intermediate and well-established solution is obtained with \(\gamma=1\), a.k.a., proportional fairness. In this case, a small rate decrease in one flow is accepted if it implies a significant increase in other flows so that the network throughput is less penalized. For further details on fairness formulations, please refer to [21] and references therein. Note, however, that except for \(\gamma=0\), increasing the rate \(\Delta r\) produces a bigger increase in utility when the sensor has a small rate allocation than when it is high. In our WSN scenario, we assume that the network is built-up so that each sensor knows the route to the sink inside the cluster tree. Furthermore, each parent node has the information about the maximum transmission rate of its cluster, which is given by its own superframe configuration, and each sensor has evaluated its radio link quality, e.g., by means of the Packet Delivery Ratio (PDR). Given all this information, the goal is to compute a fair distribution of the available rate among the sensors. In the following, we focus our attention in the resolution of Problem (1) and we leave the practical implementation issues to Section 3. From the point of view of the optimization mechanism, note thatone possibility is to gather all the requests at the sink node, compute there the optimal rate allocation and send it back to the sensors.