Application of Improved Sparrow Search Algorithm in Electric Battery Swapping Station Switching Dispatching

The demand for power exchange has risen dramatically as the number of electric vehicle (EV) users has increased, and large-scale disorderly charging will increase the operating costs of battery swapping stations and increase the risk to the power grid. Through experimental comparison with other algorithms on 23 test functions, the results demonstrate that the convergence accuracy and speed of this improved algorithm are superior to those of other algorithms. Furthermore, in solving the optimization problem of EV battery swapping station scheduling, by reasonably allocating the battery pack charging time and establishing the forecasting model of switching demand, the average variance and peak-to-average ratio of the grid are reduced by 29.55% and 13.2%, respectively, based on meeting the user’s switching demand. Approximately a 12,500 RMB reduction in the cost of charging lowers the operation cost and risk of battery swapping stations and enhances the user experience.


INTRoDUCTIoN
Electric vehicles (EVs) have become an important alternative to traditional vehicles owing to their higher energy efficiency and lower emissions, especially with the intensification of the global energy crisis (Tattini et al., 2021).EVs can partially replace the role of a centralized energy storage system in peak shaving, promoting new energy consumption (Goransson et al., 2010), voltage (Kai. et al., 2022), and frequency regulation (Wang et al., 2020).They also contribute to the stable operation of the grid.However, there are still issues, such as long charging times and mileage anxiety, and EVs are uncontrollable loads (Zeng et al., 2020) that may cause issues for the grid, particularly in the event of a limited power supply (Kalla et al., 2019).A battery swapping station (BSS) is less affected by dispatchable time constraints than a charging station (i.e., a BSS is easy to realize centralized management and charging load prediction, etc.).It also can meet the demand of EV users to avoid lengthy charging times and long driving distances, and with the increase of large-scale uncontrolled charging (Hariri, A. M. et al., 2020), its dispatch optimization problem is very important.
By simulating the intelligent behavior of groups in nature, swarm intelligence algorithms are widely used as a very effective method to solve complex optimization problems.They also are widely used in optimization problems related to EV charging and switching station scheduling (Ding et al., 2022).Liu et al. (2019) proposed an opportunity-based constraint-based switching scheduling strategy that was solved by a genetic algorithm to minimize the cost of power consumption at the switching station while satisfying customer switching demand.Tirkolaee et al. (2020) proposed a hybrid strategy based on interactive fuzzy solving and an adaptive ant colony algorithm to efficiently solve the multi-objective model they developed for shop floor scheduling.Jeya Mala D. et al. (2022) proposed an improved artificial bee colony algorithm by employing some cutting-edge improvement techniques, such as "Euclidean distance" and "chaotic mapping," and experimentally validated the algorithm's efficacy.Sultana et al. (2018) applied a locust optimization algorithm to distributed generation and swap station layout and capacity allocation, thereby reducing grid loss and enhancing voltage stability.Li et al. (2023) proposed a fusion algorithm based on an improved genetic algorithm and dynamic windowing method to solve the path-planning problem and enhance the robot's capacity to avoid dynamic obstacles.
Different models and compatible algorithms were used by the aforementioned scholars to solve the problems they posed.For this paper, we used a multi-objective optimization model for charging cost and grid fluctuation of the switching station to reduce the operating cost and operational risk of the switching station so as to better solve the switching station scheduling problem.Nonetheless, we discovered during the optimization process that the solution algorithm adapted to such problems can be improved in a more in-depth manner, and many completed studies in this area have not used the most recent and improved optimization-seeking algorithms to solve them.After testing the whale optimization algorithm (Yang et al., 2023), the particle swarm algorithm (Yang et al., 2023), and the gray wolf optimizer (Ren et al., 2023)-all of which have excellent capabilities-we discovered that they all are superior to the traditional optimization algorithms, but still have typical defects that lead to insufficient convergence accuracy and speed.Therefore, we need to investigate more effective optimization algorithms to solve the problem presented in this paper.Xue et al. (2020) proposed the sparrow search algorithm (SSA), which simulates the social behavior of sparrows.After being evaluated and compared with standard traditional algorithms, SSA demonstrates a number of benefits (Huang et al., 2022;Ouyang et al., 2021).Moreover, despite the fact that the SSA solves BBS optimization problems with a significantly superior search capability than the previously mentioned algorithms, the convergence effect is not significantly enhanced.Given that the BSS scheduling problem requires high solution accuracy and dimensionality and that the relationship between the variables is complex, we proposed optimizing the BSS scheduling problem using an enhanced SSA.First, we proposed an improved sine chaotic mapping to generate highquality initial solutions.We then used a firefly perturbation mechanism to improve the algorithm's global search ability and prevent the population from reaching a local optimum.We also adopted a nonlinear convergence strategy to accelerate the algorithm's convergence at a later stage.We applied the improved SSA to the model proposed in this paper to optimize the switching plant's operating cost and operating risk.

