Energy Management of Community Microgrids Considering Uncertainty using Particle Swarm Optimisation

Although energy management of a microgrid is generally performed using a day-ahead scheduling method, its effectiveness has been questioned by the research community due to the existence of high uncertainty in renewable power generation, power demand and electricity market. As a result, real-time energy management schemes are recently developed to minimise the operating cost of a microgrid while high uncertainty presents in the network. This paper develops modified particle swarm optimisation (MPSO) algorithms to solve optimisation problems of energy management schemes for a community microgrid and proposes a scheduling approach after taking into consideration high uncertainty to effectively minimise the operational cost of the microgrid. The optimisation problems are formulated for real-time and scheduling approaches, and solution methods are developed to solve the problems. It is observed that the scheduling program demonstrates superior performance in all the cases, including uncertainty in prediction, as compared to the other energy management approaches, although solutions have significant deviations due to prediction errors.

. In [14], a stochastic model predictive control approach considering RES in energy management of a microgrid is presented. A day-ahead scheduling with distributed generators and load is co-investigated in [15], where mixed-integer linear programming (MILP) is used as solver in the GAMS tool. In [16], a day-ahead scheduling approach with several objective functions is presented, where dynamic programming is used to solve the optimisation problem. For energy management of an office building, various optimisation techniques based on energy consumption of rooms are presented and solved using action dependent hierarchical dynamic programming in [13]. Although several schedule programs are present in the literature, real-time energy management schemes are gradually being implemented to avoid uncertain effects [20].
In [8], an online energy management strategy for the real-time operation of a microgrid is developed. The study considers the constraints of power flow and system operation on a distribution network and it models online energy management as a stochastic optimal power flow problem. Lyapunov optimisation approach is used to solve the optimisation problem. In [10], a binary particle swarm optimisation algorithm is developed to improve a microgrid's performance in a real-time operation in terms of minimising energy cost and CO 2 emission. In [21], a stochastic continuous time model for a microgrid energy management using dynamic programming is demonstrated. A real-time energy management strategy for a battery-swapping station of a smart community microgrid is presented in [9], where RESs supply power to loads and batteries. The optimisation problem is solved using queuing theory-based Lyapunov optimisation framework. In [5], both real-time and scheduling approaches are presented to reduce the energy cost of a house and it is concluded that real-time energy management performs better in practice than scheduling, although a full comparison is not provided. In the majority of the literature, researchers are suggesting applying real-time energy management instead of using a scheduling approach since high uncertain existence in a renewable power generation, but they have not compared extensively the methods.
While real-time energy management schemes are gradually applied in managing energy of a microgrid, their effectiveness should be systematically justified before implementing in practice. To the best of the authors' knowledge, there is no existing literature that extensively demonstrates the performance analysis of several energy management schemes under high uncertain environment to systematically present their results. Therefore, to bridge the gap, this paper contributes to the existing knowledge as follows: • A nature inspired meta-heuristic algorithm, modified particle swarm optimisation (MPSO), is proposed to solve the optimisation problems of real-time and scheduling energy management schemes developed, the modification is carried out in the structural change of the PSO algorithm by introducing a correction method during variable selection; • This paper extensively analyses various energy management approaches while considering uncertain effects on energy schedule and their explicit impact on the scheduling problems; • Mathematical models for the components of a microgrid, such as solar and wind generation, are presented to facilitate the analysis; and • A comparative analysis of several advanced optimisation algorithms is conducted to measure their effectiveness to solve an optimisation problem of discrete time.
In this study, we have developed MPSO algorithm to solve the optimisation problems for a number of rea- improved performance in the scheduling approach as compared to the advanced algorithms. It is worth mentioning that while the PSO algorithms are sometimes criticised for stuck in local optima, this is not an issue for small scale optimisation problems like microgrids. From the case study of this paper, it is observed that the scheduling program demonstrates better performance even after confronting high uncertainty in input data or error in input data prediction.
The remainder of this paper is structured as follows. Section 2 presents a short description of a community microgrid and its components are modelled for facilitating a comparative study. In Section 3, optimisation problems are formulated as real-time and scheduling approaches to manage the energy of the microgrid under uncertainty in electricity prices. Separate solution methods using the MPSO algorithm are presented in Section 4. In Section 5, simulation results with a comparative analysis of advanced optimisation algorithms are discussed. Section 6 provides concluding remarks.

