9.3.3. Multi-agent System

The MAS in the simulation consists of a world agent that controls the simulation and establishes the connection to the outside world (Internet), vehicle, and twin agents. The twin agent can either be the active controller of the vehicle agent (influencer) or a passive passenger. The vehicle agents implement different overlaid behaviour:


The vehicle agent consists of a set of activities performing specific actions and represent different micro-goals, basically: {*percept*, *plan*, *move*, *collect*, *wait*}. A vehicle agent represents a mobile entity and at least one human (a twin agent). The *collect* activity is able to bind more vehicle or twin agents (humans) to this vehicle entity, i.e., implementing vehicle grouping or sharing. Twin agents can be coupled to vehicle and communicate with each other via the tuple space of the mobile platform both sharing.

A vehicle has a direction *dir* and uses a set of sensors {*f*,*l*,*r*,*b*} providing information about the neighbourhood in front, left, right, and backward relative to current direction. Each sensor is an array with distance increasing with the array index. New sensor values are collected in the *percept* activity, shown in Algorithm 3.

**Algorithm 3.** Perception activity of the vehicle agent. Sensors k0, v0, and i can depend on twin driver agents, too.


The vehicle mobility and its planning are immediately influenced by its velocity *v*, the sensors *d* and *i*(*s*,*v*) limiting the distance to the next vehicle, and the force to keep the current direction (not turning) *k*. There is a current long-range direction *dir* and a short-range position correction Δ, an (x,y) delta vector, e.g., required for turns or street and direction changes.

The current street is given by the *s* sensor. A street *s* consists of coordinates {*x*,*y*,*w*,*h*}, a unique identifier *id* and a set of possible directions *dirs*. It is assumed that a street has three tracks (left, right, middle). A street has either a horizontal (*N*,*S*) or vertical alignment (*W*,*E*). *P*(*x*,*y*) is place in the world at position (*x*,*y*) with attributes *street*, *vehicle*, *signal*.

