# Novel Approach Sizing and Routing of Wireless Sensor Networks for Applications in Smart Cities
## 3 Problem Formulation
### Wireless Sensor Network Routing
#### 3.2.3 Multiple Flow Routing  
For the third routing case of the wireless sensor network, a set of sensors is assumed to be connected via unidirectional wireless links. If a link exists between node \(A\) and node \(B\), denoted as \(e_{A,B}\), then \(A\) can send data directly to \(B\). The link \(e_{A,B}\) has an associated weight or distance and is given by \(d_{A,B}\); additionally, the capacity of the link \(e_{A,B}\) is given by \(C_{A,B}\). Thus, \(V\) is defined as the set of sensors, \(E\) as the set of existing links, and \(G=(V,E)\) as a directed graph that represents the network topology. On the other hand, we assume a set of data flows \(F=\{f_{1},f_{2},\ldots,f_{k}\}\) that require the transmission of data from a source node \(S_{k}\) to a destination sensor \(T_{k}\); this requirement refers to the link capacity in terms of the flow \(F_{k}\) and is determined by \(R_{k}\). The flow is transmitted through the intermediate sensors by using existing links. A flow between a pair of sensors \(f_{k}=(S_{k},T_{k})\) belonging to \(V\) represents the source and destination sensors. To define the optimization model, it is necessary to define a path \(P\) as a set of sensors \(P=\{P_{1},P_{2},\ldots,P_{M}\}\) such that the sensors \(e_{Pk,Pk+1}\in E\); in addition, we define the length of the path \(P\) as \(d_{P}\), which is given by \(d_{P}=\sum_{k=1}^{M-1}d_{Pk,Pk+1}\). We then define the path for the flow \((s,t)\) as a path \(P_{s,t}\) such that \(P_{1}=s\) and \(P_{M}=t\). The minimum-distance path is defined as the path \(P_{s,t^{*}}\) such that \(d_{P_{s},t^{*}}<=d_{P_{s,t}}\) for any other possible path \(P_{s,t}\). A possible route is defined as a route that contains links that exist within the topology and that can transmit the flows passing through them. In this way, the optimization problem that seeks to find the minimum-distance path is defined by considering the flows belonging to \(F\). To determine the problem in the field of optimization, it is required to define the variable \(X_{i,j,k}\); for this, it is assumed that the link \(e_{i,j}\) exists and that \(X_{i,j,k}\) has a value of 1 if the link \((i,j)\) belongs to the path \(P_{sk,tk}\); that is, the k-th flow uses the link \(e_{i,j}\); otherwise, the value is 0. Similarly, for a sensor \(i\in V\), \(E_{i,out}\) is defined as the set of outgoing links of \(i\) and \(E_{i,in}\) is defined as the set of incoming links of \(i\). Overall, the model supporting the above is as follows:  
Objective function:  
\[\min\ \ \sum_{(i,j)\in E}\sum_{k\in F}d_{i,j}X_{i,j,k}, \tag{12}\]  
which is subject to:  
\[ \begin{array}{l}\sum\limits_{j|e_{i,j}\in E_{i,out}}X_{i,j,k}-\sum\limits_{j |e_{i,j}\in E_{i,in}}X_{i,j,k}=\alpha_{i,k}\\ \forall i\in V;\forall k\in F\end{array}  \tag{13}\]  
\[\sum_{k\in F}R_{k}\cdot X_{i,j,k}\leq C_{i,j};\ \forall\ (i,j)\in E \tag{14}\]  
\[\alpha_{i,k}=\left\{ \begin{array}{l}1,\ \text{si}\ i=s_{k}\\ -1,\text{si}\ i=t_{k}\\ 0,\ \text{si}\ i\
eq s_{k},i\
eq t_{k}\end{array} \right. \tag{15}\]  
In this way, as with multicast routing, one can seek to determine the tree with the minimum cost allowed by the downstream Dijkstra algorithm; however, in this case, it is necessary to subtract the capacity of the links of the current network from the transmission rate of the current flow over the links affected by the same link [32; 33]. The pseudocode for the optimal sizing of the wireless sensor network is presented in the \(ODRSI\) Algorithm 1, and the pseudocode with the optimal routing according to the sizing results is presented in the \(OERSI\) Algorithm 2; furthermore, Table 2 summarizes the variables used in Algorithms 1 and 2. \begin{table}