简体   繁体   中英

Make OD file in sumo using Node instead of TAZ

I have data of a network (siouxfalls) and want to make simulation with it in SUMO. For OD file, I have the demand between each node (not the links): https://github.com/bstabler/TransportationNetworks/blob/master/SiouxFalls/SiouxFalls_trips.tntp

As I know, to make OD file in SUMO, we should use TAZ (not the node): https://sumo.dlr.de/docs/Demand/Importing_O/D_Matrices.html

So, this is my question: How can I make trips and simulation with sumo, when I have the value of demands between nodes?

You can build a district (TAZ) file where each TAZ has the outgoing edges of a node as source edges and the incoming edges of a node as incoming. You can safely reuse the node id as a taz id here.

<tazs>
    <taz id="<TAZ_ID>">
      <tazSource id="<EDGE_ID>" weight="<PROBABILITY_TO_USE>"/>
      ... further source edges ...

      <tazSink id="<EDGE_ID>" weight="<PROBABILITY_TO_USE>"/>
      ... further destination edges ...
    </taz>

    ... further traffic assignment zones (districts) ...

</tazs>

To build that programmatically you can parse the network with sumolib (incomplete sketch below):

import sumolib
net = sumolib.net.readNet('myNet.net.xml')
for node in net.getNodes():
    print('<taz id="%s">' % node.getID())
    for outEdge in node.getOutgoing():
        print('<tazSource id="%s"/>' % outEdge.getID())
    for inEdge in node.getOutgoing():
        print('<tazSink id="%s"/>' % inEdge.getID())
    print('</taz>')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM