###### Abstract
One of the popular optimization techniques that have been incorporated in solving the EMS problem is dynamic programming (DP). The main advantage of this method is its ability to divide the EMS into smaller sub-problems. This means that the optimization  
Figure 1: Example of a microgrid with an energy management system (EMS) based on Harris hawk optimization (HHO) proposed in this paper. technique will solve sequential problems instead of solving one sophisticated problem, which helps in reaching the optimum solution with quick and accurate performance. However, the operation of this algorithm is considered difficult since it includes a high number of recursive functions [14]. In [15], a genetic algorithm is used in optimizing the EMS's objective function. This method has better computational burden when compared to LP. However, still the computational complexity exists. Multi agent (MA) optimization has gained great researchers attraction in solving the EMS optimization problem. Although this method has relatively high accuracy considering many constrains, it suffers also from high computational complexity and time [16; 17; 18; 19]. Particle swarm optimization (PSO) has attracted many researchers as well to use it in the optimization of the EMS problem. This method showed better results compared to previously mentioned methods in terms of accuracy and computational burden [15; 20]. In [21], authors proposed the artificial bee colony (ABC) to solve the EMS problem. Although this method is considered quite simple and has robust performance, the formulation of the EMS problem to adapt between it and the algorithm is considered complex as this technique is suitable for objective functions that do not have high number of parameters. This technique has directed many researchers to use various meta-heuristic optimization algorithms such as grey wolf optimization (GWO) [22], evolutionary algorithms (EA), etc. Another research direction led by many researchers depends on coordinated control. In [23] a coordinated controller for a microgrid based on a predictive model and voltage control is presented. The main advantage of this method is that it needs less effort in the tuning of the controller. Authors of [24] also proposed a multi-layer coordinated control technique for the energy management of microgrids based on forecasting customer loading. Furthermore, another method of coordinated control is presented in [25]. This method depends on bi-level stochastic modelling. Most of papers mentioned in literature have suffered from drawbacks (particularly in the modelling of the system) that can be summarized in the following points [11; 12; 15; 21; 22; 26; 27; 28; 29]:  
* Power losses are not taken into considered in some papers. * Battery charging and discharging intervals are not considered in some papers. * High computational complexity in some of the above indicated references. In this paper, the Harris hawk optimization (HHO) is used in solving the EMS optimization problem in a grid connected microgrids. The algorithm is applied to a highly constrained objective function which takes into consideration many important constraints such as power balance, generation power capacities, spinning reserve and energy storage limits (including charging and discharging rates). The proposed algorithm shows an improved performance compared to other algorithms used previously in literature in terms of speed of convergence and minimization of cost of operation when compared head-to-head and applied to same test bench. The proposed HHO algorithm may form a good optimization technique for solving other optimization problems in the power and energy fields. The rest of this paper is organized as follows: Section 2 shows the problem formulation of the EMS optimization problem, while Section 3 explains the HHO algorithm and its application to the proposed EMS optimization algorithm. In Section 4 the results of applying the proposed EMS optimization algorithm to a real microgrid with two different operating scenarios are presented.