您可以构建一个区域 (TAZ) 文件,其中每个 TAZ 将节点的出边作为源边,将节点的传入边作为输入。您可以在此处安全地重用节点 ID 作为 taz id。
<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>
要以编程方式构建它,您可以使用 sumolib 解析网络(下面的不完整草图):
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>')