###### Abstract  
At present, the integration of microgrids into power systems presents significant power quality challenges in terms of the rising adoption of nonlinear loads and electric vehicles. Ensuring the stability and efficiency of the electrical network in this evolving landscape is crucial. This paper explores the implementation of cascading Proportional-Integral (PI-PI) and cascading Fractional-Order PI (FOPI-FOPI) controllers for a Distribution Static Compensator (DSTATCOM) in hybrid microgrids that include photovoltaic (PV) systems and fuel cells. A novel hybrid optimization algorithm, WSO-WOA, is introduced to enhance power quality. This algorithm leverages the strengths of the White Shark Optimization (WSO) algorithm and the Whale Optimization Algorithm (WOA), with WSO generating new candidate solutions and WOA exploring alternative search areas when WSO does not converge on optimal results. The proposed approach was rigorously tested through multiple case studies and compared with established metaheuristic algorithms. The findings demonstrate that the WSO-WOA hybrid algorithm significantly outperforms others in optimizing the PI-PI and FOPI-FOPI controllers. The WSO-WOA algorithm showed an improvement in accuracy, surpassing the other algorithms by approximately 7.29% to 14.1% in the tuning of the PI-PI controller and about 8.5% to 21.2% in the tuning of the FOPI-FOPI controller. Additionally, the results confirm the superior performance of the FOPI-FOPI controller over the PI-PI controller in enhancing the effectiveness of the DSTATCOM across various scenarios. The FOPI-FOPI provided controller a reduced settling time by at least 30.5-56.1%, resulting in marked improvements in voltage regulation and overall power quality within the microgrid. microgrid; electric vehicles; power quality; DSTATCOM; hybrid optimization algorithms; cascading controller +
Footnote †: journal: Medical  
as solar and wind, promoting environmental sustainability and reducing greenhouse gas emissions [3; 4]. Their potential to operate autonomously in island mode during outages could ensure a continuous power supply for critical infrastructures. Moreover, microgrids can optimize energy usage through advanced management systems, leading to increased efficiency and cost savings. As the demand for reliable, clean, and resilient energy solutions grows, the integration of microgrids into power systems stands as a crucial step toward achieving a sustainable and secure energy future [5; 6; 7]. The integration of microgrids into power systems introduces several power quality issues that must be meticulously addressed to guarantee the stability and efficiency of the overall electrical network. One significant concern is the potential for voltage fluctuations and imbalance [8]. Microgrids, particularly those that incorporate renewable energy sources such as solar and wind, are prone to generating intermittent and variable power outputs. This variability can lead to voltage sags or swells, which can affect the performance and lifespan of sensitive electronic equipment and industrial processes. To mitigate these issues, advanced voltage regulation and stabilization techniques, including the use of dynamic reactive power compensation, must be implemented. Harmonic distortion is another critical power quality issue associated with microgrid integration. The increased use of power electronic devices in microgrids, such as inverters and converters, can provide harmonics to the power network. These harmonics can distort the waveform of the electrical supply, leading to a range of adverse effects, including the overheating of equipment, the malfunction of protective devices, and the reduced efficiency of electrical machines. Effective harmonic filtering and the adoption of standards for harmonic limits are essential measures to address this problem [9; 10].