# Optimal Design and Real Time Implementation of Autonomous Microgrid Including Active Load
## 3 Problem Formulation
### Particle Swarm Optimization  
In this work, PSO is utilized to obtain the optimal parameters. In 1995, stimulated by social behavior of bird gathering or fish training, [PERSON] and [PERSON] developed PSO as a population based stochastic optimization method [35]. It is worth mentioning that balancing between local and global search methods can be achieved using PSO. It has different advantages over other traditional optimization techniques [3]. In a PSO algorithm, the population has \(n\) particles that represent candidate solutions. Each particle is an \(m\)-dimensional real-valued vector, where \(m\) is the number of optimized parameters. Therefore, each optimized parameter represents a dimension of the problem space. The PSO technique can be summarized as follows:  
1. Initialization Starting by time counter setting then randomly \(n\) particles and their initial velocities will be generated. The objective function of each particle will be evaluated. From the obtained objective functions, the global best function \(J_{best}\) will be selected as the lowest objective function. Meanwhile, its associated global best particle \(x_{best}\) will be selected as well. To control the impact of the previous velocity on the current velocity, the inertia weight will be initiated. 2. Time Updating The time counter will be updated. 3. Weight Updating The inertia weight will be updated as follows \(w(t)=\alpha w(t-1)\) where \(\alpha\) is a decrement constant smaller than but close to 1;
4. Velocity Updating At each time step, each particle velocity is modified depending mostly on its current velocity and the distances between the particle and its personal and global best positions. \[v_{n+1}^{j}=wv_{n}^{j}+c_{1}r_{1}\left(p_{best}-k_{n}^{i}\right)+c_{2}r_{2} \left(g_{best}-k_{n}^{i}\right)\] (30) where \(r_{1}\) and \(r_{2}\) are random numbers between 0 and 1; \(w\) is the inertia weight; \(c_{1}\) and \(c_{2}\) are the 'trust' parameters; \(g_{best}\) is the best swarm position; and \(p_{best}\) is the best position for particle \(i\). It is worth mentioning that the second term represents the cognitive part of PSO where the particle changes its velocity based on its own thinking and memory. The third term represents the social part of PSO where the particle changes its velocity based on the social-psychological adaptation of knowledge. In previous research, a variety of inertia weight strategies were proposed and developed to improve the performance of the PSO algorithm. However, the random values for most modified PSO algorithms are always generated by uniform distribution in the range of [0, 1]. Obviously, the random values represent the weights of two distances for updating the particle velocity. If the range of random values is small, these two distances have little influence on the new particle velocity, which means that the velocity cannot be effectively increased or changed to escape from local optima. In order to improve the global optimization ability of the PSO algorithm, it is necessary to expand the range of random values [41]. 5. Position updating Based on the updated velocities, the new particle position at iteration \(n+1\) is given \[k_{n+1}^{i}=k_{n}^{i}+v_{n+1}^{i}\] (31) where \(k_{n+1}^{i}\) and \(v_{n+1}^{i}\) are the particle position and its velocity vector at iteration \(n+1\). 6. Individual Best Updating For each particle, the cost function J will be determined according to the updated position and then it will be compared with the previous one. If this cost function at this time is less than the previous one, it will be selected as the global best \(J_{j}^{*}\). An individual best will be also selected as a global best. 7. Global Best Updating From the all values of the global best \(J_{j}^{*}\), the minimum value will be selected as follows: If \(J_{\min}>J^{**}\) then update global best as \(X^{**}=X_{\min}\) and \(J^{**}=J_{\min}\). 8.