System description and modeling
This study considers a community microgrid that is located in a remote area with a grid-connected power supply as shown in Figure 1. The microgrid has seven solar generators with each 5 kW capacity, eight wind turbines with each 5 kW capacity and an energy storage system with 40 kW h capacity. The capacities of the microgrid's components are given in Table 1. The microgrid can exchange power with the grid utility depending on available energy sources and there are no limits on the transmission line for exchanging powers. The EMS is the main responsible controller for assuring a supply-demand balance in the microgrid. In the following subsections, the mathematical models of the microgrid's components are provided.

Solar generators
The output power from solar irradiation, shown in Figure 2, for a solar panel can be determined as follows [22]: where η s indicates the conversion efficiency (%), A refers to the area of PV panels (m 2 ), and t o is the outside For a number of solar panels, the total output power can be expressed as follows: where i(= 1, 2, 3......I) is the number of solar generators, seven in this study.

Wind turbine
The wind power generation depends on wind velocities, as shown in Figure 3, at the power rating and site of a wind turbine. The electric power as a piece-wise function of the wind speed can be expressed as follows [22]: where P r is the rated electrical power; v r is the rated wind speed; v represents wind speed; v c refers to cut-in wind speed; and v f is the cut-off wind speed.
For a number of wind turbines, the total output power can be calculated as follows: where j(= 1, 2, 3.......J) is the number of wind generators, which are eight in our study.

Storage systems
Battery energy levels for the charging/discharging cycles of the battery can be represented as follows [22]. subject to: Power limits Battery energy level limits where P c (t) is the charging powers of the battery at time t; P d (t) the discharging powers of the battery; BL(t) the battery energy level; ∆t the interval of the time period; and η c and η d are the charging and discharging efficiency, respectively."

Loads and grid utility
The load profile, L(t), of the locality is shown in Figure 4. The loads, including basic household equipment of the community, such as refrigerators, TVs, fans, lights and computers, fluctuate over the time period with a time step of one hour. Real-time electricity prices usually depend on the wholesale electricity market and vary over time. In this study, those varied price-rates are considered due to their effectiveness over others [23]. The purchasing and selling RTP are represented by C(t) (cents/kW h) and considered identical, i.e C buy (t) = C sell (t) = C(t), for simplicity purpose. The variation of RTP is adopted from [24] and illustrated in Figure 5. The electricity rate is converted by considering the present electricity rate and future electricity market in Australia.
The exchange power at time t with the grid utility is marked as P g (t) kW and it can be calculated as follows.
with the following conditions: • P g (t) > 0, i.e. P + g , for power buying from the utility, and • P g (t) < 0, i.e. P − g , for power selling to the utility.

Problem formulations
This study presents three different energy management strategies, namely, baseline, real-time and schedule, which exist in the literature for the use of the community microgrid to measure their efficiency and effectiveness in the presence of uncertainty. For comparison purposes, we have used a baseline method as a point of reference to compare energy management approaches. We have only considered the uncertainty of electricity prices, as it has a significant impact on energy schedule, whereas uncertainty in power generation and demand has no effect due to grid connection facility as demonstrated in our previous study in [18]. The reason is that the battery is charged/discharged based on electricity prices of the grid utility, and the distribution network of the community microgrid has no limit to exchange power with the grid; as a result, power supply and demand has no effect.
In the following subsections, the simple rules of the baseline approach are first described in subsection 3.1 and then optimisation problems for real-time energy management and energy scheduling approaches described in subsection 3.2 and 3.3, respectively, are formulated.

