# A Lookahead Behavior Model for Multi-Agent Hybrid Simulation
## 4 The Lookahead Behavior Model
### Time Window-Based Lookahead
That is, for \(agent_{1}\), the action \(a_{0}^{1}\) corresponds to the internal state transition \(\delta_{\text{int}}^{1}\), which will cause \(agent_{1}\) to change its state from \(t_{start}(a_{0}^{1})\) to \(t_{start}(a_{0}^{1})+t_{duration}(a_{0}^{1})\). For \(agent_{2}\), the state is changed by the internal state transition \(\delta_{\text{int}}^{2}\). With the change in the speed vector, the spatial positions of agents might change, which could lead to the occurrence of interactions, such as detections. Without any consideration of interactions between \(agent_{1}\) and \(agent_{2}\), two events for performing action \(a_{0}^{1}\) can be created to perform the internal state transition. The \"start action\" event for \(a_{0}^{1}\) is represented as \(E_{0}\), while the \"ending action\" event for \(a_{0}^{1}\) is denoted as \(E_{1}\). Let \(t_{1}=t_{start}(a_{0}^{1})\), and \(t_{2}=t_{start}(a_{0}^{1})+t_{duration}(a_{0}^{1})\). The initial situation is illustrated in Figure 5a. After the two events for \(a_{0}^{1}\) are scheduled, the time window can be obtained as \(T_{window}=[t_{1},t_{2}]\) according to Definition 2. Then, the intersection of functions \(\delta_{\text{int}}^{1}\) and \(\delta_{\text{int}}^{2}\) can be calculated to generate the \(interaction_{1,2}\) between \(agent_{1}\) and \(agent_{2}\) within the time window. Supposing that \(interaction_{1,2}\) will occur at \(t_{3}\), the interaction event will be \(E_{3}=E_{1,2}=<agent_{1},agent_{2},t_{1},t_{3},interaction_{1,2}>\), according to Definition 3. The situation after the lookahead process is illustrated in Figure 5b. It is a remarkable fact that the \(t_{3}\) is a time in the future, indicating that the event \(E_{3}\) is a result of the prediction of the lookahead. In the processing of \(E_{3}\), the original state transition for \(agent_{1}\) might be interrupted. The state of \(agent_{1}\) will be updated and resynchronized with \(agent_{2}\). Meanwhile, the event \(E_{2}\) could be canceled if the action \(a_{0}^{1}\) can only be partially carried out as \(\overline{a}_{0}^{1}\). Under the circumstances, the following action sequence of \(agent_{1}\) will be regenerated at \(t_{3}\) as \(\overline{\Lambda}^{1}=(\overline{a}_{0}^{1})\). The time window-based lookahead algorithm shown above can be described as Algorithm 1. The duration of action \(t_{duration}\), along with the start time of action \(t_{start}\), is determined when the action  
Figure 5: The lookahead principle based on the time window. **(a)** The initial state. **(b)** The state after the lookahead procedure. is created. The _predictInteraction (\(a_{0}\),\(a_{i}\))_ procedure refers to the calculation of the intersection of two internal state transition functions, which are related to \(a_{0}\) and \(a_{i}\), respectively. ```
Input: next action to be performed at the moment by the primary Agent0: \(a^{0}\); duration of action: \(t\)duration Variables: \(t_{current}\)// current simulation time Output:\(EventSet=\left\{(Event_{j},StateLookahead_{j})\right\}\)
1\(T_{window}=[t_{current},t_{current}+t_{duration}]\)
2 AgentList = getAgentsMayIntervalWithAction (\(a^{0}\))
3 foreach\(agent_{i}\) in the AgentList
4\(a^{i}=getCurrentPerformingAction(agent_{i})\)
5\(InteractionSet=predictInteraction(a^{0}\),\(a^{i}\))
6 foreach\(interaction_{j}\) in the \(InteractionSet\)
7\(t_{j}=getPredictedTimeOfInteraction\) (\(interaction_{j}\))
8\(StateLookahead_{j}=getPredictedStateOfInteraction(interaction_{j})\)
9 if(\(t_{j}\subseteq T_{window}\))
10\(Event_{j}\) = createEventFrominteraction(agent\({}_{0}\), \(agent_{i}\), \(t_{j}\), interaction)
11\(EventSet\leftarrow(Event_{j},StateLookahead_{j})\)
12 endif
13 endfor
14 endfor
```  
**Algorithm 1**_Time window-based lookahead algorithm._  
According to Algorithm 1, after the interaction between the primary agent and the other agent in the time window is predicted, the corresponding interaction event can be created according to the predicted time and the agents who participate in the interaction.