Abstract

Battery swapping stations effectively address the challenges of long charging times, lack of charging stations, and safety hazards for electric two-wheelers. With the rapid development of shared electric bicycles and takeaways, the scale of electric two-wheeler users is expanding while generating a huge demand for battery swapping. The research on the planning and operation of battery swapping stations (BSSs) for electric two-wheelers has yet to be widely discussed. This study developed a data-driven optimization model based on machine learning algorithms using Beijing’s battery swapping stations and point of interest (POI) dataset. First, through the spatial features of BSS analyzed by ArcGIS, we found that the coverage of BSSs was mainly concentrated within the fifth ring road, and the utilization rate was unbalanced. Then, on a 3000 m grid scale, a prediction model of BSS quantity with random forest, support vector regression, and gradient-boosting decision tree algorithm was built. The final stacking model was constructed by strengthening three single models with an accuracy of 86.21%. Compared with the original BSSs layout, the machine-learning algorithm proposed in this study can cover more factors and avoid the subjectivity of site selection. Finally, the queuing model for BSSs based on the Monte Carlo simulation was proposed. Through two scenarios, we found that the key parameters (the number of charging slots) and (the user arrival rate) were influential to the outputs of service capability.

1. Introduction

Under the dual constraints of resources and the environment, promoting low-carbon travel is the key to achieving sustainable development of the environment. Electric two-wheelers (E2Ws) have become a widely used sustainable transportation policy tool for short-distance trips [1, 2]. EVTank (China Yiwei Institute of Economics) reported that China’s electric two-wheelers sales had reached 49.8 million in 2021 (Figure 1). As of October 2021, Beijing has 3.333 million E2Ws with legal licenses. There are two main user markets for E2Ws, namely, personal users and business fields, such as takeaway delivery [3]. The rider in the distribution industry is the fastest-growing force in the E2Ws army and is also the high-frequency user of the E2Ws battery. Figure 2 shows the user size of online food ordering in China. Up to December 2021, the user size of online food ordering had reached 544 million. According to the survey, there are about 54,000 food delivery riders in Beijing, and one million orders are delivered daily. 68% of diners order takeout food every day [4]. At the same time, the type of order also determines that most of these orders are delivered by E2Ws. The Internet report shows that the takeaway platform is still dominated by catering, accounting for about 97%. Catering takeaway orders are in high demand and have a strict time window [5]. The delivery rider will be punished if he goes over time. Therefore, to complete the order pickup and delivery quickly, riders must choose a convenient means of transportation. Compared with cars, which face traffic jams and cannot stop at any time, or motorcycles, which need to apply for many certificates, E2Ws have fewer constraints. Thus, E2Ws are still the first choice for food delivery riders to carry out their work.

A limited range is an important factor hindering the development of the electric vehicle industry [6], and it will also affect the work efficiency and income of the delivery worker. The most common electric two-wheeler range is 60 kilometres, while a takeout delivery rider travelled 120 kilometres on an average per day, which is entirely unsatisfactory. So the rider needs to recharge the battery. At present, there are two charging modes for E2Ws. The first is traditional plug-in charging. Plug-in charging takes more than 8 hours, which is quite time-consuming [7] and reduces business efficiency. Fire hazard is also a problem in traditional charging mode. Due to the lack of charging facilities in domestic communities, some users will charge their batteries at home, which creates a huge safety hazard. Finding a charging station and prolonged charging times are two significant concerns encountered by most E2Ws users. Therefore, battery swapping shows up. In a nutshell, battery swapping saves the waiting time during the charging session and exchanges the discharged battery for a fully charged one [8]. The battery charging time can be shortened to between 1 and 2 minutes [8]. Battery swapping brings higher efficiency and a safer user experience for customers.

