# Operation Scheduling Optimization for Microgrids Considering Coordination of Their Components
## 3 Solution Method
### Application of Binary Particle Swarm Optimization  
PSO is a population-based, stochastic computational algorithm [34] that optimizes a problem by iteratively trying to improve a solution candidate for a given measure of quality, called fitness function. An initial set of randomly created solutions, called the initial swarm, propagates in the design of the search space towards the optimal solution over a number of iterations, called moves, based on the large amount of information that is fitted and shared by all members of the swarm. Each particle \(x\) has a position, \(y_{x}^{m}\), and a velocity, \(z_{x}^{m}\), in iteration \(m\) (\(m=1,2,\ldots,M\)) and flies through the search space to find the best positions and velocities. The inertia weight factor, \(\omega\), controls the iteration size. With regards to the proposed problem formulation, the below equations describe the solution update mechanism.  
\[y_{x}^{m}=u^{\prime}, \tag{20}\]  
\[y_{x}^{m+1}=y_{x}^{m}+z_{x}^{m+1}, \tag{21}\]  
\[z_{x}^{m+1}=\omega z_{x}^{m}+\theta_{1}r_{1}[y_{x}^{*}-y_{x}^{m}]+\theta_{2}r_ {2}[\left(\min_{x\in X}y_{x}^{*}\right)-y_{x}^{m}], \tag{22}\]  
where \(\theta_{1}\) and \(\theta_{2}\) are the cognitive factors that represent the trust for each particle and the swarm; \(r_{1}\) and \(r_{2}\) are the random numbers in the range, \([0,\ 1]\); \(y_{x}^{*}\) is the personal best for particle \(x\), called pbest; \(\min_{x\in X}y_{x}^{*}\) is the best in the swarm, called gbest; and \(X\) is the set of all particles.  
Although PSO has succeeded in many continuous problems, it still has some difficulties in treating discrete optimization problems [35]. To modify ON/OFF states of the controllable components, \(u^{\prime}_{h,t}\), the PSO is expanded as a BPSO, which introduces the following sigmoid function in part of the PSO algorithm.  
\[\text{If }0.5<\frac{1}{1+e^{-u^{\prime}_{h,t}}}\text{ then }u^{\prime}_{h,t}=1, \text{ else }u^{\prime}_{h,t}=0,\text{ for }h<NG,\ \forall t. \tag{23}\]  
Here, \(u^{\prime}_{h,t}\) for the ESSs and the CLs (\(NG<h<NH-1\)) can be set to \(1\) in the range of available periods of the components (ESSs: \(t\in TS_{j}\), CLs: \(t\in TV_{k}\)), while it can be set to \(0\) in the other periods (ESSs: \(t\
otin TS_{j}\), CLs: \(t\
otin TV_{k}\)). This is because the outputs for the ESSs and the CLs include \(0\) in their controllable ranges. For the same reason, \(u^{\prime}_{h,t}\) for electricity trading (\(h=NH\)) can be set to \(1\) for all time periods. As a result, we can fix \(u^{\prime}\), and, therefore, the combined method of BPSO and QP solves the formulated problem approximately.  
With the aim of handling the constraints, the penalty method, which replaces a constrained optimization problem by a series of unconstrained problems, is applied during the iterative process. The fitness function is represented as  
\[F=\sum\
olimits_{t=1}^{T}\left\{\int_{d_{t}^{min}}^{d_{t}^{max}}\left\{C_{t}(u_{ t},\ g_{t})+M_{t}e_{t}+I_{t}e_{t}^{\prime}+VIO_{t}\right\}\!f(d_{t})\mathrm{d}d_{t}\right\}\!, \tag{24}\]  
where \(VIO_{t}\) is the weighted sum of violation of the constraints excluding (9) (\(VIO_{t}\gg C_{t}(u_{t},\ g_{t})+M_{t}e_{t}+I_{t}e_{t}^{\prime}\)).