In recent years, the adoption of electric vehicles in urban logistics has surged, driven by global sustainability goals and the need to reduce carbon emissions. As an eco-friendly alternative to traditional fuel-powered vehicles, electric vehicles offer zero tailpipe emissions and higher energy efficiency. However, their integration into distribution networks poses significant challenges, primarily due to limited driving range and prolonged recharging times. These limitations often conflict with tight delivery schedules and customer time windows, impacting service quality and operational costs. In this context, optimizing the routing and energy replenishment strategies for electric vehicle fleets becomes crucial. I focus on the electric vehicle routing problem (EVRP), which involves planning delivery routes while managing battery constraints. Traditional approaches often consider单一 recharging modes—either charging or battery swapping—but fail to balance time window adherence and cost-effectiveness. This paper proposes a novel optimization model that simultaneously incorporates both charging and battery swapping modes, allowing electric vehicle cars to dynamically select the most suitable energy replenishment method based on real-time conditions. The goal is to minimize total distribution costs while satisfying multiple constraints, including vehicle capacity, battery limits, soft time windows, and traffic flow. I develop a genetic algorithm to solve this complex problem and demonstrate its effectiveness through comparative analysis. The findings highlight the advantages of a hybrid approach, offering insights for logistics companies seeking to enhance electric vehicle car operations.
The growing body of research on EVRP reflects its importance in modern logistics. Scholars have explored various求解 algorithms and energy replenishment strategies to address the inherent challenges. For instance, Jia et al. introduced a confidence-based ant colony optimization algorithm for capacitated electric vehicle routing, while Liu et al. applied a hybrid ant colony algorithm to cold chain logistics with electric vehicle cars. Other algorithms, such as genetic algorithms, particle swarm optimization, and machine learning methods, have been employed to improve solution quality and computational efficiency. In terms of energy replenishment, studies often separate charging and battery swapping modes. Charging modes may include full or partial charging, with considerations for nonlinear charging functions and dynamic energy consumption. Battery swapping, on the other hand, involves replacing depleted batteries with fully charged ones at dedicated stations, reducing downtime but incurring rental costs. Recent works have integrated time window constraints to assess delivery punctuality, but they typically focus on单一 mode. For example, Keskin and Çatay examined fast chargers in time-constrained EVRP, and Verma investigated routing with both charging and swapping stations. However, these studies lack flexibility in mode selection during trips. My work builds on this literature by proposing a unified model that allows electric vehicle cars to choose between charging and swapping at any replenishment station, optimizing both cost and time window compliance. This approach addresses gaps in existing research, particularly in handling diverse customer requirements and fluctuating traffic conditions.
The problem involves a distribution center serving multiple customers with a fleet of homogeneous electric vehicle cars. Each customer has a known location, demand quantity, and soft time window—a preferred delivery interval with penalties for early or late arrivals. The distribution center dispatches electric vehicle cars to fulfill all customer demands, starting and ending at the center. During routes, if an electric vehicle car’s battery level falls below a safe threshold, it must visit a replenishment station to restore energy. Two modes are available: charging, which takes time proportional to the energy added, and battery swapping, which is faster but involves fixed costs. The objective is to minimize total distribution costs, which include fixed vehicle operating costs, time costs during replenishment, labor costs, energy replenishment costs, and time window penalty costs. Key assumptions are made to simplify the model: customer data is static, the distribution center has sufficient goods, electric vehicle cars are identical and compatible with stations, speed and energy consumption rates are constant, and stations have no waiting queues. These assumptions provide a foundation for modeling real-world scenarios while maintaining tractability.