Initially, battery swapping stations are designed for electric vehicles. It refers to the rapid recovery of electric vehicle energy by replacing batteries when they are about to run out [9, 10]. In 2011, Israel’s Better Place first promoted battery swapping in Denmark. Tesla, an American electric vehicle giant, also launched a pilot project for replacing electric vehicles [11, 12]. China’s Nio built its first battery swapping station for private users in Shenzhen in 2018. Driven by the practice of battery swapping in electric vehicles, China and Southeast Asia are seeing a flourishing battery swapping market for E2Ws [13]. Successful companies to adopt the model include Gogoro in Taiwan, China Tower, and E-Huandian in Mainland China. Figure 3 shows the process of a battery swap for E2Ws users. Locating swap stations is made simple via a mobile app that connects to the vehicle. This app alerts riders when their battery is low and will give them directions to the nearest swap station. Drivers can head to a swap station multiple times a day to replace their discharged battery with a new, fully charged one, all of which takes place in less than two minutes.

For personal users, the driving range of E2Ws is relatively short, and the demand for battery swapping is mainly concentrated in the food delivery industry. To satisfy the battery swapping demands, BSS operators must build enough swapping stations. As shown in Figure 4, for example, the BSS in Beijing has an uneven utilization rate at peak times. It reflects that operators may build more BSS in low-demand areas, resulting in a waste of resources. Battery swapping demand is affected by the demand for takeaways. Therefore, it is possible to find the relationship between the points of interest (POI) that may generate takeaway demand and the layout of the BSS. In addition, BSS operators also need to make trade-offs between service capacity and operating costs. Essentially, BSS operators need to find answers to the following three questions when providing battery swapping services for E2Ws: (1) What are the behavior patterns of battery swapping by E2W users? (2) How to deploy BSSs? (3) How many services can BSS provide to E2Ws users?

To address these three problems, this study aims to develop a data-driven approach to deploy BSSs. The rest of the article is outlined as follows: A general overview is presented in Section 2. Section 3 offers the research dataset. Then, Section 4 presents the research methodology, including data analysis, machine learning algorithms, and a queuing model based on Monte Carlo. A case study and sensitivity analyses are presented in Section 5. Finally, in Section 6, some conclusions and suggestions are given.

2. Literature Review

Electric two-wheelers (E2Ws) are defined as two-wheeled vehicles with electric propulsion [13]. In Taiwan, there are 13.7 million scooter users [13]. To improve air quality, Taiwan is dedicated to increasing the penetration level of electric two-wheelers. Gogoro proposed the battery swapping system in 2015 [14], which overcomes the limitations of E2Ws, such as shorter driving range, long charging time, and inconvenient charging [15]. The questionnaire survey found that more than 80% of the respondents believe that the BSS is efficient and willing to accept it [13, 16]. Operators expect to provide services to E2Ws users involved in the issue of how the BSS facilities could be located. In this study, CiteSpace has been selected to analyze the relevant literature on E2W’s battery swapping station. Currently, the research on E2Ws is mainly divided into two parts (Figure 5). One is related to technology, such as vehicle design and battery technology, and the other is social interaction, such as traffic accident rate, the impact of energy consumption, and the user’s perception of E2Ws. Only a few studies have been conducted on the siting of battery swapping stations for E2Ws.

2.1. Optimization-Based Models

Zhu and Pei [17] developed a simple deterministic location model for E2Ws battery swapping stations to reduce construction and user access costs. The frequency, restaurant, and timing of our online ordering are all uncertain, making the battery swapping demand for delivery drivers equally uncertain. Therefore, the BSS location problem could be expanded to stochastic circumstances. The uncertain events were presented as specific probability density functions (PDFs). A Monte Carlo simulation-based approach was repeatedly conducted through random sampling from the PDFs to resolve the stochastic location problems [14]. E2Ws are not limited to daily life scenarios and can be further considered for urban tourism activities [18]. Each travel demand is associated with a trip chain, and the time-space networks are a valuable method for modeling conveyance movements in terms of time and space. The model is formulated as an integer network flow problem to minimize the total long-term cost. Since this model is characterized as NP-hard, we used a problem decomposition technique coupled with the mathematical solver CPLEX to solve the model [19].