Base-line approach
Simple rules to control the battery energy are used in the baseline approach for managing the community microgrid and therefore this method is easy to implement in practice. However, this method cannot guarantee the optimal operation of the microgrid. The simple rules at each time slot are described as follows [5,22]: • "If the load demand is greater than power generation, then power demand is supplied from the battery.
If the battery cannot supply the required power, then the power is imported from the grid utility." • "If the power generation is higher than the power demand, then the extra power is used to charge the battery while maintaining the charging rate. If surplus power is greater than the charging rate or the battery is already full, the remained energy is exported to the grid."

Real-time energy management
Real-time energy management of the microgrid involves managing energy with respect to measured data of solar generation, wind generation, load demand and electricity prices. As decisions are taken based on real-time measurement, the problem formulation is required to be more balanced to charge and discharge the battery with appropriate time of RTP [20]. This is unlike the problem formulation of an energy scheduling approach.
Therefore, both the charging and discharging terms are included in the objective function as follows: where, where The lower values of the objective function (F RT (t)) refer to discharging the battery energy during higher electricity prices and the hours of low power generation. These also indicate charging the battery during higher power generation and lower electricity prices. These values depend on the command signals, u, of the battery as RESs are operated as maximum power point tracking modes to maximise their benefits. The command signals, u, must fulfil the constraints of battery to avoid premature degradation of the battery capacity. To implement this in the algorithmic process, we have considered only the variables that satisfy the constraints, and discards the solutions that violate constraints with a high penalty cost. As the algorithm works on real-time measurement, it is free from uncertainty in power generation, power demand and electricity prices.

Energy scheduling program
The performance of the scheduling program depends on a problem formulation referring to minimise targeted objective, here the objective is to reduce the operational cost. In our study, the operational cost can be minimised by buying energy during low RTP and selling it at the time of high RTP. This can be achieved using the following formula that is mostly used in the literature [7,25,13]: where C buy is the purchasing electricity price, C sell the selling electricity prices, and P + g the purchasing power from the grid and P − g the selling power to the grid. The first part of Eq. (11) represents the purchasing cost of the power imported from the grid, whereas the second part indicates selling power to the grid for time periods given.

Constraints:
To obtain effective solutions of the optimisation problem, the following constraints must be fulfilled. Energy balance: The power of the microgrid should be always balanced in terms of power supply and demand as follows [22]: As charging the battery is positive value of u(t) similar to a power consumption by load, the u(t) is placed at the right-hand side of the equation.
Battery energy: The commanded signals, u(t), must fulfil the following constraints for extending battery life.
1) "The charging and discharging rates must be within the given limitations, i.e., (P c,max < u(t) < P d,max )." 2) "The energy level of the battery must maintain the upper and lower limits, i.e., BL min < BL(t) + u(t) < BL max ."

