## 6 Dynamic Path Optimization with Charging Selection
### Optimization Model  
In this paper, AEVs can calculate their travel costs and charging costs based on real-time traffic conditions and the service status information of the charging infrastructure in the network. The travel cost and charging cost of each AEV are expressed as a weighted sum with specific weights. Therefore, the optimization model can be formulated as follows:\[\min_{\begin{subarray}{c}x_{ij}^{k}(t_{k})\\ y_{ij}^{k\sigma_{ij}}(t)\\ y_{ij}^{k\sigma}(t)\end{subarray}}\Bigg{\{}w_{r}\bigg{(}\sum_{ \begin{subarray}{c}i=s\\ j\in O(l)\end{subarray}}^{j=d}\Big{(}p_{t}\tau_{ij}^{k\prime}(t)+p_{e}E_{ij}^{k} (t)\Big{)}x_{ij}^{k}(t)\bigg{)}+w_{c}\Bigg{(}\sum_{\begin{subarray}{c}\alpha_{i }\in\mathbb{U}_{\alpha_{i}}\\ (i,j)\in\Theta,\\ \end{subarray}}\Big{(}\Big{(}p_{t}\Big{(}x_{cs}^{k,w}(t)+x_{cs}^{k,c}(t) \Big{)}+p_{cs}E_{a}^{k}\Big{)}y_{cs}^{kcs}(t)+p_{r}\tau_{ij}^{k,c}\lambda y_{ij }^{kcs}(t)\Big{)}  
about this path optimization is how to set the TFD threshold. The answer to this question is shown in Section 8.2.  
For the path-optimization problem (31), we propose a DRT-A* algorithm. Compared with A* algorithm [45], we conduct a path search based on real-time traffic condition information and consumption of charge, and adjust the start-destination pair considering traffic conditions and the SoC level of AEV to achieve dynamic real-time path-planning, as shown in Algorithm 2.  
```
1:Input: Map, Start-Destination (travel or charging infrastructure) pair, SoC
2:Output: The optimal path from the start node to destination.
3:Initialize t=simulation.start
4:Calculate Equation (21), Equation (32)
5:while traci.simulation.getMinExpectedNumber()>0 do
6: Set current node=start node
7: Put start node into openset.
8:while openset is not empty do
9:for neighbors in map[current node] do
10:if next node in openset then
11:t_travel(t)[current node,next node] \(\leftarrow\) Equation (5)
12:E(t)[current node,next node] \(\leftarrow\) Equation (16)
13:e(t)[next node] \(\leftarrow\) Equation (33)
14:g(t)[next node] \(\leftarrow\) Equation (34)
15:f(t)[next node] \(\leftarrow\) Equation (34) + Equation (35)
16:if e(t)[next node] \(\leq\) C(t)[next node]&&the node with lowest f(t)[next node] then
17: Update g(t)[next node]
18: Update t and SoC
19:endif
20:else
21: Put next node into openset
22:endif
23:endfor
24:endwhile
25:if current node == Destination then
26: Return path
27:endif
28:if destination charges then
29: Update start-destination pair
30: Go to line 6
31:endif
32:endwhile
```  
**Algorithm 2** : DRT-A* algorithm.  
Compared with the fixed travel cost in the A* algorithm, we discuss the consumption of charge cost \(e_{i}(t)\) and redefine the real-time travel cost \(g_{i}(t)\) and estimated travel cost \(h_{j}(t)\) in the DRT-A* algorithm.  
\(e_{i}(t)\) is the consumption of charge cost from the starting node \(s\) to the current node \(i\), initialization \(e_{s}(t)=0\), and the consumption of charge cost of the neighbor node \(j\) of the current node \(i\) is expressed as,  
\[e_{j}(t)=e_{i}(t)+E_{ij}(t). \tag{33}\]  
\(g_{i}(t)\) is the travel cost from the starting node \(s\) to the current node \(i\), initialization \(g_{s}(t)=0\), and the travel cost of the neighbor node \(j\) of the current node \(i\) is expressed as  
\[g_{j}(t)=g_{i}(t)+p_{i}\tau_{ij}^{r}(t)+p_{e}E_{ij}(t). \tag{34}\]\(h_{i}(t)\) is the estimated travel cost from the node \(i\) to the destination node \(d\),  
\[h_{i}(t)=p_{t}\tau_{i,d}^{r}(t)+p_{e}E_{i,d}(t). \tag{35}\]  
In terms of complexity, compared with the A* algorithm, the DRT-A* algorithm simplifies the road network \(G\) based on TFD and SoC, therefore shortening the calculation time.