# Energy Efficient Access Point Placement for Distributed Massive MIMO
## Appendix A  
This section elaborates on the algorithms that are used for computing the paths in the two graph-based channel models. In Algorithm A1, set \(\mathcal{L}\) includes all the nodes corresponding to the potential AP locations. \(graph\) is the graph, including all the nodes and connections between the nodes. Vector \(\mathbf{g}_{\text{T}}\) includes the antenna gain for different directions. Line 1 initializes set \(\mathcal{D}\), which is used to store all the calculated \(\ell_{il}\) and return this set at the end of the algorithm. Lines 2-27 iterate over each node \(src\) (potential AP location) in set \(\mathcal{L}\) and compute the best paths between \(src\) and each node in the graph. In each iteration, set \(\mathcal{Q}\) is used to store all the nodes that need to be explored. It initially only includes node \(src\) (line 3). More nodes are added to it on line 22. Each explored node is removed from \(\mathcal{Q}\) on line 14. When \(\mathcal{Q}\) becomes empty on line 12, an iteration is completed. Lines 4-11 initializes the vectors. Each \(d[n]\) in vector \(\mathbf{d}\) stores the value of parameter \(\ell_{il}\) -- \(i\) is node \(n\) and \(l\) corresponds to node \(src\). The lower the \(d[n]\), the better the path is from node \(src\) to node \(n\). \(dist[n]\) is the length of the best found path between nodes \(src\) and \(n\). \(penalties[n]\) is the product of all the angular change penalties involved in the best found path between nodes \(src\) and \(n\). \(prev[n]\) is the previous-hop node in the best found path between nodes \(src\) and \(n\). On lines 12-26, each node in \(\mathcal{Q}\) is explored. It starts by getting a node \(i\) in \(\mathcal{Q}\) on line 13 that is associated with the minimum value \(d[i]\). The reason for selecting the minimum \(d[i]\) is to reduce the computational time of Algorithm A1. Then, each neighbor node \(j\) of node \(i\) is explored (lines 15-26). Function \(\texttt{length}(i,j)\) on line 16 gives the distance between nodes \(i\) and \(j\). Line 17 checks whether node \(i\) is the initial node of the path, which means that it is associated with a potential AP location. Function \(\texttt{antenna}\texttt{Gain}(src,j,\mathbf{g}_{\text{T}})\) on line 18 calculates the antenna gain from node \(src\) (potential AP location) to the direction of node \(j\) via Algorithm A2, where function \(\texttt{broadside}(src)\) gives the broadside direction at the potential AP location of node \(src\). Then, the reciprocal of the square root of the antenna gain is incorporated into \(alt\). The reason for using the reciprocal and square root is due to the relation between the propagation distance and antenna gain when calculating the channel gain. If node \(i\) is not the initial node, line 20 incorporates the angular change penalty into \(alt\). The angular change penalty is calculated with the function \(\texttt{penalty}(. )\) using Algorithm A3 which will be detailed later. On line 21, if the new value is better than the current value for \(d[j]\), the data related to node \(j\) is updated on lines 22-26. After each iteration, new computed vector \(\mathbf{d}\) is added to set \(\mathcal{D}\) on line 27. Finally, after running Algorithm A1, \(\ell_{il}\) is extracted from \(\mathcal{D}\) for each \(i\in\mathcal{R}\) and \(l\in\mathcal{L}\).