Proposed solution approaches
Several optimisation algorithms can be applied to solve the optimisation problem formulated. We have developed modified PSO algorithm to solve both the real-time and scheduling energy management schemes as this algorithm can solve the problem quite faster than other algorithms [5] that helps for the application of realtime energy management. The MPSO algorithm has also demonstrated better performance for the scheduling program than other optimisation algorithms in our previous study [18].
PSO, a population-based optimisation method, has been successfully applied to solve many power system problems [26,27] in recent times. An overview of the PSO along with its performance of different constituents and variants for the use in power system optimisation problems are discussed in [28]. A standard PSO algorithm has mainly two equations for the position and velocity vectors in an N -dimensional solution space [29,30]. The movement and position of each particle i can be represented as v k+1 i and x k+1 i vectors, respectively, as follows: "where v k i and x k i refer to the i th particle velocity for k th iteration in N -dimension and to the i th particle position for k th iteration in N -dimension, respectively; p i and p g are the best position of an individual particle i and the best position achieved among all particles, respectively. In addition, w refers to inertia weight; r 1 , r 2 represent the random numbers of the uniform distribution within the range of [0 1], and c 1 , c 2 are the learning factors used to regulate the best solution." To keep the particle velocity within the prescribed limits, constriction coefficients are used in [31], which regulates the movement of particles to reach in satisfactory solutions. Therefore, modified velocities can be expressed as follows: "where w CF = w × CF , and C 1 , C 2 refer to the cognitive and social components, respectively." The C 1 and C 2 can be represented as follows: where CF = 2 "where CF and φ represent a constriction factor and co-efficient, respectively." The following procedure is applied while evaluating the objective function of each hour [20].  2. Compute the objective function for each particle; 3. Internal iteration start: (a) Modify the velocity and position of each particle according to Eqs. (15) and (14), respectively, with their limits; (b) Evaluate the objective function satisfying all constraints, otherwise impose a penalty factor to discard the solution; (c) Determine the individual best and global best values; (d) Update inertia weight; (e) Continue the process from 3 until the maximum number of iterations is reached.

Solution steps for the scheduling approach
The following steps are proposed for the MPSO algorithm to solve the optimisation problem of energy scheduling approach with the objective function in Eq. (11).
Start: Initialisation 1. Take the parameter values according to Table 1

Simulation results
This section performs the computer simulations of the community microgrid for analysing the results of the three energy management schemes to demonstrate their capabilities in minimising operational cost. The lower operating cost can be achieved by controlling battery energy with respect to RTP while maintaining a balanced power supply in the network in addition to the constraints using EMS. The parameters shown in Table 1 are used for the analysis. Simulations of a two-day energy schedule that makes the optimisation problem complex to solve it are carried out to demonstrate the performance of energy management schemes.

Energy management without uncertainty
In this subsection, different energy management approaches are described with their comparative performance with respect to real-time and time-of-use pricing. Advanced optimisation algorithms are applied to solve the energy scheduling problem with minimum operating cost and thereby to demonstrate the effectiveness of the proposed MPSO algorithm. In addition, the uncertain effects of the scheduling program are also demonstrated to measure the impact of inaccurate prediction in electricity prices.

Baseline approach
This approach works based on sets of rules (i.e., if-else statement) to reduce the operational cost of the microgrid. It provides straightforward actions without guaranteed the lowest operational cost to control the battery energy of the microgrid. Therefore, it is easy to implement this baseline approach in practice. Figure 6a shows the charging-discharging behaviours of the battery. The battery charges during higher renewable power generation than power demand, and it discharges when there is lower power generation than power demand.
Due to the constraints of the battery operation, such as the charging/discharging rate and the upper/lower energy limits, the grid utility requires to supply power to satisfy the power demand of the microgrid as shown in Figure 6b. The convergence curve of the algorithm for an hour is shown in Figure 8. In this method, the operating cost of the baseline approach for two days of energy management is 994.58 cents.

Real-time management
In this method, the data measured are used to find the optimal solutions of the energy management problem using an optimisation algorithm. This algorithm determines the best solution through the lowest value in Eq. (8). The outcomes of this method for charging-discharging cycles of the battery and energy exchange with the grid are depicted in Figure 7 from where it is observed that the battery charges during lower electricity prices and higher power generation than power demand. On the other hand, it discharges at the time of higher power demand than power generation and higher electricity prices than usual. Figure 7b illustrates the energy exchange program with the grid and it is noticed that energy is exported to the grid utility around t = 24 h even after the battery is not fully charged. Similarly, energy is imported from the grid around t = 18 h during discharging the battery energy. This is because of battery constraints that allow only 10% of the total battery capacity at each time step (i.e., one hour), as a result, power is exported to the grid to satisfy the equality constraints. From this method, the operating cost of the microgrid is 791.40 cents, leading to 20.43 per cent saving than the baseline approach. The cost-saving in percentage is determined as follows [22]: %Saving = Reference electricity cost -Measured electricity cost Reference electricity cost × 100.