E2W’s battery swapping station site selection is similar to the electric vehicle swapping station location problem. Traditional network location problems (coverage problem and P-median problem) assume that the demand and siting points are located in the network nodes. At the same time, service objects like convenience stores and gas stations represent the flow of customers through the facility, so a flow-based location model is proposed to capture traffic flow as much as possible [20]. Based on the flow-based model, the problem of BSSs deployed under deterministic traffic flow is presented to minimize construction and inventory costs [21]. In reality, randomness is a characteristic of traffic flow, especially for online car-hailing and taxis with frequent battery swaps, which are not deterministic O-D demands. Therefore, the problem of site selection under random traffic flow is proposed [22]. Robust optimization is one of the effective methods to cope with uncertainty problems. The authors in [23] proposed a distributed robust optimization model, proved that the model can be equated to a mixed-integer nonlinear optimization problem, and proposed an outer approximation algorithm to solve it. The widespread location-route problem is another research branch. Yang and Sun [24] developed an integer programming model to determine the locations of BSSs and the routes of an electric vehicle and proposed a four-phase heuristic (scanning algorithm, greedy algorithm, adaptive large neighborhood search, and algorithm improvement) to solve the model. Based on the algorithm and problem proposed by Yang and Sun [24, 25], an improved adaptive large neighborhood search algorithm to extend the solution methods was proposed. The authors in [26] proposed a hybrid VNS algorithm to find the optimal number and location of BSSs. According to various variants of vehicle routing problems, the location-routing problem of BSSs with time windows [27, 28], multiple vehicle types [29], and multiple depots [30, 31] is also developed. In addition to considering the BSS operator’s cost, it also involves interactions with drivers, power grids, society, and other environments, improving customer satisfaction [32], reducing grid load [33], and reducing the impact on the distribution grid [34]. These factors also have social significance for the construction of swap stations.

2.2. Optimization-Based Machine Learning

Different from modeling optimization, combining big data and machine learning is another way to solve the location problem. The authors in [35] used the K-means clustering algorithm to deploy BSSs. The authors in [36] first conducted map matching using the hidden Markov model (HMM), then extracted trajectories, determined the space-time distribution of battery swapping demand by the clustering algorithm, and finally identified the places with dense battery demand as BSS location candidates. With the development of geographic information systems and grid-based systems, the spatial analysis of massive data by GIS has also been applied to location problems, such as the location of logistic centers [37], car sharing stations [38], and wind farms [39]. The combination of machine learning algorithms like random forest and GIS has also been used in real-world problem research in a few studies, such as population spatialization [40].

2.3. Research Gaps and Aims

On the object of research, most previous studies focused on planning for the deployment of charging stations or battery swapping stations for electric vehicles, with fewer studies on electric two-wheelers. Compared to electric vehicles, E2Ws have quite different user and operation modes. In the research method, model construction is used in most articles, and some constraints are more challenging to express quantitatively and will choose ignore or make assumptions. However, the location of BSSs involves many factors, and the analysis of economic, social, geographical, and other factors should be carried out in the region. Second, regarding the method of machine learning and GIS, location problem is usually regarded as a binary classification problem. Whether the area has such facilities (0-1) is the standard for labeling; this method is simple and incomplete without combining the area situation. In addition, research on the operation capacity of the E2Ws battery swapping station is rarely involved.

In response, we will first use the state of charge (SOC) dataset on actual BSSs in Beijing to extract the behavior patterns of E2Ws. Then, based on map gridding by ArcGIS, machine learning algorithms such as random forest and support vector regression will be proposed to predict the number of BSSs. Finally, the queuing model is built, and the Monte Carlo algorithm will be used to simulate the service capability of the BSSs.

3. Datasets

The capital of China, Beijing, was chosen as a study area. This study explores how points of interest affect the layout of the E2Ws battery swap station. The data collected are as follows: (1) the location data of the BSSs, (2) the battery state of charge, and (3) the data of the point of interest (POI).

3.1. The Location Data of the BSSs

The dataset contains the location information of the E2Ws battery swapping stations in Beijing, which was collected by the “E-huandian” and “China Tower” APPs that mainly provide battery swap services through Python Spider. Table 1 shows an example of the BSS information, including BSS ID, address, longitude, and latitude. The visual analysis of this dataset is given in Section 5.1.1.