In automatic driving mode, the distance to a vehicle in front is limited to *d* = *v*δ/*dk* and depends on the security distance parameter δ and the current velocity of the vehicle.

The vehicle plans the next movement based on perception in activity *plan*, shown in Algorithm 4 (simplified pseudo code), finally executing the movement in activity *move*, shown in Algorithm 5.

A twin agent is divided in two sub-class behaviour: (1) Driver (2) Passenger. The twin agents implement basically the goal-driven behaviour of mobility and provides higher planning and routing levels influencing the vehicle. A driver twin agent directly controls traffic routing, whereas passenger twin agents influence the temporal flow of vehicles (by entering or leaving the vehicle).

**Algorithm 4.** Simplified planning activity of the vehicle agent, which can be depend on twin driver and partly on passenger agents, too



**Algorithm 5.** Simplified move activity of the vehicle agent. The gotoXY function moves the vehicle one step to a new free place minimizing minΔ→0

### 9.3.4. Evaluation

The traffic simulation was initially performed with a closed simulation world using a default behaviour model and traffic control parameter set. The outcome of this simulation was compared with an open simulation using agents with the same default behaviour extended with digital twins created from user surveys via crowd sensing agents. The major goal was to show the influence of variation by real-word digital twins on the simulation outcome and to identify relevant model parameters with significant impact. The traffic flow was controlled by light signals (red and green signals) positioned at each crossing corner. The default traffic signal switching is periodic with a state sequence {rr,gr,rr,rg}, with the first character assigned to all North-South signals, and the second character assigned to all West-East signals (r:red/g:green). Transition times were *t*<sup>1</sup> for gr|rg → rr transitions, and *t*<sup>0</sup> < *t*<sup>1</sup> for rr → gr|rg transitions.

In Figure 14, a closed simulation with vehicles (individual class) and different traffic signal switching times were investigated. The simulation started with an initial population of 200 vehicles at random starting positions. The plots show the time-resolved decrease of driving passengers and increase of arriving passengers (in this case vehicles with on driver as a passenger) due to arrival at a destination position. The first plot (a) uses a signal switch time (red ↔ green signal state) of 500, the second plot of 200 simulation time units. Either North-South (*NS*) streets get green lights, or the West-East (*WE*) streets. The switching time has a significant impact on the mean arrival time of vehicles, although vehicles uses *NS* and *WE* streets, but the arrival time do not depend on individual parameters, i.e., security distance and routing strategy (zig-zag versa straight-line). The vehicle flow depends on the routing behaviour (straight-line shows lower dependence on signal switching times).

In Figure 15, the simulation was extended with MCWS and digital twins posing individual behaviour. The MCWS users were chosen randomly. The goal of this simulation was to identify jams and the dependence on driver behaviour parameter. Two main parameters were identified: The security distance and routing (straight-line vs. zig-zag shortest path) behaviour. Again, about 200 vehicles were created, a fraction with a default behaviour, and another fraction with individual behaviour. The value of the security distance parameter δ has significant impact on the jam probability (defined by the number vehicles involved in jams relative to the overall number of vehicles). A value δ = 1.0 relates to a law-conforming driving style, a lower value means a riskier driving style with lower distances to other vehicles, and a higher number a more defence driving style. Lower security distances (relative to current vehicle velocity) increases the jam probability due to a modified vehicle flow (accidents are not considered here). The is more important if a straight-line routing style (parameter

greater than zero) is chosen by the driver. The last three bars in the plot show a distribution of the security-distance parameter (25%, 33%, 50%). Even a low fraction of 25% risky drivers increases the jam probability significantly.

**Figure 14.** Simulation with 200 vehicles with static traffic control showing the accumulated number of moving vehicles/passengers and the number of arrived vehicles/passengers (**Left**) t1/t0 = 500/60 signal change times (**Right**) t1/t0 = 200/60.

**Figure 15.** Simulation with 200 vehicles and different mobility parameters showing the probability of a jam.

Finally, the traffic control algorithm was evaluated in Figure 16. Again, the traffic flow of 200 vehicles with zig-zag routing was evaluated (δ = 1.0, σ = 0). Two traffic signal control algorithms were compared: On the left side the static global switching algorithm (with *t*1/*t*<sup>0</sup> = 500/60), and on the right side a dynamic local switching algorithm with dynamic switching times based on vehicle flow densities before each signal of a crossing. The global mode switches all signals of crossings globally and periodically, the local mode switches signals of each crossing individually. The dynamic flow-based switching increases arrival times by 2 times, and the velocity of vehicles shows low modulations and is near by the default velocity *v* = 50 (arb. units).

**Figure 16.** Simulation of 200 vehicles (σ = 0.0,δ = 1.0): (**Top**) Temporal development of number of mobile vehicles/passengers and number of vehicles/passengers reached destination (**Bottom**) Mean velocity of moving vehicles and number of moving vehicles (**Left**) Without traffic control with t1/t0 = 500/60 signal change times (**Right**) With dynamic flow traffic management.

To summarise, individualism of behaviour model parameters derived by real-world sensing (eventually in real-time) like driving style (security distance, routing) can influence crowd and vehicle flows significantly and hence has to be considered by traffic control to optimise traffic and crowd flows. It is important to get a representative model parameter set from an actual traffic situation to be able to predict flows and to control traffic.

### **10. Conclusions**

The MAS simulation framework presented in this work provides the bidirectional integration of real-world data via agent-based crowd sensing, agent-based modelling, and agent-based simulation via data mining, i.e., applying DM in ABMS by creating generated simulation data and applying ABMS in DM by backpropagating generated simulation data. The framework is suitable to combine social and computational simulations with real-world interaction at run-time and in real-time by using mobile computational agents. The simulator supports two classes of agents. Physical agents only exist in the virtual world and correspond to *NetLogo* agents, whereas computational agents can exist in real and virtual worlds and create the bridge between the two worlds.

The *JAM* agent processing platform is the core component in the simulator and crowd sensing system that can be deployed in heterogeneous networks on a broad range of devices including simulation software. This is enabled by programming *JAM* and agents in *JavaScript*. Chat bots with dynamic (situation and context-dependent) dialogues can be implemented with *JAM* agents directly using a unified dialogue structure and API.

Two key concepts in the augmented simulation approach are parametrizable behaviour models and digital twins created from surveys via crowd sensing.

Different use-cases demonstrate the augmented simulation approach with social or socio-technical interaction models. First, a classical social interaction study was performed based on a parametrizable Sakoda model, second, a reactive and interactive city light management was sketched, and third, a crowd-based city traffic control was investigated. Digital twins retrieved by agent-based crowd sensing extended agent-based simulation with variance and a broader range of model parameter settings. The crowd sensing performed by mobile agents is used to create digital twins of real humans (with respect to the social interaction model and mobility) based on individual surveys via a chat bot dialogue. Chat bots are the link between virtual and physical worlds.

It could be shown that social interaction and individualism (variance) has a relevant impact on traffic control and crowd or vehicle flows, hence social models overlay technical models. It is important to get a representative model parameter set and distributions from real-world situations by crowd sensing for accurate system prediction and control.

In the future, we aim to use the framework in order to investigate different environments in quasi-experimental set-ups with broader data and user range.

Finally, the system behaviour and cross interaction effects should be studied with hybrid models, i.e., the combination of the social interaction model describing group formations, e.g., Sakoda model, with mobility models, e.g., mobile vehicles, or by combining agent-based with analytical models to strength the simulation output.

**Author Contributions:** S.B. provided content and methodologies related to the computer science parts, social models, and performed the experiments, U.E. provided content for the general concepts and methodologies related to the social science parts of the paper.

**Funding:** There was no founding.

**Conflicts of Interest:** There are no conflicts of interest.

### **Appendix A Comparison of NetLogo and SEJAM Simulations**

The well-known and established *NetLogo* simulator is (commonly) used for the ABM domain only. In contrast, the *SEJAM* simulator is primarily used for the ABC domain, although any physical simulation can be transformed into a computational task implementing the behaviour of a physical entity. The fusion of real worlds deploying computational agents (that interact with machines and humans) with virtual simulation models requires a mapping methodology to be able to simulate physical agents (i.e., artefacts of real entities) using computational agents.

Computational agents as mobile software processes require a connected communication network of host platforms (computers) to migrate along a path *AB*. A human being, in contrast, does not require such a digital transport network. In a simulation world, a physical (purely behavioural) agent can overcome arbitrary distances in one step (in principle).

To combine social interaction and computational simulation models, the *SEJAM* simulation model was extended by two super classes of agents: (1) computational and (2) physical agents. A physical agent can only exist in the virtual simulation world and consists of a <*logical node, physical agent*> tuple. The physical agent is bound to his node and can change its position only by moving the node carrying the agent. In contrast, computational agents are mobile and can hop from one platform to another if there is a communication link between both platforms by performing process serialisation and deserialisation. The link can be virtual (inside the simulation world) or physical connecting a logical node of the simulation world with another *JAM* platform in the real world (e.g., a smartphone) via the Internet.

The mapping of *NetLogo* model constructs and statements on the *SEJAM* simulation model basically consists of a simulation API extension. Physical agents represent turtles (active agents) and resources representing patches. The patch grid world is discretised, although *SEJAM* is not limited to and can model any two-dimensional world. In *NetLogo*, the agent behaviour is entirely controlled and executed by a global observer (centralised macro control), whereas in *SEJAM* the agent behaviour is controlled and executed by each individual agent (decentralised micro-control).