SSA
The SSA is an innovative heuristic optimization algorithm inspired by the foraging behavior of sparrows.The sparrows in the SSA are highly sensitive, exhaustive, and powerfully collaborative; these traits give the algorithm a strong search capability and optimization effect (Fan et al., 2022).The matrix in equation (1) illustrates its initial position: In this equation, n represents the number of individuals, d represents the dimension, and x denotes the initial position of the i-th sparrow in the j-th dimension.The fitness is expressed in equation ( 2): In equation ( 2), f ( Xi ) denotes the fitness value of the ith sparrow.Its members can have three roles: discoverer, follower, and vigilant.The discoverer is responsible for the global exploration of the search space to identify new potential solutions.The follower is transferred to the safety zone if the safety value is less than the alarm value.The position of the discoverer is updated as shown in equation (3): In this equation, R is the current number of iterations, R max is the maximum number of iterations, α 1 is a random number between 0 and 1, and L is a 1-row multicolumn matrix with all elements equal to 1. Q is a random number that follows the normal distribution.r a ∈ [0, 1] is the warning value, and Rs ∈ [0.5, 1.0] is the safety threshold.
The follower position is updated as shown in equation (4): In equation (4), X b and X w represent the best and worst positions, respectively, and A is a 1-row, multicolumn matrix with 1 or -1 elements.Note that randomly generated vigilantes make up 10% to 20% of the sparrow population, and the vigilant positions are updated as shown in equation ( 5 In equation ( 5), β 1 is the step control covariate that follows a normal distribution of 0 or 1, α 2 is a random number between -1 and 1, and β 2 is the minimum constant.Avoid the case where the denominator is 0 when f n = f b .f n , f b and f w represent the current adaptation, the best adaptation value, and the worst adaptation, respectively.

Improved Sine Chaos Mapping
The SSA generates initial sparrow populations in the exploration domain at random, possibly resulting in an uneven distribution of sparrow populations and an insufficient exploration domain.Chaos, with its ergodic and random nature, can solve these problems very well (Feng et al., 2017).Chaos is frequently employed in optimization search issues.Tent and logistic maps are the most frequently employed chaotic models, but they have a finite number of mappings.In contrast, the sine model is infinitely mappable.The sine model has superior chaotic properties compared with the logistic model, which is represented by the mathematical expression shown in equation ( 6): In equation ( 6), x n is the current sparrow position, and a is the mapping factor.
Because the typical one-dimensional sine mapping generates a random sequence with an unbalanced distribution in the phase domain and is slightly narrower in the parameter domain of chaotic states, we propose the improved sine chaotic mapping shown in equation ( 7): In equation ( 7), x n represents the current sparrow position; a is the mapping coefficient, which typically takes values in the range of 2.3-4.0; and γ is the interference coefficient, which typically takes values between 0 and 1.Compared with the standard sine mapping, the improved sine mapping adds an interference term γ to increase the randomness and diversity of the mapping and the search area.The test results indicate that the distribution is especially well balanced when a = 3 and γ = 1, and the chaotic effect is excellent, as depicted in Figure 1.Consequently, in this paper we optimize the initial population by means of an enhanced sine chaotic mapping.

Firefly Interference Strategy
The core concept of the firefly interference strategy (Cheng et al., 2023) is to introduce a certain degree of random perturbation into the search process to increase the diversity and randomness of the search, thereby preventing the use of local optimal solutions.During the movement of sparrows, a proportion of firefly positions are selected at random, and their positions are used as the source of disturbance to increase the diversity of the current sparrow positions.At the end of the algorithm, the population will be forced to leave the region farthest from the fitness value to determine if it is the optimal value.Equation ( 8) displays the firefly's luminosity L and attraction r: In equation ( 8), f (Xi) is the fitness value (i.e., luminance), γ max represents the maximum attraction between individuals, μ represents the light intensity coefficient, and l A,B is the distance between two individuals.When A is attracted to B, the position of A is under the expression shown in equation ( 9): In this equation, X A and X B represent the positions of A and B, respectively.λ ∈ [0, 1] is the step factor, and α 3 is a uniformly distributed random number between 0 and 1.The position of the brightest individual S is updated as shown in equation ( 10): In equation ( 10), X S is the brightest individual position.Equation ( 10) prevents the firefly from falling into the local optimum prematurely to some extent.It will direct the sparrow to the optimal position and enhance the global search performance.

Nonlinear Convergence Strategy
The search speed of the population in the SSA is typically linear and decelerates as the number of iterations increases.To solve this issue, a nonlinear convergence strategy (Na & Long, 2022) can be implemented to accelerate the search and enhance the algorithm's performance by using the formula shown in equation ( 11): From Equation ( 11) and Figure 2, we can determine that at the beginning of the algorithm, the slope of the function is small, which slows the rate of decline of c and improves the algorithm's ability to search for the global optimal solution; at the end of the algorithm, the slope of the function The following steps describe the GSSA algorithmic procedure: 1. Configure the algorithm's parameters, including the number of individuals N in the sparrow population, the dimension D of the sparrow population, and the number of iterations T of the algorithm.2. Use the chaotic sequence method described by Equation ( 7) to initialize the location of the sparrow population in the spatially feasible domain.3. Incorporate each member of the current population into the objective function to be optimized, calculate the magnitude of their fitness value, and rank them.4. Compute the size of parameter c in the current iteration and update it using the nonlinear convergence strategy shown in Equation 11. 5. Determine the disturbance of the sparrow update locations using the updated Equation ( 10) and the calculation and ranking of fitness values for the updated populations.
Note: If the iteration termination condition is met, the current optimal individual's position information and the size of the fitness value are output, and the algorithm ends; if the algorithm's end condition is not met, we go to step three, and the iteration continues.
Figure 3 shows a summary of the GSSA steps based on sine mapping and firefly interference strategy.

Algorithm Performance Testing
For this paper, we used the more prevalent Competitive Evolutionary Computation (CEC) test functions for performance testing (Luo et al., 2022)   According to the convergence curves, GSSA is superior to other comparable algorithms in terms of convergence speed and solution accuracy.In both the single-peak and multi-peak test functions, the proposed GSSA offers clear benefits.The lower the fitness value is, the higher the search accuracy is; the first inflection point, the faster the solution speed.We demonstrated that the proposed improved sparrow search algorithm can enhance the algorithm's global search performance, prevent premature convergence, and prevent the sparrow population from falling into the local optimum when determining the optimal solution.

CHARGING SCHEDULING MoDEL FoR SwITCHING STATIoNS optimization Variables
To achieve the economic efficiency of the BSS and the stability of the power grid, ensuring the normal demand for vehicle power exchange and charging the battery pack to meet the power exchange demand [-1.28, 1.28] 0 Non-fixed dimensional multimodal standard functions ) Table 1.Continued continued on following page of the road network's users are necessary steps.Consequently, the optimal time to begin charging can be determined.To develop a more refined charging schedule, a day is taken as a cycle, and a 24-hour day corresponds to a time between 0 and 1,440 min.Furthermore, we conducted a modeling study for the BSS by optimizing the start charging time of each battery as a decision variable, reducing the charging cost, and smoothing the load curve as multiple objectives to optimize the start charging time of each battery pack (Figure 5).The model addresses each objective function using the two primary aspects listed below.

objective Function
The main influence on the charging cost of BSS is the electricity price.The objective of the economic operation of BSS is to minimize the charging electricity cost, and the objective function based on the existing time-sharing tariff is shown in equation ( 12): In equation ( 12), P(t) is the power of the charging station corresponding to each time point in kW, and each integration interval is the range of the corresponding time period (in min); p 1 , p 2 , and p 3 are the electricity prices in low, flat, and peak hours, in yuan/kWh, respectively⋅

Algorithm
Parameter Setting The average variance and peak-to-average ratio reflect the load fluctuations and the grid operation.

Mean Square Error and Minimum Objective Function
The mean square error and minimum objective function can be calculated using the formula shown in equation ( 13).

Minimum Peak-to-Average Ratio Objective Function
The minimum peak-to-average ratio objective function can be calculated using the formula shown in equations ( 14) and ( 15).In equation ( 13), K 21 is the grid fluctuation function.In equation ( 14), K 22 is the peak-to-average ratio function, P av is the optimized completed daily average load, P Wi is the base load of the BSS regional distribution network at time I, and P Ki is the BSS charging power at time i.
Because the difference between the aforementioned two objective functions is too great, F 1 and F 2 are normalized and normalized and weighted, respectively, and the obtained resulting function expressions are shown in equations ( 16) and ( 17).
In equation ( 16), F 1 is the objective function after normalized weighting treatment of charging cost, and in equation ( 17), F 2 is the objective function after normalized weighting treatment based on distribution network load fluctuation and peak-to-average ratio.K 21 and K 22 represent the values of regional load mean squared difference and peak-to-average ratio after optimization, and K 21O and K 22O represent the values of load mean squared difference and peak-to-average ratio under base load, respectively.α 1 and α 2 represent the weighting coefficients of each objective function, and their values can be determined by the entropy weighting method or selected independently by combining the situation using hierarchical analysis and α 1 + α 2 = 1.

