# Sensor Topology Optimization in Dense IoT Environments by Applying Neural Network Configuration
## 3 System Model Design and Optimization Framework
### Neural Network Framework  
We solved our combinatorial optimization problem, as defined in (9), by building a neural network framework in Python, which utilizes well-known libraries such as Numpy, TensorFlow, and Keras. In Figure 2, we give a flowchart diagram of the proposed neural network solver. For the initialization phase, we use csv files as input datasets to express the sensors' initial coordinates. These coordinates, which form the initial topology, are the theoretical topology points and are given as an input to the solver in the first execution step of the algorithm. The algorithm reads a digital map of the FoI and extracts the sensor node coordinates to a csv file. This map also provides the coordinates of the query or reserved points. The algorithm's basic operation is to propose the nearest-neighbor theoretical points for every query point. This is achieved with a single-layer perceptron, i.e., a feed forward neural network (FFNN) with many inputs and outputs for each query point. In the case of a deterministic topology, the inputs to the FFNN are the coordinates of query points and the coordinates of theoretical points, i.e., the ones resulting from the CVT. The FFNN's outputs are the sensor coordinates of the theoretical points which are as close as possible to each query point, with respect to the communication and coverage constraints defined in the previous section. Therefore, the algorithm selects its nearest (i.e., energy-efficient) neighbor for each node. In our work, two NN configurations were built to propose the new and energy-efficient coordinates for each reserved sensor terrain point. The structure of the first NN configuration consists of (2) layers, and the second NN of (3) layers. We built a deep learning NN model with different parameters in Python using Keras [32]. Keras is a powerful, easy-to-use, free, and open source Python library for developing and evaluating deep learning models. It is part of the TensorFlow library and allows us to define and train NN models. We used the classes Sequential and Dense from Keras in our model. Models in Keras are defined as a sequence of layers. We created a sequential model and added layers. The best network structure is found through a process of trial-and-error experimentation [13]. Compiling a NN model uses the efficient numerical libraries of TensorFlow. The backend automatically chooses the best way to represent the network for training and making predictions. During compilation, we specified some additional properties required for the network training. Training a network means finding the best set of weights to map inputs to outputs for our dataset. We trained or fitted our model on our loaded data by calling the fit() function on the model. After training the model, we used it to make predictions on new data using the method model.predict(). Theoretical points will be repositioned in the new coordinates proposed by the NN. The criterion for a valid geometric topology is that the proposed relocation of each node should be at a distance of L \(\leq(2-\sqrt{3})\times R_{\text{s}}\) from its original positions and towards the orientation direction of the sink node. The neural network solver proposed a network topology with the minimum energy consumption, according to the objective function in Equation (9). We then extracted the nodes' coordinates to a csv file and we could draw the new topology. As soon as the solver reached an energy-efficient (i.e., final) topology, we proceeded with the calculation of the total network lifetime, according to the final topology design. Based on the trained NN model, the new nodes' coordinates indicate points as close as possible to the sink nodes, regarding the communication and coverage constraints. This means that we may relocate some nodes apart from their initial points, as suggested by the CVT. With the proposed algorithm, we managed to increase the network lifetime in all the proposed use cases at a factor of 3% to 5%, ensuring a connectivity rate of over 90% in all topologies.