01.01.2015 Views

LARGE-SCALE PARALLEL GRAPH-BASED SIMULATIONS - MATSim

LARGE-SCALE PARALLEL GRAPH-BASED SIMULATIONS - MATSim

LARGE-SCALE PARALLEL GRAPH-BASED SIMULATIONS - MATSim

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

t y p e d e f multimap- Time , Veh WaitQueue ;<br />

WaitQueue waitQueue ;<br />

t y p e d e f multimap- Time , Veh ParkQueue ;<br />

ParkQueue parkQueue ;<br />

Figure 3.8: Declarations for waiting and parking queues with the STL-multimap<br />

t y p e d e f Linked- Time , Veh WaitQueue ;<br />

WaitQueue waitQueue ;<br />

t y p e d e f Linked- Time , Veh ParkQueue ;<br />

ParkQueue parkQueue ;<br />

Figure 3.9: Declarations for waiting and parking queues with linked lists<br />

queue is not full, the vehicle is moved from the waiting queue into the spatial queue so that it<br />

can start its trip.<br />

Hence, in each time step, waiting and parking queues are checked for the eligible vehicles.<br />

In realistic scenarios, most of the vehicles wait in these queues because their drivers are actually<br />

performing an activity. Checking for all eligible vehicles and accessing their information and<br />

moving them to other queues when necessary comes with computational cost. Therefore, an<br />

appropriate data structure should be used for these queues. That data structure needs to make<br />

available the vehicle with the next scheduled departure at low performance cost. For this, a<br />

partial ordering would in fact be sufficient. However, there is no data structure in the STL<br />

which supplies a fully efficient partial ordering. Therefore, two fully ordered data structures<br />

were tested: the STL-multimap, and a self-implemented singly linked list.<br />

Note that this section only discusses waiting and parking queues. Data structures for link<br />

cells will be explained in the next subsection.<br />

Multimap<br />

An easy-to-use fully sorted data structure is the STL-multimap. One just inserts key-item<br />

pairs, with the keys equal to the start time of vehicles and the items being pointers to vehicles,<br />

and the resulting data structure is automatically sorted. The difference between the STL-map,<br />

as mentioned above, and the STL-multimap is that the latter accepts multiple elements for<br />

the same key. This is necessary since it is possible that several vehicles want to depart at the<br />

same time step. The declarations by using STL-multimap are given in Figure 3.8.<br />

User-defined singly linked list<br />

There are three operations defined on these queues: Insertion of an element into a queue, retrieving<br />

the first element of the queue, and deleting the first element of the queue. Unfortunately<br />

these operations are rather costly with the STL-multimap. From the experiences in the C<br />

version of the simulation where a linked list was been used for these queues, a linked list is<br />

implemented also in the C++ version to handle waiting and parking queues.<br />

The Linked class in Figure 3.9 represents a singly linked list where each item in the list<br />

has a pointer to the next item. Insertion at the end of the list and insertion according to a key<br />

value into the sorted list are available. The latter is important so that vehicles can be sorted<br />

according to their start times.<br />

25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!