Constraints
The constraint condition is the linchpin of this model.The upper limit must comply with the maximum power permitted by the regional grid load to ensure the grid's safe operation.In contrast, the lower limit is intended to accommodate the switching demand load.On the basis of meeting the user's switching demand, the switching station can arrange the battery pack charging time more reasonably, reducing unnecessary resource waste and better reducing the switching station operation cost and regional load fluctuation.

Charging Power Constraint
To calculate the charging power constraint, use the formulas shown in equations ( 18) and ( 19).In these equations, P Ki min and P Ki max are the minimum and maximum charging power that the BSS can supply on behalf of the i time period.P Kih max is the maximum charging power that all batteries in the BSS can withstand in the i time period.PKic max is the power delivery capacity of the distribution line or distribution transformer capacity in the BSS location area in the i time period.PKim max is the maximum charging load power of the BSS in the i time period, which is P Ki min , and P K i max.P K ih max is the minimum value.

Charging Power Constraint
From the analysis of the temporal characteristics of the BSS power exchange demand in the road network model, we can determine the constraints on the BSS charging power for each time period, as shown in equation ( 20): In equation ( 20), Q i is the battery charging power in time i.Q i min and Q i max are the minimum and maximum power that can be achieved in time i to satisfy the power exchange demand.
By weighing the objective function of the model presented in the previous section and integrating it with the constraints, the BSS charging scheduling optimization problem is formulated as shown in equations ( 21) and ( 22):

Experimental Data
For this paper, we used the core area of a northern city as an example, constructed a road traffic network model with reference to its main backbone road network and the node relationship between roads, and divided the entire area into 27 areas of residential area (H), work area (W), shopping area (S), and functional area (F), as shown in Figure 6.The triangle represents the location of the exchange station.
We used MATLAB to simulate the EV within the road network as the study object.The parameters of the model are set as follows: • The maximum capacity of the distribution network in the area is set to 3,500 kW.
• The number of EVs is 4,000, the load has 1,440 sampling moments per day, the simulation runs for 14 days, and the average value of the total load for 14 days is taken as the EV charging load.• The maximum capacity of the batteries in stock at the BSS is for 500 groups, the time required for the exchange process is 10 min, and the number of chargeable interfaces is 200 at the same time.• Battery capacity reference existing electric car brand BYD Han pure electric models for 76.9 kW*h; charging efficiency is 0.9.Charging power is 7 kW, and energy consumption per unit mileage is 0.13kw*h/km.
On the basis of previous research, using Ministry of Statistics and Transportation data (Wang & Renne, 2023) and simulating the trajectory of 4,000 electric vehicles in the road network using the Monte Carlo method, the EV begins to find the power exchange station when the power is below 10%, subtracts the power consumed in the road until the completion of the power exchange, and then calculates the regional consumption load of each exchange station via Dijkstra's shortest path algorithm that is the constraint exchange demand load discussed in the "Charging Power Constraint" section (Figure 7).
Consider a typical exchange station in the core of the road network as an illustration.According to statistics, the number of EVs in the area is about 500.Take one day as a dispatching cycle.EVs begin to go to the exchange station when the power is less than 10% and subtract the power consumed on the road until they complete the exchange.After getting the load of the user's exchange demand, the exchange station can arrange the battery pack charging time more rationally, based on satisfying the user's exchange demand.This step reduces the needless waste of resources and has the potential to reduce the power exchange station's operating expenses and regional load fluctuations.For this paper, we charged the battery using the constant power method.Figure 8 depicts the base load of the regional distribution network, and the time-sharing tariff refers to the typical city tariff.The objective function F weights α 1 , α 2 are taken as 0.5, 0.5, and λ 1 , λ 2 are taken as 0.6, 0.4 respectively.The MATLAB simulation environment specification is a Core i3-4150 CPU running at 3.50 GHz with 12 GB of RAM.

Experimental Results and Analysis
With a population size of 60 and using 200 iterations, the proposed GSSA is applied to the objective function.Figure 9 provides a comparison of the PSO, the WOA, and the GWO.This optimization scheduling on GSSA and SSA is found to be more efficient than other algorithms.In the early and middle stages of PSO, WOA, and GWO algorithms, the solution falls into a local optimum, and the accuracy of solving this problem is lower than with other algorithms.GSSA and SSA demonstrate their superior performance by solving this problem.Compared with SSA, GSSA has the following advantages: • At an early stage of the solution, sine chaos mapping is introduced into the location update for the problems of uneven distribution of sparrow population and insufficient search space to exert its perturbation ability.• In the middle of the solution, a certain proportion of firefly locations are randomly selected, and their locations are used as the source of disturbance to perturb the current sparrow locations to increase the search diversity.• At the conclusion of the solution, a portion of firefly locations are chosen at random, and their locations are used as the source of disturbance in order to increase search diversity.Through the nonlinear convergence method, the slope of the convergence coefficient gradually increases at the end of the solution, which improves the local search performance in the arithmetic solution process and the curve convergence effect.Taking the optimal target value in the preceding test as the optimization result, we simulated the disorderly charging load curve of the switching station and compared it with the optimized load curve of GSSA.We also gave the charging allocation time of each battery pack of the decision variable in the scheduling model of the switching station in one day.The results are depicted in Figures 10-12, respectively.According to the simulation results, disorderly charging will increase the peak of the BSS load wave and result in the phenomenon of "peak on peak."In contrast, orderly charging scheduling with GSSA optimization improves the load characteristics of the distribution network and achieves the effect of "peak shaving and valley filling."Unlike disorderly charging, the orderly charging strategy allocates the charging time for each battery pack rationally and prioritizes times when the regional load is lower and the charging cost is less expensive.It effectively avoids peak on peak, reduces switching station operating costs, improves grid stability, and demonstrates the efficacy and superiority of the GSSA model in resolving this issue.

CoNCLUSIoN
Environmental protection and the energy crisis have always been the primary concerns of the international community.EVs are gaining popularity owing to their greater energy efficiency and reduced emissions.The emergence of EV exchange stations satisfies the demand of EV drivers to avoid lengthy charging times and long-distance driving and is becoming an increasingly significant EV energy replenishment location.However, as the number of EV users increases, so does the demand for power exchange.Large-scale disorderly charging will increase the operating costs of the exchange stations and exacerbate the fluctuation of the power grid, elevating the significance of the scheduling optimization problem.We modeled the optimal scheduling problem of EV charging and switching stations, and we used the swarm intelligence algorithm to solve the problem.In light of the deficiencies of the existing swarm intelligence algorithm in solving this problem, a refined SSA was proposed and applied to the optimal switching station scheduling problem.Using experimental cases, we showed that the algorithm is superior to the existing swarm intelligence algorithm in terms of searchability and convergence speed, as well as its ability to solve the switching station scheduling problem.By establishing a road network traffic model to calculate the switching demand load, we found that it is more reasonable to arrange the charging time of each battery pack based on the need to meet the normal switching of users and reduce the operation cost and regional load fluctuations so as to better solve the switching station scheduling problem.The problem was solved more effectively, enhancing the algorithm's performance.In this paper we shared how we enhanced the SSA and developed an optimal switchyard scheduling model.Although the experimental results are more satisfactory, there are a few flaws, such as the lack of comparison with more advanced algorithms and the absence of a comprehensive analysis of the model's weights for multi-objective functions.This will be considered in the future, thereby optimizing the switching station dispatching system for improved performance and outcomes.

Figure 5 .
Figure 5. Schematic diagram of the charging load of the switching station

Figure 6 .
Figure 6.Road network area distribution map

Figure 8 .
Figure 8. Original load map of the switching station

Figure 9 .
Figure 9.Comparison of the optimization of the fitness values

Figure 11 .
Figure 11.Optimized charging time allocation for each battery pack to validate the problem-solving effectiveness of SSA algorithms.CEC test functions are a classic set of optimization problem test functions.The benchmark test function curves provide a good indication of each algorithm's convergence speed and accuracy, as well as a visual representation of the algorithm's ability to leave the local region.In solving the 23 CEC 2021 test functions listed in Table 1, the original SSA, particle swarm algorithm