## 1 Introduction  
The present power system is found to have a revolutionary change in terms of using the resources for energy generation. The main difference between the present and the traditional power system is using distributed energy sources (DES), such as renewables and energy storage options compared to conventional energy resources. The DES penetration to the power system is relatively high in recent years, which has enabled the power system to transition towards achieving sustainability and, at the same time, ensuring resilience operation [1]. In addition to sustainability and resilience, the changes made in the power system are found to have more benefits in several situations. These include the ease in energy transaction and sharing facility, reducing power losses over long transmission lines, and reducing the amount of investment necessary to construct new power transmission lines [2; 3]. Moreover, DES would help to decrease the effects of climate change and the gradual depletion of energy sources (coal, gas, and oil), dealing with the steadily increasing consumption of energy, satisfying the need for local economic and social development. The DES bears low power generation efficiency, high capital cost, deficiency to be dispatched from the centralized control center, and intermittency in the output power [1; 4]. The DES, consisting of the non-conventional sources like photovoltaic (PV), wind turbine (WT), and battery energy storage system (BESS), are incorporated to form the microgrid (MG) [5], which are interfaced to the power system and may actively operate on both grid-interactive and islanded condition [6; 7]. PV and WT systems support each other during a day cycle. Solar energy, having more potential during sunny days and strong winds, mostly occurs during the nocturnal period. Usually, strong winds are noticed in the course of the nighttime and cloudy days in contrast to weak winds that occur during bright days. Irrespective of their erratic behavior and demerits, WT, and PV systems provide energy to load with greater reliability and uninterrupted supply with reduced emissions [1; 4; 7]. The MG is interfaced with the power system through a hybrid shunt active power filter (HSAPF) [8]. HSAPF supplies the compensating current [9; 10] at the point of intersection (POI) and controls the power injection to the grid. The battery at the direct current (DC) bus confirms the power balance during a change in solar power and wind power generation concerning load demand. During less load demands and high renewable power generation, the BESS charges to collect surplus renewable energy. On the other side, with less renewable power generation and high load demands, BESS discharges for compensating the shortage of load demands. However, to maintain the stability of the system during long periods of excess power generation and less load demands, which results in top-up the BESS, a dump load is switched on at DC bus. Generally, MG runs in association with the power system. During this condition, the exchange of power takes place between the MG and the power system. However, in case any abnormality arises in the power system, the MG can effectively work in an islanded condition [11]. The power generation in this condition must balance the load demands. During power balancing, the islanded condition may face issues related to operation and control. Therefore, an advanced controlling technique must address the power quality (PQ) problems arising during the integration of MG with the power system through HSAPF and can effectively work at both grid-interactive and islanded conditions. During grid-interactive conditions [12], MG frequency and voltage at POI are performed through the grid. MG manages the active and reactive power produced by the DES units, and it is its primary role [13; 14]. While during the islanded condition [15], the MG voltage and frequency are controlled through DES. The electric grid no more supplies the voltage and frequency variables.