## 4 Simulation and Results  
The main objective of this article is to find the optimal solution to improve the power profile and cost-effectiveness. Fuzzy logic utilizes sets and reasoning, offering user-friendly comprehension. It excels at solving complex problems that pose challenges for an alternative system. Fuzzy logic delivers precise outputs, particularly when handling imprecise or inaccurate data. In this research, the above stages should be implemented using a power and an EMS that continuously monitors the system's status and controls the power flows. The Yalmip toolbox [45] is utilized to resolve the optimization problem, whereas the PSO technique is implemented in this article. The primary advantage encompasses more straightforward algorithm implementation, reduced parameters adjustment, and rapid convergence speed [46]. The optimization technique has been developed using a MATLAB/Simulink model. PSO exhibits numerous benefits over traditional optimization techniques, notably its fast convergence [47]. In this paper, input given in the simulation process comprises the financial facts, daily solar radiations, wind speed in m/s, and the load. The made-up peak load of consumers on the MG is about 2 MW. The average solar radiation, wind velocity/speed, and load of each consumer (p.u.) are revealed in Table 2. The capital costs of each DER unit are derived from [48; 49; 50], and a summary of these costs is provided in Table 3. Optimum size for each unit is given in Table 4.  
The methodology, based on fuzzy rules and PSO, is implemented for optimizing MG systems. It involves integrating various inputs into an algorithm, considering technical system constraints, and assessing both economic and technical outcomes. The rule-based fuzzy system operates with two inputs: the system's voltage and the power produced by the system. Prior to evaluating the outcomes, specific rules are established. These rules include defining upper and lower limits for the inputs, ensuring that the system's outcomes remain within these predefined limits. The fuzzy controller's parameters include membership functions that are triangular, range of power of about \(-20\) to \(20\) units, range of voltage in the proposed system of \(-10\) to \(10\), proposed distribution that is medium, \(25\)-rule base, and a defined output range of \(-20\) to \(20\). These parameters were meticulously chosen based on various considerations, and were specifically designed to improve power quality by regulating power and voltage, ensuring optimal system performance. Moreover, PSO have been employed during the parameter-selection process to strike a balance between complexity and effectiveness. Figure 9 illustrates the rule-based surface area with distinct colors for identification. The bluish areas indicate the most feasible outcomes achieved by the system, while the reddish areas represent less favorable scenarios, which may suggest faults or non-convergent values within the system. The optimization process follows a detailed, step-by-step algorithm, as depicted in Figure 10. The PSO convergence characteristics with respect to the cost obtained in the optimal strategy of the MG system is exposed in Figure 11. The optimal solution is found just after a hundred iterations. Figure 10: Step-by-step algorithm of PSO. Figure 9: Rule-based surface area of the proposed system. The latter half of the research focused on voltage convergence within the hydrogen-based microgrid. PSO is utilized to optimize the power at each level. Figure 12 presents the optimized output characteristics of RESs. Voltage level of each RES has significant value to serve the demand with less instabilities, as the power profile is a crucial consideration in the research. Once the power quality is well-established at the main source of generation, the entire energy storage system can reap benefits. The FCs consistently provided a reliable current to meet consumer demand during periods of power scarcity in RESs production.