## 3 Farming Monitoring System Concepts and Methods
### Drone Path Planning Optimization  
In this study, an industrial agricultural hybrid fixed-wing VTOL drone, known as AeroHawk [36], was utilized to perform measurements. The selected VTOL drone has the advantages of both fixed-wing and multi-rotor drones, which can take off and land vertically without a long runway while having the leverage of more extended range and endurance due to the aerodynamic efficiency generated from the wings during flight. This key feature is important for farmers with a large area of land. To find the shortest flight path for the drone, first, the path planning problem was modeled as the TSP, and then both PSO and EPSO algorithms were used to solve the problem. In the TSP, the nodes and distance between the nodes are given, and the object is to find the minimum overall distance to travel from one node to other nodes and back to the starting node without crossing a node twice. According to graph theory, the TSP solves the Euclidean metric to find a Hamilton loop with the smallest weight in the weighted completely undirected graph. However, the TSP belongs to the class of non-deterministic polynomial (NP) problems. To reduce the computational complexity, metaheuristic algorithms such as the GA, PSO, ant colony optimization (ACO), and neural network (NN) have been used. In this study, we used PSO because of its advantages such as strong robustness, simulation evolution, ability to store past iterations, and easy implementation. The PSO algorithm works in such a way that, first, all particles are scattered randomly on the search space and every particle calculates the objective function based on its position in the search space. Then, each particle computes its next movement direction based on a combination of information about its current position, its best position that it has experienced so far, its current velocity, and information from one or more of the best particles in the swarm. Then, particles move, one step of the algorithm ends, and, in case of necessity, the above steps are iterated until the algorithm finds the optimal solution. In our simulation, we set the PSO algorithm to stop its execution when meeting the defined number of function evaluation (NFE) value, which is defined as  
\[NFE(t)=n_{pop}+n_{pop}\times t=n_{pop}(1+t), \tag{1}\]  
where \(n_{pop}\) is the population size (swarm size), and \(t\) is the number of iterations. To formulate the behavior of particles, assume there are \(n\) particles in the swarm, where the position and velocity of \(i\)th particle at time \(t\) are denoted as \(x^{i}\) and \(v^{i}\), respectively, for \(i\in\{1,\ 2,\ \ldots,\ n\}\). \(x^{i,\ best}[t]\) is the best position that the \(i\)th particle has experienced so far and \(x^{best}[t]\) is the best position in the swarm's experience. In every iteration (generation), the swarm updates its best position (based on objective value) which is known as the global best, and each particle updates its best solution (i.e., personal best) and computes its next position as follows:  
\[v^{i}[t+1]=wv^{i}[t]+c_{1}r_{1}\Big{(}x^{i,\ best}[t]-x^{i}[t]\Big{)}+c_{2}r_{2 }\Big{(}x^{best}[t]-x^{i}[t]\Big{)}, \tag{2}\]  
\[x^{i}[t+1]=x^{i}[t]+v^{i}[t+1], \tag{3}\]  
where \(w\) is the inertia coefficient, \(c_{1}\) and \(c_{2}\) are cognitive and social acceleration coefficients, respectively, and \(r_{1}\) and \(r_{2}\) are random numbers in the range of 0-1. The weakness of the classic PSO algorithm in solving the TSP is that it falls into the trap of local optimums. To address this problem, we applied three mutation operators, called swap, reversion, and insertion, into the PSO algorithm, and the modified PSO algorithm is called EPSO. Figure 7 shows the flowchart of the EPSO algorithm which was implementedin MATLAB. The initial parameters are generated through the swarm initialization.