To formalize the problem, I define sets, parameters, and decision variables. Let $O$ represent the distribution center, $N = \{1, 2, \dots, n\}$ be the set of customers, $K = \{1, 2, \dots, k\}$ the set of electric vehicle cars, and $CS = \{1, 2, \dots, m\}$ the set of replenishment stations. Key parameters include $q_i$ for customer demand, $Q$ for vehicle capacity, $d_{ij}$ for distance between points $i$ and $j$, $EVV$ for electric vehicle car speed, $QOE^{\text{max}}$ for maximum battery capacity, $f$ for energy consumption per kilometer, $\beta$ for charging rate, $T^{\text{change}}$ for swapping time, and time windows $[Te_i, Tl_i]$. Decision variables include $x_{ijk}$ (binary, indicating if electric vehicle car $k$ travels from $i$ to $j$), $y_{ik}$ (binary, for customer assignment), $z_{ik}$ (binary, for charging at station $i$ by vehicle $k$), and $g_{ik}$ (binary, for swapping at station $i$ by vehicle $k$). The total cost $C$ is minimized, composed of several components:
Fixed operating cost for electric vehicle cars: $$C_1 = \sum_{k \in K} \sum_{j \in N \cup CS} C^{\text{vehicle}} \cdot x_{Ojk}$$ where $C^{\text{vehicle}}$ is the cost per vehicle dispatch.
Time cost during energy replenishment: $$C_2 = f^{\text{time}} \cdot \sum_{i \in CS} \sum_{k \in K} (z_{ik} \cdot T^{\text{char}}_{ik} + g_{ik} \cdot T^{\text{change}})$$ with $f^{\text{time}}$ as the unit time cost and $T^{\text{char}}_{ik}$ as charging time.
Labor cost, including fixed wages and performance-based pay: $$C_3 = \sum_{k \in K} \sum_{j \in N \cup CS} C^{FS} \cdot x_{Ojk} + \alpha \cdot \left( \sum_{i,j \in V, i \neq j} \sum_{k \in K} x_{ijk} \cdot \frac{d_{ij}}{EVV} + \sum_{i \in N} \sum_{k \in K} y_{ik} \cdot T^{\text{service}} + \sum_{i \in N} \sum_{k \in K} y_{ik} \cdot \max(Te_i – T^{\text{arrive}}_{ik}, 0) + \sum_{i \in CS} \sum_{k \in K} \left( z_{ik} \cdot \frac{QOE^{\text{char}}_{ik}}{\beta} + g_{ik} \cdot T^{\text{change}} \right) \right)$$ where $\alpha$ is the performance wage coefficient and $C^{FS}$ is the fixed salary.
Energy replenishment cost, covering charging and swapping expenses: $$C_4 = \sum_{i \in CS} \sum_{k \in K} \left( z_{ik} \cdot ((f^{\text{char}} + f^{\text{service}}) \cdot QOE^{\text{char}}_{ik}) + g_{ik} \cdot (f^{\text{rent}} + f^{\text{change}} \cdot QOE^{\text{change}}_{ik}) \right)$$ with $f^{\text{char}}$ and $f^{\text{service}}$ as charging rates, and $f^{\text{rent}}$ and $f^{\text{change}}$ as swapping fees.
Time window penalty cost, accounting for early or late arrivals: $$p_{ik}(T^{\text{arrive}}_{ik}) = \begin{cases} M_1 (Te_i – T^{\text{arrive}}_{ik}) & \text{if } T^{\text{arrive}}_{ik} \in [0, Te_i) \\ 0 & \text{if } T^{\text{arrive}}_{ik} \in [Te_i, Tl_i] \\ M_2 (T^{\text{arrive}}_{ik} – Tl_i) & \text{if } T^{\text{arrive}}_{ik} \in (Tl_i, +\infty) \end{cases}$$ $$C_5 = \sum_{i \in N} \sum_{k \in K} y_{ik} \cdot p_{ik}(T^{\text{arrive}}_{ik})$$ where $M_1$ and $M_2$ are penalty coefficients.
The complete optimization model is formulated as follows: $$\min C = C_1 + C_2 + C_3 + C_4 + C_5$$ subject to constraints:
Vehicle capacity: $$\sum_{i \in V} q_i y_{ik} \leq Q \quad \forall k \in K$$
Customer service: $$\sum_{i \in N \cup O \cup CS, i \neq j} \sum_{k \in K} x_{ijk} = 1 \quad \forall j \in N \cup O \cup CS$$
Flow conservation: $$\sum_{i \in N \cup O \cup CS, i \neq j} \sum_{k \in K} x_{ijk} = \sum_{i \in N \cup O \cup CS, i \neq j} \sum_{k \in K} x_{jik} \quad \forall j \in N \cup O \cup CS$$
Route continuity: $$\sum_{i=0, j \in N} x_{ijk} = \sum_{j=0, i \in N} x_{ijk} \quad \forall k \in K$$
Vehicle limit: $$\sum_{i=0, j \in N} \sum_{k \in K} x_{ijk} \leq K$$
Battery dynamics: $$QOE^{\text{leave}}_{ik} = QOE^{\text{max}} \quad \forall i \in CS, \forall k \in K$$ $$QOE^{\text{arrive}}_{ik} = QOE^{\text{leave}}_{ik} \quad \forall i \in N, \forall k \in K$$ $$QOE^{\text{safe}} = QOE^{\text{max}} \cdot 15\%$$ $$QOE^{\text{safe}} \leq QOE^{\text{arrive}}_{ik} \leq QOE^{\text{max}}, \quad QOE^{\text{safe}} \leq QOE^{\text{leave}}_{ik} \leq QOE^{\text{max}} \quad \forall i \in V, \forall k \in K$$ $$QOE^{\text{arrive}}_{jk} = QOE^{\text{leave}}_{ik} – f \cdot d_{ij} \cdot x_{ijk} \quad \forall i,j \in V, i \neq j, \forall k \in K$$ $$QOE^{\text{char}}_{ik} = z_{ik} \cdot (QOE^{\text{leave}}_{ik} – QOE^{\text{arrive}}_{ik}) \quad \forall i \in CS, \forall k \in K$$ $$QOE^{\text{change}}_{ik} = g_{ik} \cdot (QOE^{\text{leave}}_{ik} – QOE^{\text{arrive}}_{ik}) \quad \forall i \in CS, \forall k \in K$$
Time constraints: $$T^{\text{leave}}_{ik} = 0 \quad i = O, \forall k \in K$$ $$T^{\text{char}}_{ik} = z_{ik} \cdot \frac{QOE^{\text{char}}_{ik}}{\beta} \quad \forall i \in CS, \forall k \in K$$ $$T^{\text{wait}}_{ik} = \max(Te_i – T^{\text{arrive}}_{ik}, 0) \quad \forall i \in N, \forall k \in K$$ $$T^{\text{leave}}_{ik} = T^{\text{arrive}}_{ik} + T^{\text{service}}_{ik} + T^{\text{wait}}_{ik} \quad \forall i \in N, \forall k \in K$$ $$T^{\text{leave}}_{ik} = T^{\text{char}}_{ik} \cdot z_{ik} + T^{\text{change}}_{ik} \cdot g_{ik} \quad \forall i \in CS, \forall k \in K$$ $$T^{\text{arrive}}_{jk} = x_{ijk} \left( T^{\text{leave}}_{ik} + \frac{d_{ij}}{EVV} \right) \quad \forall i,j \in N, i \neq j, \forall k \in K$$
This comprehensive model captures the intricacies of electric vehicle car routing with hybrid energy replenishment, providing a foundation for algorithmic solution.
To solve the model, I design a genetic algorithm due to its global search capabilities and adaptability to complex constraints. The algorithm includes encoding, selection, crossover, mutation, and a specialized replenishment station insertion subroutine. For encoding, I use a permutation integer scheme. Given $n$ customers and $k$ electric vehicle cars, the chromosome length is $n + k – 1$, with genes ranging from 1 to $n + k – 1$. Numbers 1 to $n$ represent customers, and numbers $n+1$ to $n+k-1$ serve as separators to split routes. For example, with 20 customers and 6 electric vehicle cars, a chromosome might be [3, 15, 21, 7, 12, 24, 5, …], where 21 and 24 are separators. Decoding involves partitioning the chromosome at separators to form individual routes, each starting and ending at the distribution center (coded as 0).
The selection operator employs tournament selection. In each iteration, $m$ individuals are randomly chosen from the population, and the one with the best fitness (lowest total cost) is selected for the next generation. This process repeats until the new population is filled, promoting diversity and convergence speed. For crossover, I apply the partially mapped crossover (PMX) method. Two parent chromosomes are selected, and a crossover region is randomly defined. Genes within this region are swapped between parents, and conflicts outside the region are resolved through mapping relations, ensuring valid permutations. For mutation, I use inversion mutation: a subsequence within the chromosome is randomly selected and reversed, introducing local variations to escape local optima. The fitness function evaluates the total cost $C$ for each chromosome, incorporating constraints via penalty terms or repair mechanisms.
A key innovation is the replenishment station insertion algorithm, which handles battery and capacity constraints dynamically. The algorithm works in two phases. First, it checks vehicle capacity: for each route derived from the chromosome, the total customer demand is summed; if it exceeds $Q$, the solution is deemed infeasible. Second, it manages battery levels: as the electric vehicle car traverses the route from point $P_i$ to $P_{i+1}$, the nearest replenishment stations $M_i$ and $M_{i+1}$ are identified. If the electric vehicle car cannot reach $P_{i+1}$ or $M_{i+1}$ from $P_i$, station $M_i$ is inserted between $P_i$ and $P_{i+1}$. If insertion fails due to insufficient range, the solution is infeasible. This algorithm ensures realistic routing by simulating on-the-fly station selection, rather than predefining stations in the encoding.
To validate the model and algorithm, I conduct a numerical case study based on a adapted dataset. The scenario includes one distribution center, 20 customers, and 5 replenishment stations, with 6 homogeneous electric vehicle cars available. Customer locations are given in Cartesian coordinates (in kilometers), along with demand quantities and time windows. The distribution center is at (70, 75), and station locations are specified. For brevity, I summarize key data in the following tables.
| Point Type | Index | Coordinates (km) | Demand (t) | Time Window |
|---|---|---|---|---|
| Distribution Center | 0 | (70, 75) | – | – |
| Customers | 1 | (39, 69) | 0.32 | 04:20-05:00 |
| 2 | (47, 51) | 0.35 | 00:30-01:00 | |
| 3 | (46, 54) | 0.30 | 01:40-03:00 | |
| 4 | (56, 49) | 0.40 | 00:25-01:00 | |
| 5 | (57, 57) | 0.34 | 02:30-03:30 | |
| 6 | (51, 59) | 0.47 | 00:05-00:50 | |
| 7 | (45, 60) | 0.35 | 00:00-02:00 | |
| 8 | (66, 65) | 0.30 | 05:30-06:00 | |
| 9 | (61, 52) | 0.38 | 00:00-01:00 | |
| 10 | (36, 60) | 0.31 | 02:00-03:00 | |
| 11 | (40, 48) | 0.30 | 00:15-00:40 | |
| 12 | (48, 62) | 0.41 | 01:00-02:00 | |
| 13 | (49, 41) | 0.34 | 01:30-02:30 | |
| 14 | (56, 66) | 0.25 | 02:00-03:00 | |
| 15 | (45, 70) | 0.40 | 00:00-01:00 | |
| 16 | (36, 53) | 0.25 | 02:00-02:30 | |
| 17 | (38, 63) | 0.30 | 00:00-01:00 | |
| 18 | (51, 52) | 0.31 | 00:10-01:00 | |
| 19 | (44, 41) | 0.35 | 03:00-03:30 | |
| 20 | (39, 41) | 0.26 | 05:00-06:00 | |
| Stations | 21 | (45, 45) | – | – |
| 22 | (46, 66) | – | – | |
| 23 | (53, 44) | – | – | |
| 24 | (41, 55) | – | – | |
| 25 | (62, 62) | – | – |
Parameter settings are as follows: fixed vehicle operating cost $C^{\text{vehicle}} = 120$ per electric vehicle car, capacity $Q = 2$ t, speed $EVV = 35$ km/h, battery capacity $QOE^{\text{max}} = 55$ kWh, consumption rate $f = 0.5$ kWh/km, charging price $f^{\text{char}} = 0.75$ per kWh, service fee $f^{\text{service}} = 0.4$ per kWh, time cost $f^{\text{time}} = 20$ per hour, swapping price $f^{\text{change}} = 1$ per kWh, rental cost $f^{\text{rent}} = 50$ per swap, performance coefficient $\alpha = 24$ per hour, charging rate $\beta = 40$ kWh/h, swapping time $T^{\text{change}} = 0.08$ h, fixed salary $C^{FS} = 100$ per day, penalty coefficients $M_1 = 10$ per hour and $M_2 = 20$ per hour, and service time $T^{\text{service}} = 0.3$ h. The genetic algorithm uses a population size of 150, maximum iterations of 400, crossover probability of 0.9, and mutation probability of 0.05. For comparison, a particle swarm optimization (PSO) algorithm is also implemented with inertia weight 0.5 and learning factors 1.5.
After running both algorithms 10 times independently, the genetic algorithm achieves an average solution time of 94.30 seconds and a minimum total cost of 1803.36 units. In contrast, PSO averages 60.42 seconds but converges to a higher cost of 1857.91 units. The genetic algorithm demonstrates superior global search ability, reducing costs by 2.9% compared to PSO. This validates the choice of genetic algorithm for solving this electric vehicle car routing problem. The convergence plots show that PSO stagnates early, while genetic algorithm maintains diversity and finds better solutions.
To assess the hybrid replenishment model, I compare it against单一 modes. By setting $g_{ik} = 0$ or $z_{ik} = 0$, I derive single charging and single swapping models, respectively. Results are summarized in the table below.
| Replenishment Mode | Total Cost (units) | Time Window Penalty Cost (units) | Early Arrival Time (h) | Late Arrival Time (h) | Replenishment Time (h) | On-Time Deliveries (count) |
|---|---|---|---|---|---|---|
| Single Charging | 1926.00 | 207.50 | 0.97 | 9.80 | 4.28 | 7 |
| Single Swapping | 1951.16 | 188.50 | 2.20 | 8.27 | 0.32 | 7 |
| Hybrid (Charging + Swapping) | 1803.36 | 90.70 | 0.95 | 4.00 | 2.23 | 11 |
The hybrid mode reduces total cost by 6.4% compared to single charging and 7.6% compared to single swapping. It also slashes time window penalty costs by over 50%, with only 4 hours of late arrivals versus 9.8 and 8.27 hours for single modes. Moreover, on-time deliveries increase to 11 out of 20 (55% rate), indicating better service quality. These improvements stem from the flexibility to choose replenishment methods: charging is used when time permits to save costs, while swapping is opted for urgent deliveries to meet tight windows. This adaptability helps electric vehicle cars balance operational expenses and customer satisfaction.
I further conduct sensitivity analysis on time window constraints to evaluate model robustness. Two scenarios are tested: wide time windows (intervals exceeding 2 hours) and narrow time windows (intervals under 0.5 hours), alongside the original case. Results are shown in the following table.
| Time Window Scenario | Replenishment Mode | Total Cost (units) | Time Window Penalty Cost (units) |
|---|---|---|---|
| Wide | Single Charging | 1744.03 | 26.70 |
| Single Swapping | 1788.54 | 32.40 | |
| Hybrid | 1701.12 | 6.60 | |
| Original | Single Charging | 1926.00 | 207.50 |
| Single Swapping | 1951.16 | 188.50 | |
| Hybrid | 1803.36 | 90.70 | |
| Narrow | Single Charging | 2082.29 | 294.70 |
| Single Swapping | 2036.19 | 191.00 | |
| Hybrid | 1892.88 | 114.70 |
As time windows tighten, costs generally rise due to higher penalties. However, the hybrid mode consistently outperforms单一 modes. In wide windows, it saves 2.5% and 4.9% over single charging and swapping, respectively; in narrow windows, savings increase to 9.1% and 7.0%. The penalty costs for the hybrid mode remain significantly lower, demonstrating its ability to adapt to strict constraints. This sensitivity analysis confirms that the proposed model is effective across varying customer time requirements, offering logistics managers a reliable tool for electric vehicle car routing under uncertain conditions.
In conclusion, this paper presents a comprehensive optimization model for electric vehicle distribution that integrates both charging and battery swapping modes. By allowing dynamic selection of replenishment methods, the model enhances flexibility and reduces total costs while improving time window compliance. The genetic algorithm, coupled with a station insertion subroutine, provides an efficient solution method, outperforming alternatives like particle swarm optimization. Numerical experiments show that the hybrid approach achieves cost savings of 6.4–7.6% and boosts on-time delivery rates to 55%, compared to单一 modes. Sensitivity analysis further validates the model’s robustness under different time window constraints. These findings have practical implications for logistics companies adopting electric vehicle cars, as they can optimize routes, lower expenses, and elevate service quality. Future research could extend this work by incorporating stochastic elements, such as traffic congestion or variable energy prices, and exploring multi-depot or heterogeneous electric vehicle car fleets. Additionally, real-time data integration and machine learning techniques could further refine replenishment decisions, paving the way for smarter urban logistics systems centered on electric vehicle car sustainability.