Scheduling management
The accuracy of data prediction is the main part of a scheduling program as it fully depends on the predicted data and based on this it schedules next actions in the network. If the predicted data change, then solutions  may not work effectively and efficiently. In this subsection, we assume predicted data are precise and thereby the scheduling program works effectively. Figure 9a depicts the energy scheduling of the battery and it is observed that the battery charges at the time of low electricity prices and it discharges during the higher electricity prices. This is because of the attachment of energy exchange with the electricity prices as the problem formulated in Eq. (11). The buying and selling energy is shown in Figure 9b and it is observed that power is imported and exported even after the battery discharges and charges, respectively, due to the battery constraints. The battery commands for the scheduling program are shown in Figure 10. Operating cost of this method is 243.55 cents and the method reduces operating cost by 75.51% as compared to the baseline approach, shown in Table 2. A comparison of the energy management shown in Figure 11 demonstrates that the baseline and real-time methods have a similar pattern, but the scheduling program is different from them. This is because of a predicted long horizon in the scheduling program that works looking at the future. In contrast, both the baseline and real-time approaches act only the measurement of current data. The convergence curve of the scheduling algorithm is shown in Figure 12 and it can be observed that the algorithm converges the solutions within only 50 iterations. This indicates the efficiency of the MPSO algorithm. For further clarifying the capability of the proposed algorithm to solve a complex optimisation problem, in the next subsection, a comparative analysis of several advanced optimisation algorithms are investigated.

Comparative analysis of advanced optimisation algorithms
In this subsection, different types of optimisation algorithms are compared to measure an effective solution approach of optimisation algorithms. Optimisation algorithms are basically compared using the scheduling Objective values (cents) Figure 13: Comparisons of algorithms using box plot for 51 runs. approach as it is difficult to solve as compared to the real-time energy management. Several algorithms were applied to solve the optimisation problem, but only competitive approaches are demonstrated in this study.
Although it is a difficult task to compare different optimisation algorithms, we have tuned the parameters of each algorithm several times to solve the optimisation problem with minimum cost. The population size and the maximum number of epoch for every algorithm are considered thirty-five and one thousand, respectively, to facilitate the same features of all algorithms. As the algorithm takes random seed to generate random variables, we runs algorithms fifty-one times to statistically present the suitability of the proposed method. The number of runs can be determined any value, such as 20 or 30, but the higher number of runs indicate a stable solution approach. In addition, we have chosen odd number to easily determine a median value.    algorithm has shown better performance than other algorithms.

