TraCI值与outpu不符

2024-04-28 07:05:40 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在模拟的最后一步执行traci.edge.getWaitingTime(str(-108542273))时,我从中得到一个值0。你知道吗

但是当我去验证生成的基于边缘的状态转储时,发现值是15。为什么traci值不能反映这一点?他们的意思不一样吗?你知道吗

<meandata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/meandata_file.xsd">
    <interval begin="0.00" end="602.00" id="edgebased">
       <edge id="-108542273" sampledSeconds="288.08" traveltime="6.77" density="8.67" occupancy="4.33" waitingTime="15.00" speed="8.15" departed="0" arrived="0" entered="39" left="39" laneChangedFrom="0" laneChangedTo="0"/>
       ... more edge entries
    </interval>
</meandata>

我在模拟的最后一步提取了值,所以我认为2应该反映相同的东西?你知道吗

这是我的全部python代码

import os, sys
import subprocess

if 'SUMO_HOME' in os.environ:
    tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
    sys.path.append(tools)
else:   
    sys.exit("please declare environment variable 'SUMO_HOME'")

def runTraCI():
    trip_outputFile = "trip.output.xml"
    vehroute_outputFile = "vehroute.output.xml"

    PORT = 8817
    sumoBinary = "sumo"
    sumoProcess = subprocess.Popen([sumoBinary, "-c", "data/tracitest.sumocfg", "--no-warnings", "true", "--remote-port", str(PORT),
        "--tripinfo-output", trip_outputFile, "--vehroute-output", vehroute_outputFile], stdout=sys.stdout, stderr=sys.stderr)

    import traci
    import traci.constants as tc
    traci.init(PORT) 
    step = 0
    edgeList = traci.edge.getIDList() #a list of edges of the network
    waitingTimeDict = {key: None for key in edgeList} # create an empty waitingTime dict
    while step <= 600:
        if (step % 300) == 0: # read reading every 300s
            for key, value in waitingTimeDict.iteritems():
                waitingTimeDict[key] = traci.edge.getWaitingTime(str(-108542273))
        traci.simulationStep()
        step += 1

    print waitingTimeDict #when I print this, every value is 0. In another word, edgeID("-108542273") waitingTime was return as 0 to me.
    traci.close()
    sys.exit()

runTraCI()

Tags: keyimportoutputosstepsysedgesumo
1条回答
网友
1楼 · 发布于 2024-04-28 07:05:40

meandata输出是随时间聚合的,因此它显示了间隔中等待时间的总和。但是,TraCI调用只返回上一个模拟步骤中给定边上的等待时间(不随时间聚合)。你知道吗

相关问题 更多 >