3.2. The State of Charge of a Battery

One battery swapping station has multiple charging slots that can charge the battery. The state of charge (SOC) is varied within the charging slots. We obtain the SOC of each slot in the swap station, and SOC is the ratio of the remaining power to the battery capacity. The capture date is 2022/4/6 0 : 00–2022/4/7 0 : 00, with 20 min intervals. About 650,000 pieces of data were collected, and 560,000 pieces of data were obtained after data deduplication. The analysis of this dataset will be given in Section 5.1.2. Table 2 is an example of the state of charge, including BSS ID, battery port number, the state of charge, and capture time.

3.3. Point of Interest

A point of interest (POI) is a specific point location that someone may find useful or interesting. The core attributes of point of interest data include type, name, address, latitude, longitude, and other related information. This study collects POI data that may generate online food ordering demand in Beijing, such as restaurants, coffee bars, shopping centers, universities, office buildings, companies, hospitals, and dormitories. The POI data are divided into seven categories according to their functions: restaurant, shopping, university, company, hospital, and residence (Table 3).

4. Methodology

4.1. Data Cleaning and Mining

Data cleaning can help detect and remove invalid or wrong data, resulting in a dataset for subsequent analyses. For example, to delete those data with unreasonable values (e.g., “SOC” > 100%) and duplicates.

Points of interest are needed for the deployment of BSSs. The first step is the spatial analysis of BSSs and POIs by ArcGIS (5.1.1 and 5.1.2). The primary service area of the facility can be obtained, resulting in a dataset for subsequent machine learning predictions. The second step is data mining to characterize the user’s battery swapping behavior (5.1.3). We identified battery swapping behavior with the following principle (Figure 6). The battery’s state of charge (SOC) can be an effective indicator for judging whether the battery has been exchanged. Like mobile phones, users prefer to replace a fully charged battery to ensure the device’s usability. We recorded the SOC of each battery at 20 min intervals. If the SOC at the next moment is lower than the last, it indicates that the battery slot has had a battery swap during this period. Conversely, it means that there is no battery swap and the battery is being charged. For example, for port 1, the SOC is 96% at 12 : 20 and the SOC is 33% at 12 : 40, indicating that a user has removed the battery with higher power during this period and put the battery with an SOC of 33% or lower into the port for charging because the SOC will not decrease without use. The SOC is 60% at 13 : 00, and it can be inferred that there is no battery swapping between 12 : 40 and 13 : 00. Similarly, the battery swapping behavior of all data can be identified by this rule.

4.2. The Machine Learning Model of BSSs Deployment Based on POI

In this study, using the fishnet tool of ArcGIS, Beijing is divided into several grids with a scale of 3000 m3000 m. Then, we determine the number of BSSs and POI in each grid. Finally, the random forest (RF), support vector regression (SVR), gradient boosting decision tree (GBDT), and stacking ensemble learning are used to predict the number of BSSs (5.2). The whole process is composed of three steps:(i)Step 1: Create test and training sets: Separating data into training and testing sets is an important part of machine learning [41]. The training set learns and adjusts model parameters, and the test set can test the accuracy of the trained model. Determine the research scope and divide the training set and test set according to the ratio of 7 : 3.(ii)Step 2: Feature extraction: Before forecasting, this study uses correlation analysis to determine which type of POI, namely, service facilities, has a greater impact on the deployment of BSSs.(iii)Step 3: Predictions based on machine learning: First, the number of BSSs is fitted by a single machine learning algorithm (RF, SVR, and GBDT). Grid search was used to determine the optimal parameters. Then, we select stacking to ensemble models. Stacking is one of the most popular ensemble machine learning techniques. In stacking, an algorithm takes the outputs of submodels as input and attempts to learn how to combine the input predictions best to make a better output prediction [42].

The prediction results of machine learning algorithms are usually measured by (coefficient of determination), (mean squared error), (mean absolute error), and (root mean square error) [43].where, in formulas (1)–(4), is the true value, is the predicted value, is the mean of the dataset , and is the sample size. The value of shows whether the model would be a good fit for the given dataset. , , and describe the error between the true value and the predicted value of the test set. The lower the error, the better a given model is able to fit a dataset.

4.3. Queuing Model Based on Monte Carlo Simulation

The procedure of user battery swapping at the BSS can be seen as a queuing problem. The BSS is equipped with multiple charging slots in which batteries are placed. There is a slight difference between the BSS queuing problem and the general queuing problem. The general queuing problem is that an idle server is created after the customer has been served. However, whether the BSS has idle servers depends on the battery status. So, the queuing system of the BSS is actually coupled with the E2Ws queuing system and the battery queuing system. We can use the diagram of the battery swap queue in Figure 7 to explain this problem. The QR code can be regarded as only one server, while charging slots can be considered as multiple servers. Since the user’s service time is only one minute, the battery swapping process can be viewed as an M/M/C queuing system. The FIFO queuing method is adopted, and the length of the queue and working hours are not limited. The user’s wait time depends on the number of customers in the queue and the number of fully charged batteries in the BSS. The state of the battery is affected by the arrival rate and charging time.

4.3.1. Queuing Model of Battery Swapping Station

We assume that the arrival of the E2Ws follows the Poisson distribution with parameter . The charging time for a low-charge to full-charge battery follows the exponential distribution of the charging rate . Let m be the number of charging slots and n be the number of E2Ws. The state transfer of the BSS is a birth-death process, as shown in Figure 8. The initial stage assumes that the batteries in the BSS are fully charged. When the number of E2Ws n is less than the number of fully charged batteries m, the service can be provided by n batteries. When n exceeds m, the user needs to wait.

It can be seen that the state transition probability of the BSS is related to the arrival rate , charging rate , and the number of batteries m in the BSS. In an equilibrium state, from Figure 8, the following equations can be formed:

Set , , when , according to the above equation, we can observe that

According to equation (6), the mathematical expectation of the queue length of E2Ws can be written as

The average waiting time is

Essentially, when the BSS increases the number of charging slots, that is, the number of batteries, the waiting time, and length of the queue will decrease, thus improving the service capability of the BSS.

4.3.2. Monte Carlo Simulation

When the E2Ws arrive at the BSS, whether the service can be started needs to be judged on the following two conditions: (1) Is there a vehicle ahead? (2) Is there a fully charged battery for the user to swap? Therefore, the simulation process will be based on several situations formed by the queue and battery state to calculate the start time and wait time. Table 4 lists all the parameters used in the queuing system.

(1) No Queuing Process. When the E2Ws arrive at the BSS, if there is at least one fully charged battery, the E2Ws n starts to replace the battery, and the time to start receiving service is equal to its arrival time:

If the battery is not fully charged at this time, the E2Ws n will have to wait. The start time of the service depends on which battery can be fully charged the earliest. The start time for battery swapping is

Departure time is the sum of service start time and service time:

(2) Queuing Process. When the E2Ws arrive at the BSS, if there is a queuing situation, vehicle n needs to exchange batteries after the previous vehicle leaves. If there is a fully charged battery in the BSS after the previous vehicle leaves, the time for the E2Ws n to start receiving service is equal to the time when the previous vehicle leaves:

If there is no fully charged battery at the BSS after the previous vehicle leaves, the E2Ws n needs to wait. The start time of the service depends on which battery can be fully charged the earliest. The start time for battery swapping is

After summarizing the above four cases, the model can be obtained as follows:

Figure 9 is an explanation of the variables and . In the initial state, the time is set to 0, and the SOC of the three charging slots is 98%. When the first user arrives at the 10th minute, that is, n = 1, t = 10, the batteries for all three charging slots are available. So, set . After the battery swap, the SOC in charging slot1 becomes 35%, which is the old battery swapped by the user. When the second user arrives after 15 minutes, that is, t = 25, n = 2, charging slots2 and slots3 are available, and slot1 is only available when t is 54. So, set .