Energy management under uncertainty
This subsection demonstrates the effect of uncertainty on the scheduling program through the introduction of several electricity prices on the predicted data, as our previous study concludes its effect on the scheduling program [18]. Initially, one thousand data with a standard deviation of five are generated using normal distribution process described in subsection 4.1 and then sample reduction techniques described in [39] are applied to reduce the data to only three samples as shown in Figure 14. With these sample data, the cost of the scheduling program for the microgrid is calculated as it is performed using the predicted data and it has no relationship with the current data or error in forecasting and measuring data. In contrast, the real-time and baseline approaches are evaluated based on the sample data of electricity prices due to the fact that they work in current data and therefore are free from uncertainty. The operating costs of the energy management approaches for different electricity prices are tabulated in Table 5. It is found that the scheduling program demonstrates higher cost-saving than the baseline and real-time approaches for all the cases. It should be noted that the operating cost in the scheduling program for price, C t1 , is negative and percentage saving is above 100%, indicating profit rather than saving due to higher power generation at the time of high electricity prices and this was possible because of a long time horizon in this program. If power generation installed is higher  than power demand, then the owner can get this type of benefit. The BL in Table 5 stands for baseline and RL real-time.
To increase uncertain levels into the predicted electricity prices, we have considered a standard deviation of eight of which the negative data are omitted using a conditional statement. The uncertain electricity prices are shown in Figure 15b, with the predicted price marked as red. Simulation results tabulated in Tables 6 demonstrate that the scheduling program has still superior performance as compared to the real-time and baseline approaches to reduce operational cost. From the above analysis, it can be concluded that a scheduling program has higher cost-saving capability even after it is affected by uncertain input data as compared to the baseline and real-time energy management approaches.
To extend the analysis further with the scheduling program, the scheduling method has adopted the un- Electricity prices (cents/kW h)  certain electricity prices and new experimental simulations, called repaired schedule, are carried out with the uncertain prices. Table 7 shows new results from this scheduling program. It is observed that there is a large deviation between scheduling with precise data and with errors in prediction. It is worth noting that in the repaired scheduling, i.e. no error in prediction, operating cost can be reduced significantly. In the case of electricity price, C t6 , the owner can even earn profit out of the scheduling, if the prediction is accurate. Therefore, from Table 7, it can be concluded that the scheduling program get affected with the increase of uncertainty levels (standard deviation 8), numerically on average 119.66% based on three scenarios, where percentage deviation is comparatively higher than the uncertain levels of five standard deviations, numerically on average 20.29%.

Energy management using time-of-use
In this subsection, energy management of three separate methods is performed using TOU to demonstrate their differences in performance. TOU is used in many places around the world to shift load demand from peak to off-peak periods, although this approach may not effectively work when there exists the high penetration of RESs in a distribution network due to uncertainty in their power generation. The TOU price in Australian Capital Territory is adopted in this study to compare energy management schemes as shown in Figure 16. It has three different electricity prices, namely peak, off-peak and shoulder, at different times of the day. The peak price indicates the highest price of the day while off-peak refers to the lowest price of the day. Shoulder    price is located in between the peak and off-peak period. The results of the scheduling program are shown in Figure 17 from where it can be observed that the battery charges during lower electricity prices and it discharges during higher electricity prices to minimise operational cost. The energy exchange with the grid utility is shown in Figure 17b. The profit from this scheduled program under TOU price is 42.55 cents. The results of the real-time and baseline energy management approaches for energy exchange with the grid utility are depicted in Figure 18 and 19, respectively. It is observed that the energy levels of the battery are similar with different operating costs. Their comparative results are shown in Figure 20 and Table 8. It is observed from Table 8 that the scheduling program not only save the electricity bill 100% but also it makes a profit, whereas real-time energy management saves only 23.88% as compared to the baseline approach. This high percentage saving of the scheduling program is because of the known prediction value in advance, where the real-time energy management works only on the current data measured.

Conclusion
This paper develops modified particle swarm optimisation algorithms to minimise the operating cost of a community microgrid by extensively analysing several energy management schemes and proposes the scheduling approach to minimise its operating cost under exposure of uncertain input data. To accomplish the tasks, optimisation problems are first formulated, then separate solution methods using the MPSO algorithms are developed and applied to solve those problems. A comparative analysis between advanced optimisation algorithms and the one proposed in this study is carried out to demonstrate their effectiveness. It is observed that the MPSO algorithm developed has superior performance than other optimisation algorithms to solve the energy scheduling problem. As a baseline method follows simple rules to control the battery energy and a real-time energy management approach works based on data measurement, they are both free from uncertain effects. Although a scheduling program that needs predicting input data to find a solution is prone to uncertain input data, this program demonstrates superior performance even in an uncertain environment over the energy management schemes to minimise the operating cost of the microgrid against other methods. Therefore, it can be concluded that the scheduling program is an effective approach to manage a microgrid's energy under uncertain environments.
In future, the degradation cost of a battery system will be considered in the comparative analysis. In addition, the constraints of a distribution limit will also be considered and thereby an equality constraint in the optimisation problem will be imposed to enlarge the analysis.