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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

the street network is explained in Section 3.3.3. The same section promotes an alternative data<br />

structure, namely, a self-implemented singly linked list, and gives the test results for these two<br />

implementations. Section 3.3.4 discusses different implementations for the link queues, i.e.,<br />

the spatial queue and the link buffer. The alternatives are using STL-deque, STL-list and<br />

a self-implemented data structure Ring.<br />

3.3.1 The Standard Template Library<br />

The Standard Template Library (STL) is a C++ library composed of the following components:<br />

Collections of standard container types. Containers are implemented as templates, a<br />

special feature of C++ and contain objects of any type. Examples are map, deque<br />

(double-ended queue), vector, list, etc.<br />

Algorithms defined on containers. Examples are: accessing an element, sorting the elements<br />

in a container, searching for an element, etc.<br />

Iterators used for traversing the elements of a container.<br />

The STL not only hides the implementation details of its components but also provides<br />

elegant data structures and algorithms for users. Encapsulation and abstraction properties of<br />

STL enables programmers to focus on application specific issues.<br />

The STL provides two types of containers: Sequence containers store data in a linear sequence.<br />

The “sequence” depends on time and position of insertion. The position of an element<br />

in the container is independent of the element’s value. vector, deque and list are of this<br />

type.<br />

Associative containers, on the other hand, are sorted data structures. They associate the<br />

domain of one type (key) with the domain of another type (value). The position of an element<br />

in such a container depends on its key. Examples are map, multimap, set, etc.<br />

Operations defined on containers, such as insert, delete, or retrieve, differ in performance.<br />

Container selection is dependent on characteristics of the applications and on call frequency.<br />

Some examples are given in next sub-sections.<br />

Each iterator represents a certain position in a container. Regardless of the container for<br />

which it is defined, an iterator comes with a set of basic operators. The basic operators are ++<br />

(stepping forward to the next element), == (equal), != (not equal), = (assignment operator)<br />

and * (dereference operator). Since an iterator is an object, the user must create instances of<br />

the iterator class prior to using them.<br />

3.3.2 Containers: Map vs Vector for Graph Data<br />

Accessing the graph data, i.e. the street network, is one of the key issues in the simulation.<br />

This is because every single item (a link or a node) of the graph is visited several times in each<br />

time step during the simulation run. Moreover, the searching algorithm for the elements of a<br />

container, which represents the graph data, is crucial since searching for a single element in the<br />

graph data is done more than once: (1) when plans are read, the start and the end locations have<br />

to be searched in the graph data, and (2) every time a vehicle on a link at the border needs to<br />

enter the next link, the next link is searched in the graph data to find out, to which computing<br />

node it belongs in the parallel implementation.<br />

The overall approach of using STL containers for the graph data looks as Figure 3.1 (using<br />

graph nodes as the example 1 .)<br />

1 For non-C-experts: typedef aa bb means that from now on, bb will be translated to aa before the<br />

19

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

Saved successfully!

Ooh no, something went wrong!