Monte Carlo simulation is a mathematical technique to estimate an uncertain event’s possible outcomes [44]. Based on the above analysis, the Monte Carlo algorithm was used in this study to solve the queuing model, and the number of users that can be served in one day and the average waiting time are given. Figure 10 shows the simulation flow. The specific steps are as follows:(i)Step 1: Input parameters: The parameters include the number of iterations, the parameter values of the probability density function of SOC, and the interval time.(ii)Step 2: Initialize the battery state: According to the probability density function, the SOC of each battery cabinet is randomly generated.(iii)Step 3: Update the battery status: The user departure time is calculated based on formulas (14)∼(19). We generate the SOC of the removed battery to calculate the battery charging time and battery available time . Generate the arrival time of the following user according to the distribution function of the user’s arrival time interval.(iv)Step 4: Based on the Monte Carlo algorithm, the operation of the BSS is simulated 1,000 times to obtain the average service capacity and waiting time.

5. Results

5.1. Data Analysis
5.1.1. Spatial Features of E2Ws Battery Swapping Station

As introduced in Section 3.1, the spatial distribution of BSS in Beijing is given. Figure 11 shows the number of BSSs in each administrative district of Beijing. Based on the “E-huandian” and “China Tower” apps that mainly provide battery swapping services in Beijing, 1,741 BSSs have been deployed. The deployment of BSSs has prominent regional characteristics that are related to their service functions. The first is Chaoyang District, where around 38.77% of the swap stations are built. Chaoyang District is the largest and most popular urban area in Beijing. 18.78% of the BSS are located in Haidian District, known for its top universities, research academies, and Internet companies. The third is Fengtai District, which includes a railway station, long bus stations, an industrial park, and a leisure square. It is also a hot spot for battery swapping, and 10.05% of the BSSs are deployed. About 8.96% of the swap stations are located in Changping District, which is dominated by residential areas. These locations are potential food delivery demand points, increasing the demand for battery swapping.

5.1.2. Spatial Features of POI Data

Based on the data in Section 3.3, this section uses ArcGIS to draw the spatial distribution density map of POI data. Figures 1217 show the distribution of various service facilities in Beijing that may generate food delivery demand. As can be seen from the figure, Beijing covers a large number of restaurants and companies and has a wide distribution range. Then, the most covered are residential areas, universities and shopping centers, and medical institutions. Universities, hospitals, and large shopping centers in Beijing are mainly distributed on the Fifth Ring Road.

5.1.3. Features of Battery Swapping Behavior

According to the identification rules in Section 4.1, the battery swap data within the BSS is inferred. Figure 18 shows the battery swap demand in different administrative districts, and there are apparent differences between the administrative districts. Compared with the layout of the BSSs given above, the demand trend is consistent with the number of BSSs in each district and is also related to the POI data.

Figure 19 shows the battery swap demand at different times. Data analysis shows that the peak time of battery swapping orders occurs at 11 : 00, 15 : 00, 18 : 00, and 21 : 00. These four times also coincide with the peak period for online food delivery. The valley time of the battery swap is 02 : 00–07 : 00, which is the rest time. After 07 : 00, the demand for battery swaps gradually increased. 12 : 00–14 : 00 is the most intensive time for takeaway orders involving multiple business office areas. Therefore, there is a lot of battery swap demand at 11 : 00 to maintain the mileage of E2Ws to cope with the peak delivery period. From 11 : 00 to 15 : 00, the demand has dropped, but it remains high. Depleted batteries need to be replaced after the peak period, so demand rises at 15 : 00. Similarly, 18 : 00–20 : 00 is the peak period for takeaways in the evening. 18 : 00 and 21 : 00 are the start and end times of the peak period, and the user needs to swap the battery. After 21 : 00, the demand for battery swapping showed a decreasing trend.

Figure 20 shows the user’s electricity preferences when swapping batteries. According to the statistics, 80% of users will choose the battery with more than 90% SOC to exchange. Almost all users consider that batteries with a SOC above 80% can be swapped. Therefore, we set the battery usable SOC threshold to 95% during the simulation.

