## 3 Methodology
### Optimization Method  
The optimization method employed in this study is the particle swarm optimization (PSO) algorithm [39; 40], a widely recognized metaheuristic algorithm known for its rapid convergence. In this research, the PSO algorithm seeks the optimal values for the expectations and standard deviation of Gaussian membership functions to determine the best references for the current of the battery, supercapacitor, and OVD components. The algorithm operates by searching for optimal values that minimize the objective function. This function, as explained earlier in (1), comprises two components: one for ripple minimization and another for reducing the number of EV battery activations. The proposed PSO-based fuzzy controller is implemented based on the Algorithm 1. ```
1. Determine the PSO parameters. 2. Define boundaries for the expectation and standard deviation of each membership function. 3. Initialize the fuzzy inference system (FIS). 4. PSO updates the positions and velocities of each population. 5. PSO executes DC microgrid model and provides it with a new FIS. After simulation, PSO calculates the objective function value. 6. If the results from this new FIS can minimize the cost function more effectively than the results from other populations, it should be saved as the best solution among all population results. 7. If the stop condition is not met, go to step 4. 8. Print the results. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**Rules** & \(\



## 4 Simulation Results

In this section, we present simulation results of our proposed PSO-based fuzzy controller on a DC microgrid, comparing it with two conventional controllers to demonstrate its efficiency. ### Initialization and Fuzzy Optimization

To start simulating the DC microgrid, we require the values of the parameters of this system. Initially, a model of the DC microgrid is implemented in MATLAB/Simulink 2022, and the associated parameters are as follows:

\[C =20\times 10^{-6}\quad\text{(Used in ballast)}\] \[R =50\quad\text{(Used in ballast)}\] \[L =0.001\] \[R_{Bi} =0.2\quad\text{(Battery resistor)}\] \[L_{B} =0.0011\quad\text{(Inductance for battery converter)}\] \[R_{Bb} =\frac{0.4}{4}\quad\text{(Resistor of inductance for battery converter)}\] \[V_{BBase} =47.2\quad\text{(Battery base voltage)}\] \[C_{B} =3000\quad\text{(Capacitor capacity for the battery)}\] \[C_{C} =150\quad\text{(Ultra capacitor (UC) capacity)}\] \[L_{C} =0.0011\quad\text{(Inductance of converter of UC)}\] \[R =50\quad\text{(Used in ballast)}\]0 \[R =50\quad\text{(Used in ballast)}\]1 \[R =50\quad\text{(Used in ballast)}\]2 \[R =50\quad\text{(Used in ballast)}\]3 \[R =50\quad\text{(Used in ballast)}\]4 \[R =50\quad\text{(Used in ballast)}\]5 \[R =50\quad\text{(Used in ballast)}\]6 \[R =50\quad\text{(Used in ballast)}\]7

To design the PSO-based fuzzy controller, we utilized the PSO algorithm to optimize the parameters of the fuzzy controller. The convergence diagram of the PSO algorithm is plotted in Figure 9 to illustrate how effective the algorithm is at optimizing fuzzy controller parameters. To provide a comparison between the fuzzy membership functions before and after optimization through PSO algorithm, these results are shown in Figures 8 and 10. \[R =50\quad\text{(Used in ballast)}\]8 The value for load consumption and resource production. \[R =50\quad\text{(Used in ballast)}\]9 Membership functions for the EV’s battery, ultracapacitor, and OVD after optimization. \[L =0.001\]0 Convergence of objective function. ### Ripple Minimization

One of the main objectives of this research is to minimize the voltage ripple in the main bus. In this section, we will explain this objective further to demonstrate the effectiveness of our proposed controller compared to the two other controllers. The voltage ripples of the system in the presence of three introduced controllers are shown in \[L =0.001\]1 As can be seen from this figure, the regular fuzzy controller is the most inefficient in ripple minimization.