• No results found

Comparing Synchronous and Asynchronous Updating

When a model is simulated it is done in a time-stepped manner. In an ABM this is sometimes known as clockwork. In clockwork, each step in the simula- tion occurs at a fixed time interval and during each step every agent performs some behaviour. In DES time is event-based. Event-based simulation events are scheduled to occur at particular times. These events are kept in a time ordered queue. The next event scheduled to occur is taken from the front of the queue and the clock time advanced to match that of the event. DES relies on event-based time while CA and ABSS use clockwork. As we have seen clockwork has been adopted by the major agent toolkits such as NetLogo, Repast, Mason and Swarm [North et al., 2013b, Luke et al., 2005, Berryman, 2008]. It is the clockwork ap- proach that is of interest here.

The synchronous and asynchronous approaches to updating define how we han- dle multiple events occurring simultaneously or at the same time, i.e. during the same step.

Asynchronous Updating To accurately simulate actions that may occur simulta- neously it is sufficient that during each time interval all agents are restricted to acting one at a time in some well defined sequence. That is, this sequenc- ing of actions is in effect equivalent to those actions occurring simultane- ously.

Synchronous Updating SU holds that, in contrast to AU, to accurately simulate a world where events can happen simultaneously it is necessary to perform those simultaneous actions concurrently.

with each.

2.8.1 Asynchronous Updating

The asynchronous approach assumes that there is no global clock that forces agents to interact in lockstep [Huberman and Glance, 1993] with each other. We can get this same effect, it is argued, by allowing each agent behaviour to occur in sequence within a step. That is, agents acting simultaneously during a time step can be ac- curately simulated by just letting each agent act in sequence. While it is conceded that using a particular ordering of behaviours might cause artifacts in the simula- tion it is assumed that these can be overcome by employing a different ordering during each step. In any case overall behaviour can be ascertained by running the simulation multiple times and looking for patterns in the outcomes.

There are two different approaches to asynchrony Step Driven and Time Driven and they can be further subdivided into [Sch¨onfisch and de Roos, 1999]:

Fixed Direction Line-By-Line The locations in the lattice representing the simu- lation space are updated in the order they appear in the lattice (usually left to right, top-down). This is a deterministic ordering in that the ordering remains the same during every simulation run. When a simulation employs this ap- proach it is impossible to tell if the emergent properties of the simulation are due in whole or part to the particular ordering used. Properties that are due to the ordering used are known as ertifacts. Because this determinacy can cause artifacts it is the least favoured approach;

Fixed Random Sweep The order that is used is determined randomly at the start of the simulation and this order is constant for every step in the simulation. Here the ordering is specific to each simulation run. In any particular simu- lation run the ordering is deterministic and does not vary from step to step. As each simulation run uses a different ordering this approach allows dif- ferent runs to be compared and contrasted to see if any emergent properties are artefacts due to the particular orderings employed or not. This is a major improvement over Fixed Direction LineBy-Line;

Random New Sweep The order that the agents are updated in is determined ran- domly at the start of each step (each step uses a different order). This ap- proach is, in a weak sense, fairer than the previous approaches because the ordering is randomly chosen from time step to time step. No one location

has a lasting advantage over any other location over time. Artifacts appear to be less common under this approach;

Uniform Choice Each agent has an equal probability of being chosen. If there are n agents, then n agents are chosen randomly during a step. During any single step an agent may not be picked at all or may be picked more than once (in contrast Random New Sweep guarantees every agent is picked exactly once per step);

Exponential Waiting Time This is a Time Driven method, all the others are step driven. Every agent has its own clock which rings when the agent is to be updated. The waiting times for the clock are exponentially distributed (with mean 1). The probability that an event occurs at time t follows e−twhere t is a real number, t ≥ 0. This is most similar to Uniform Choice.

Most of these introduce nondeterminacy into the simulation and so every run of the simulation will use a different set of orderings and will most likely produce different outcomes. Determining the outcome of a simulation might therefore re- quire us to produce multiple runs and compare their outcomes for similar patterns of overall system level behaviour.

There is no established SU algorithm for ABM that overcomes the technical difficulties associated with concurrent agent interaction (for example, two or more agents attempting to move to the same location). As a result of this the asyn- chronous approach is almost exclusively used in ABM. We will look at SU and its associated problems next.

2.8.2 Synchronous Updating

Adherents of the synchronous approach argue that, as the events are occurring simultaneously, they should be implemented in that manner. This is achieved by letting each agent see the state of the world only as it was at the start of the step. They then perform their behaviours based on that information. Any updates that the behaviours make to an agents state do not get applied until the end of the step, once all agents have completed their behaviours. This makes the updates appear as if they were applied simultaneously.

For simple CA-based simulations where each agent only reads the state of ad- jacent agents and can only update their own state, synchronous updating is easily implemented. However for an ABSS where behaviour can be complex and agent

behaviour may update not just the agent performing the behaviour but also its sur- rounding agents the synchronous approach is more difficult to implement. If we take the example of simple agent movement, an agent must update the status of two locations, during a move the location where the agent currently resides is va- cated while the destination location changes from being vacant to containing the moving agent. If two or more agents try to move to the same location then we have a collision and a decision must be taken as to how this is handled.

Any SU approach must have a sensible way of handling collision detection and since detection of collisions is not enough it must also provide some collision reso- lution mechanism that resolves the issue properly. These mechanisms become part of the agent behaviour definitions as they will affect how the simulation proceeds.

If we return to the Movement example we can see that there are numerous possible ways of handling agent collisions:

1. One agent is chosen at random to be the winner;

2. The agent who was nearest the destination can be deemed the winner (he would have gotten there first);

3. The strongest agent wins (by some agreed measure of strength).

Even once a resolution mechanism is decided upon there is the question of how the losing agents are death with:

1. The losing agents return to their starting position. In effect they miss a go and remain stationary for this move. A punishment for attempting to move to the wrong destination;

2. Losing agents get another go. Here we assume they would have spotted to imminent collision and moved to a different destination (side stepping the potentially colliding agent).

Each choice will lead to a different dynamic and so needs to be justified in the context of the simulation. Any collision resolution strategy must also be aware of and be able to avoid potential deadlock situations. Consider a trading behaviour. Each agent chooses an agent that they wish to trade with and then performs some trade. Under SU, agent A might choose to trade with agent B while agent B wishes to trade with agent C who, in turn, wants to trade with agent A. In this case we have circular waiting and unless there is some method of breaking the circular dependency each will wait for the other agent forever (A waits to hear back from B

before replying to C’s request, B waits to hear back from C before replying to A’s request and C waits to hear back from A before replying to B’s request).

AU avoided all these problems by forcing a sequential ordering on actions. Only one agent (under AU) can act at a time so there can be no collisions.

It is the difficulties that SU has in handling these collisions in a sensible manner that has resulted in AU being almost exclusively favoured in ABM. There have been a number of attempted approaches to handling the collision resolution issue and we will look at these proposed solutions in the following subsection.