5.2. Prediction of Battery Swap Station Deployment
5.2.1. Dataset Partitioning

Through the distribution map in Section 5.1, most service facilities move from the edge of the Fifth Ring Road to the urban area, and fewer are close to the Sixth Ring Road. The swap station mainly covers Fifth Ring Road. Therefore, the study area is limited to the longitude range of 116.1200027∼116.7289963 and the latitude range of 39.6907005∼40.2299003.

Then, we delete the outliers. After filtering, the final sample data contain 198 grids. The training and test sets are divided according to the ratio of 7 : 3.

5.2.2. Feature Extraction

Since the data present a nonlinear relationship, we use the Spearman coefficient to test the correlation between the BSSs and service facilities. Table 5 shows the correlation coefficients based on gridded data. We can see a positive correlation between the BSSs and service facilities, and indicates a significant correlation. Therefore, we choose the above five variables for machine learning prediction.

5.2.3. Prediction of the Number of Battery Swap Stations

Random forest, support vector regression, and gradient boosting decision tree were adopted to predict the number of BSSs. We are using grid search to find optimal hyperparameters. Table 6 shows the hyperparameters. The predicted error of the model is shown in Table 7. The curve that fits between predicted and actual values is given in Figure 21. By comparison, there is little difference in the simulation effect of a single machine learning algorithm, and the random forest algorithm is relatively better.

We adopted the stacking ensemble model to improve prediction accuracy. First, RF, SVR, and GDBT are set as the basic models. Since the prediction results of RF are better, we choose RF as the second-level model. We found the optimal hyperparameters by grid search: n_estimators = 150, max_depth = 6, min_samples_split = 4, and min_samples_leaf = 6. Table 8 shows the prediction error of the stacking model. A curve fitting between predicted and true values is given in Figure 22.

Based on the results of the stacking model, all 198 grids were predicted, and the results were visualized using ArcGIS. Figure 23 shows the predicted number of BSSs that should be deployed within each grid. We analyzed the results and found that the true and predicted values of the swap stations in each grid were slightly different. Specifically, there are five grids with a total of 31 battery swapping stations; the predicted number of swapping stations differs from the actual number by more than 5. The difference accounted for 2.5% of the total grids and 7.5% of the total battery swapping stations.

Through the above analysis, there are some errors in the results. On the one hand, all characteristic variables, such as rent and the proportion of young people, are not considered in the model’s prediction. On the other hand, it is caused by practical factors. It is difficult to collect data such as rent through the Internet. The population data given in the Statistical Yearbook can only be matched to areas or streets and cannot be mapped to grids. Therefore, it is impossible to add these features to the model at this stage.

Beside the above five grids, the number of BSSs predicted by machine learning differs from the true value by less than 5 in the other 193 grids (about 97.5%). The model fits well into these grids. Therefore, in general, the stacking model is helpful in predicting the number and layout of BSSs.

5.3. Service Capability Simulation of E2Ws Battery Swap Station

Based on the predicted number and layout of BSSs, we can choose one of the swap stations for the Monte Carlo simulation. Then, we get the average number of users a swap station that can serve in a day and the average waiting time. These data can provide recommendations for swap station operators.

5.3.1. Factors Affecting BSS Service Capability

The SOC of the battery determines its service capability. As introduced in Section 4.3, the randomness of the SOC is affected by the user arrival rate, starting SOC, and charging duration. Based on the data given in Section 3.2, we estimate that the initial SOC follows a beta distribution, and the probability density function iswhere and .

Since the time for each user to arrive at the BSS is an independent variable, the interval time is also an independent random variable. The number of users arriving at the BSS follows the Poisson distribution:

Here, is the frequency of user in the BSS between two battery swapping time. Although the arrival rate is constant, it has different values at different time periods. The battery exchange probability of E2Ws is different in each period.

5.3.2. Analysis of Simulation Result

