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.

XML File, expat Structured Text File, Structured Text File, fscanf<br />

159s 31s 36s<br />

Table 3.1: Performance results for reading different types of plans file and approaches.<br />

In the example, 6357250 is the vehicle ID, 0 in the first line shows the leg number, and<br />

24875 is the start time of the plan in seconds (06:54:35). The start accessory ID and the end<br />

accessory ID are 14584 and 14606, respectively. An accessory can be an activity location, a<br />

parking or a transit stop. Duration of the leg is 1800 seconds (30 minutes). The 0 in the third<br />

line shows the mode of transport (car). 8 is the number of the intermediate nodes between the<br />

start and the end activity locations, and these nodes are lined up in the last line.<br />

The performance is user-implementation dependent. One version of implementation keeps<br />

each vehicle’s data in integers in an STL-vector while reading. When the vehicle is created,<br />

the program accesses the values from the STL-vector. The code elements are given in<br />

Figure 3.13.<br />

Yet another version uses a C library function called fscanf to read chunks of data. The<br />

data is directly stored into integer arrays similar to the STL-vector used above. Once the<br />

vehicle is created, its variables are set using these integer arrays. A rough example code is<br />

given in Figure 3.14.<br />

Results<br />

Table 3.1 shows the results for different reading approaches and for different types of the plans<br />

file. The scenario used is the one explained in Section 2.5, i.e., around 1 million agents are<br />

read. The numbers show the time for reading and for constructing agents. Once the agents are<br />

created, they are inserted into one of the supplementary structures of the links, such as waiting<br />

queues and parking queues. These queues are of the STL-multimap type.<br />

Reading the same data from the structured text plans file gives better results by 80% relative<br />

to the XML file version. Despite its lower performance values, XML is a promising technology<br />

because of its benefits as given in Section 3.4.1.<br />

An important remark to be made is that the lower performance values of XML come mostly<br />

from the implementation inefficiencies, not from format itself: While expat parses the input<br />

plans file, an object-oriented wrapper around expat inserts each person’s data (plans and the<br />

other attributes) into an STL-deque. If the traffic flow simulator needs to read the next person,<br />

the wrapper calls pop front() to get and to remove the first element from the STL-deque.<br />

A problem resides here: The STL-deque is used in a way that it keeps the objects as opposed<br />

to keeping pointers to the objects. When a pop front() call is made on such a container,<br />

before deleting the element, the wrapper copies the element into a temporary variable. Then,<br />

the element is deleted from the STL-deque and the temporary variable is returned (copied)<br />

to the traffic flow simulator. If one used pointers to objects instead of objects themselves, not<br />

only memory allocation would be done once and in an efficient way but also the pointers to<br />

objects would be copied between different components via copying pointers instead of copying<br />

the objects themselves, which that would result in less overhead.<br />

3.4.4 XML vs Structured Text Files: Graph Data Reading<br />

The graph data can also be kept in two different types of files. Nodes and links are defined by<br />

either XML attributes or column-based numbers. The XML graph data file reading is the same<br />

31

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

Saved successfully!

Ooh no, something went wrong!