## 2 Mathematical Formulations
### Particle Swarm Optimization (PSO)  
In this paper, Particle Swarm Optimization (PSO) was applied to solve multi-objective function presented in Equation (3) which are subjected to the constraints presented in Equations (7)-(9) to analyse the voltage variation and network real power losses while changing the number of DG at the network configuration. Particle swarm optimization (PSO) is inspired by the movement and intelligence of swarms searching for food placed in an unknown location. Each swarm is recognized as a particle or variable \(X\), but vying for a common objective. The optimal position is known individually as a personal best (\(P_{best}\)) but, in a group, it is known as the global best (\(G_{best}\)). The particle that each individual represents is known as a possible solution. The search for the optimal solution happens in a search space normally known as a solution space, where other particles must follow the best particle moving ahead, and they change their position and fitness regularly, optimizing their chances of success in finding the best solution.  
A particle is represented by the variable \(X=[x_{1},\,x_{2},\,x_{3}\ldots x_{n}]\) that would minimize the power losses and maximize the voltage stability or cost and production; this depends on a set objective function. The proposed optimization fitness function is formulated as \(f(X)\), where \(X\) is known as the position vector that represents the vector model. \(X\) is an n-dimension vector since it can be a multi-dimension vector, so n represents the number of variables that can be determined in the set problems. Another variable the particles possess in the search space is velocity, \(V=[v_{1},\,v_{2},\,v_{3}\ldots v_{n}]\), which represents the direction of searching. During the iteration process, each particle maintains the best-found position, pbest, individually and the group position, also known as the best position of the group, gbest, and changes its position following the best found positions. The function of \(f(X)\), known as the objective function or fitness function, is to assess the performance of the particle's position in the search space and find an optimal point at the end. This criterion is achieved by employing a number of iterations and updating the position until the maximum or minimum point is reached. The particle position is updated as given below:  
\[X_{i}^{t+1}=X_{i}^{t}+V_{i}^{t+1} \tag{44}\]  
where velocity  
\[V_{i}^{t+1}=V_{i}^{t}+C_{1}r_{1}\,\left(p_{i}^{t}-x_{i}^{t}\right)+C_{2}r_{2} \left(p_{i}^{g}-x_{i}^{t}\right) \tag{45}\]  
where  
\(X_{i}^{t}\)--Particle position  
\(V_{i}^{t}\)--Particle velocity  
\(p_{i}^{t}\)--Best recent individual particle position  
\(p_{i}^{g}\)--Best recent swarm position  
\(C_{1}\), \(C_{2}\)--Cognitive and social parameters  
\(r_{1}\), \(r_{2}\)--Random numbers between 0 and 1  
In the \(G_{best}\), the velocity of a particle \(i\) with the inertia \(\omega\) will be given as  
\[V_{i}^{t+1}=wV_{i}^{t}+C_{1}r_{i}^{t}\Big{[}P_{best,i}^{t}-x_{i}^{t}\Big{]}+C _{2}r_{2}^{t}\big{[}G_{best}-x_{i}^{t}\big{]} \tag{46}\]  
where \(C_{1}\) and \(C_{2}\) are the acceleration coefficients while \(r_{1}\) and \(r_{2}\) denote random values required to maintain the velocity components.