(1) Baseline Scenario. A baseline scenario was set up to test the performance of the BSS. In the baseline scenario, the two key parameters were set as follows:(i)M: as introduced in Section 4.3, this denotes the number of charging slots in the BSS. It can also be considered in terms of the number of BSS batteries. M was set to 13.(ii): denotes the user arrival rate. The value of was calculated by data analysis based on the results in Sections 4.1 and 5.1.3 (Table 9).

Figure 24 shows the service capability of the BSS in the basic scenario. The average number of users that can be served by one battery swapping station daily is 203. When the number of charging slots is 13, the average waiting time for users is 0. On the one hand, there are enough charging slots and fast charging speeds. On the other hand, because of range anxiety, the SOC of the old battery that the user needs to replace will not be very low, and less electricity needs to be replenished. Therefore, the BSS can guarantee that at least one battery is available when the user arrives.

(2) Sensitivity Analysis. In this section, we will test the sensitivity of the two parameters.(i)Scenario 1-Varying. With the other parameters kept unchanged, M was set to 5–20 in sixteen different scenarios. In order to explore how the number of charging slots would influence the outputs of service capability.(ii)Scenario 2-Varying. According to Section 5.1.3, the user arrival rate is mainly affected by the peak period of food delivery. The peak time for users to replace batteries is at 11 : 00. Therefore, we will only change the arrival rate at [10–12). With the other parameters kept unchanged, was set to 20–60 to explore how the arrival rate would influence the 1 output of service capability.

Figure 25 shows how different charging slots could affect the service capability. It can be found that a higher M (which means more charging slots) would give rise to higher numbers of services and reduce user waiting time. There is no difference in service capacity when charging slots are 12 and 13. This points out that under the current user arrival rate, operators do not need to invest too many charging slots and cause waste.

Figure 26 shows how different user demands affect the service’s capability. It can be found that the more users needed, the more users can be served, and the waiting time of users is also increasing. At this time, operators can add 2 charging slots or battery swapping stations. Table 10 shows the detailed simulation results under two scenarios.

6. Conclusions

The battery swapping station solves the problems of inconvenient charging, long charging times, and hidden charging hazards. This study proposes a data-driven method that combines ArcGIS and machine learning to optimize the deployment and management of BSSs for E2Ws.

Specifically, first, the data of POI and BSSs are collected. Beijing is divided into 198 grids with a scale of 3000 m. The spatial features of service facilities such as BSSs, restaurants, and shopping centers are given through density analysis. The coverage of service facilities is mainly within Fifth Ring Road. So, we select the dataset range for subsequent machine learning predictions within the Fifth Ring Road.

Second, use RF, SVR, and GBDT algorithms to predict the number of BSSs. We found that the three algorithms’ prediction accuracy is about 80%. After using stacking integration, the prediction accuracy increased to 86.21%. Finally, the number of swap stations in all grids is predicted. There is a deviation between the predicted and real values, but the overall prediction effect is good. The machine learning model proposed in this study provides a solution for operators to deploy swap stations effectively.

Finally, several scenarios were set up to examine the performance of the BSS. The two key parameters (namely parameters and ) can heavily influence the outputs of service capability. It can be found that the quantity of the service would be much higher in those scenarios where there is a larger number of charging slots and demand. The waiting time is inversely proportional to the number of charging slots. This result suggests that operators can choose the appropriate number of charging slots by making a trade-off between cost and quality of service.

In the future, we can carry out research in two aspects. (1) In terms of data, due to the platform’s competitiveness, it is challenging to obtain takeaway orders and delivery trajectories. If the data are available, the battery swap demand can be simulated from the delivery chain, and the scale and capacity of the BSS can be further optimized. (2) On the operator side, putting too many BSSs can cover user demand, but it will increase construction costs. Therefore, the issue of pricing for battery swapping can be discussed.

Data Availability

The [xlsx] data used to support the findings of this study are deposited in the GitHub repository (https://github.com/codefish941/Machine-Learning-simple.git).

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Acknowledgments

This research was funded by the National Natural Science Foundation of China, grant no. 72171016, and The International Center for Informatics Research of Beijing Jiaotong University.