The rapid global proliferation of electric cars presents a dual challenge for power systems: managing the significant new load while harnessing their potential as distributed energy storage resources. The coordinated charging and discharging of large-scale electric car fleets can provide crucial flexibility for grid operations, including peak shaving, valley filling, and ancillary services. To effectively participate in power markets or follow grid dispatch commands, aggregators must first determine an optimal aggregate power profile for their portfolio of charging and swapping stations. The subsequent critical step is to decompose this aggregate power target into real-time charging/discharging instructions for individual electric cars and battery packs in a way that respects user requirements and physical constraints.
Existing decomposition strategies often face significant limitations. Traditional optimization-based approaches, while theoretically optimal, struggle with computational complexity in large-scale scenarios and rely on accurate forecasts of future charging demand, which are difficult to obtain. Simple priority-based rules, such as the Least Laxity First (LLF) or the Less Laxity and Longer Remaining Processing Time (LLLP) criterion, are computationally efficient but can lead to excessive fluctuations in the power setpoints for individual electric cars, which is detrimental to battery longevity and power tracking accuracy. Furthermore, most research focuses solely on charging piles, neglecting the distinct operational characteristics and flexibility potential of battery swapping stations.

To address these gaps, this work proposes an innovative real-time decomposition framework for integrated electric car charging and battery swapping facilities. For charging facilities, we enhance the classic LLLP criterion by incorporating a lookahead mechanism and a power reassignment step. This significantly smooths individual electric car power profiles and improves tracking accuracy of the aggregate target. For battery swapping stations, we introduce a dynamic battery reserve strategy, decoupling operational decisions from uncertain user demand by maintaining a predicted reserve of fully-charged or fast-charging batteries, thereby freeing the remaining non-reserve batteries for flexible grid services. The core methodology is outlined below.
Methodology Overview
The overall framework operates in two layers. First, an aggregator solves an optimization problem to determine the optimal aggregate power profile $P_t^*$ for the electric car fleet over a scheduling horizon, typically minimizing electricity purchase cost or maximizing service provision revenue. The constraints are based on the aggregate power-energy flexibility domain of the fleet. Second, in real-time operation, this target curve $P_t^*$ must be decomposed into instructions for each connected electric car at charging points and each battery pack in swapping stations. Our proposed real-time decomposition strategy tackles this second challenge efficiently and effectively.
Real-time Decomposition for Charging Facilities
We focus on the real-time control of a large number of electric car charging sessions. At each control time step $t$, the operator knows the parameters for all currently connected electric cars: required energy $e_j^r$, maximum charging power $p_j^c$, maximum discharging power $p_j^d$, departure time $t_j^d$, and current energy $e_{j,t}$. The goal is to assign a power setpoint $p_{j,t}$ to each session $j$ so that the sum approximates $P_t^*$, while ensuring each electric car’s energy demand is met by its deadline.
1. Enhanced LLLP with Lookahead and Reassignment
The baseline LLLP priority rule schedules electric cars based on two parameters calculated at time $t$: laxity $\theta_{j,t}$ and remaining time $\lambda_{j,t}$.
$$
\theta_{j,t} = \lambda_{j,t} – \gamma_{j,t}
$$
$$
\lambda_{j,t} = t_j^d – t
$$
$$
\gamma_{j,t} = \frac{e_j^r – e_{j,t}}{p_j^c}
$$
Here, $\gamma_{j,t}$ is the minimum time needed to finish charging the electric car at full power. A smaller $\theta_{j,t}$ indicates higher urgency. The LLLP rule sorts electric cars in ascending order of $\theta_{j,t}$; for equal laxity, the car with longer $\lambda_{j,t}$ (and thus longer $\gamma_{j,t}$) gets higher priority. While simple, this greedy rule can cause frequent power fluctuations for individual electric cars.
| Symbol | Description |
|---|---|
| $\theta_{j,t}$ | Laxity of electric car $j$ at time $t$. |
| $\lambda_{j,t}$ | Remaining parking time for electric car $j$. |
| $\gamma_{j,t}$ | Minimum charging time for electric car $j$ at full power. |
| $e_j^r$ | Required energy for electric car $j$. |
| $e_{j,t}$ | Current energy of electric car $j$ at time $t$. |
| $p_j^c$, $p_j^d$ | Max. charge/discharge power for electric car $j$. |
Our enhancement introduces two key mechanisms:
Lookahead Mechanism: Instead of allocating power based only on the current priority, we simulate the application of the standard LLLP rule over a forward-looking window of $N_t$ time steps. For each electric car $j$, we calculate a baseline power $\bar{p}_{j,t}$ as the average power it would receive over this simulated future period.
$$
\bar{p}_{j,t} = \frac{1}{\min\{t_j^d – t, \, N_t\}} \sum_{\tau=t}^{t+N_t} p_{j,\tau}^{LLLP}
$$
This smooths out short-term priority changes, leading to more stable power profiles for each electric car.
Power Reassignment Mechanism: The sum of baseline powers $\sum_j \bar{p}_{j,t}$ will generally not equal the target $P_t^*$. A power mismatch $\Delta P_t = P_t^* – \sum_j \bar{p}_{j,t}$ exists. We redistribute this mismatch proportionally among all non-urgent electric cars based on their available power headroom. The adjustment $\Delta p_{j,t}$ is calculated as:
$$
\Delta p_{j,t} = \begin{cases}
\min\left(\frac{\Delta P_t}{\sum_{j \in \mathcal{J}} \delta^c_{j,t}}, 1\right) \delta^c_{j,t} & \text{if } \Delta P_t \geq 0 \\
\min\left(\frac{\Delta P_t}{\sum_{j \in \mathcal{J}} \delta^d_{j,t}}, 1\right) \delta^d_{j,t} & \text{if } \Delta P_t < 0
\end{cases}
$$
where $\delta^c_{j,t}=p_j^c – \bar{p}_{j,t}$ and $\delta^d_{j,t}= -p_j^d – \bar{p}_{j,t}$ are the available upward and downward regulation margins from the baseline, respectively. The final power setpoint for the electric car is $p_{j,t} = \bar{p}_{j,t} + \Delta p_{j,t}$.
2. Adaptive Lookahead Step Adjustment
To balance computational load with control performance, the lookahead step $N_t$ is dynamically adjusted. It is linked to the recent volatility of the aggregate power target $P_t^*$:
$$
F_t = \frac{1}{N_0} \sum_{\tau=t}^{t+N_0-1} |P_{\tau+1}^* – P_{\tau}^*|
$$
$$
\sigma_t = \frac{1}{1 + e^{-r(F_t – \epsilon)}}
$$
$$
N_t = \text{round}\left( \underline{N} + (\overline{N} – \underline{N}) \sigma_t \right)
$$
Here, $F_t$ is a moving average of absolute power differences over a window $N_0$. The sigmoid function $\sigma_t$ maps this volatility measure to a range between 0 and 1, which is then scaled to the allowed step range $[\underline{N}, \overline{N}]$. Parameters $r$ and $\epsilon$ control the sensitivity. This ensures a longer lookahead is used only during periods of high target volatility, optimizing computational efficiency.
Integrated Decomposition for Charging and Swapping Facilities
Battery swapping stations for electric cars operate differently. They must maintain a ready inventory of charged batteries to meet immediate, stochastic user swap demand, which constrains their power flexibility.
1. Dynamic Battery Reserve Strategy for Swapping Stations
We categorize batteries within a station as either reserve or non-reserve.
- Reserve Batteries: These are designated to fulfill imminent swap requests. They operate in two modes: Power Reserve (charging at maximum power to reach full state of charge – SOC) or Capacity Reserve (maintaining full SOC). They provide no grid flexibility.
- Non-Reserve Batteries: These are the “spare” batteries. Their charging/discharging power can be flexibly adjusted to follow the grid’s aggregate power signal.
The key is to accurately predict the minimum number of each battery type $b$ that must be in reserve at time $t$, denoted $m_{b,t}$. This is derived from historical swap data, considering the time $t_{b}^{res}$ needed to charge a battery from its minimum to maximum SOC:
$$
t_{b}^{res} = \lceil \frac{(S_b^h – S_b^l) C_b}{p_b^c \Delta t} \rceil
$$
The historical minimum reserve $m_{b,t}$ is the count of future swaps within the $t_{b}^{res}$ window from time $t$.
2. Predicting Reserve Scale with XGBoost
For real-time operation, we predict the future reserve requirement $\hat{m}_{b,t}$ using an XGBoost model. This avoids the need for direct and error-prone swap demand forecasting. The model uses features such as lagged historical reserve counts, time features (hour, weekday, holiday), and weather data. The predicted reserve count is clipped by the actual available battery count $M_{b,t}$:
$$
\hat{m}_{b,t} = \min\{ M_{b,t}, \text{round}(\hat{y}_{b,t}) \}
$$
where $\hat{y}_{b,t}$ is the raw model output.
3. Joint Power Allocation Priority
When decomposing the adjusted aggregate power target $\tilde{P}_t^*$ (after subtracting power for urgent electric car charging and reserve battery charging), a specific priority order between charging facilities and swapping station batteries is enforced to maximize system flexibility and meet electric car user needs:
- For Charging Scenarios ($\tilde{P}_t^* \geq 0$): First, allocate power to connected electric cars using the enhanced LLLP rule. Second, charge non-reserve batteries in the swapping station, starting with those having the highest SOC (to create reserve capacity faster).
- For Discharging Scenarios ($\tilde{P}_t^* < 0$): First, discharge non-reserve batteries in the swapping station, starting with those having the lowest SOC. Second, request discharge from connected electric cars using the enhanced LLLP rule (ascending laxity order).
This coordinated strategy ensures swap service reliability while unlocking the flexibility of both individual electric cars and the station’s non-reserve battery inventory.
Case Study and Performance Evaluation
We evaluated the proposed framework using simulations based on realistic electric car charging behavior and actual battery swap station records.
1. Charging Facilities Decomposition Performance
A scenario with 100 electric car charging events per day was simulated. The aggregate power target $P_t^*$ was obtained from a day-ahead cost minimization. We compare four decomposition methods:
- Optimal Decomposition (Benchmark): Solves the full-information optimization problem (with a penalty for individual power fluctuation).
- Standard LLLP Rule.
- LLLP with Lookahead only.
- Our Proposed Method (LLLP with Lookahead & Reassignment).
Performance is measured by the Aggregate Power Tracking Relative Error (RE, lower is better) and the average individual Power Fluctuation Index (PFI, lower is better).
| Decomposition Algorithm | Relative Error (RE) | Power Fluctuation (PFI) | Avg. Runtime per Step |
|---|---|---|---|
| Optimal Decomposition | 0.21% | 0.26 kW | 126.2 s |
| Standard LLLP | 8.27% | 1.30 kW | ~0.07 ms |
| Lookahead Only | 29.46% | 0.32 kW | 6.62 ms |
| Proposed Method | 7.08% | 0.44 kW | 6.68 ms |
The results demonstrate the effectiveness of our method. It achieves an order-of-magnitude reduction in individual electric car power fluctuation compared to the standard LLLP (0.44 kW vs. 1.30 kW), while maintaining a low tracking error close to that of LLLP. The lookahead-only method has very smooth power but a high error because it lacks the reassignment correction. Critically, our method’s runtime is suitable for real-time control (milliseconds), unlike the optimal decomposition which takes over two minutes.
2. Computational Scalability
The computational efficiency of the proposed method was tested for large-scale electric car fleets, confirming its practical applicability for aggregators.
| Scale (Electric Cars per Day) | Proposed Method Avg. Runtime |
|---|---|
| 100 | 6.68 ms |
| 1,000 | 80 ms |
| 10,000 | 1.37 s |
| 100,000 | 16.65 s |
Even for a fleet of 100,000 electric cars, the runtime remains within a typical control interval (e.g., 30 seconds), making it viable for real-world, large-scale deployment.
3. Benefit of Adaptive Lookahead
The adaptive step adjustment strategy successfully balances performance and computation.
| Lookahead Strategy | Avg. Runtime | RE | PFI |
|---|---|---|---|
| Fixed $N_t=60$ (Low) | 5.38 ms | 6.64% | 0.46 kW |
| Fixed $N_t=120$ (High) | 9.67 ms | 7.47% | 0.43 kW |
| Adaptive $N_t$ (Proposed) | 6.68 ms | 7.05% | 0.44 kW |
The adaptive strategy achieves performance metrics nearly as good as the longer fixed lookahead, but with a runtime close to the shorter fixed lookahead, demonstrating its efficiency.
4. Integrated Charging and Swapping Operation
Integrating two real battery swap stations (with 13 battery packs each) into the simulation, the joint decomposition framework maintained excellent performance. The aggregate power tracking error was kept very low at 0.89%. The dynamic reserve strategy successfully managed the swap demand, while the non-reserve batteries provided flexible charging/discharging power following the system’s priority rule. Adhering to the proposed charging/swapping priority order reduced the decomposition error compared to a non-cooperative scenario (0.89% vs. 1.00%).
Conclusion
This paper presents a comprehensive and computationally efficient real-time decomposition strategy for the aggregate power of large-scale electric car charging and battery swapping facilities. The proposed method significantly improves upon existing priority-based rules by incorporating a lookahead mechanism and a power reassignment step, effectively reducing individual electric car power fluctuations and aggregate tracking error. The novel dynamic battery reserve strategy for swapping stations robustly handles uncertain user demand while enabling grid-friendly operation. The integrated framework coordinates the flexibility from both types of electric car infrastructure under a unified priority rule. Case studies based on real data confirm that the strategy is scalable, fast enough for real-time control of massive electric car fleets, and effective in minimizing power deviations. This work provides a practical and robust solution for aggregators to precisely deliver promised grid services from a diverse portfolio of electric car resources, paving the way for more sustainable and resilient power systems.
