Esempio n. 1
0
def getMinTravelTime():
    genRoutes(1, 'u', 1, 'u', 0, 'u', 0, 'u', 0)

    gui = False

    setTLType('sumoConfig\one_intersection\cross.net.xml', 'static')
    changePhaseDurations('sumoConfig\one_intersection\cross.net.xml', 1000, 6,
                         1, 6)

    if gui:
        sumoExe = "guisim"
        sumoConfig = "sumoConfig\one_intersection\cross.sumocfg"
        sumoProcess = subprocess.Popen("%s -c %s" % (sumoExe, sumoConfig),
                                       shell=True,
                                       stdout=sys.stdout)
    else:
        sumoExe = "sumo"
        sumoConfig = "sumoConfig\one_intersection\cross.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000"
            % (sumoExe, sumoConfig),
            shell=True,
            stdout=sys.stdout)

    sumoProcess.wait()

    doc = libxml2.parseFile('tripinfo.txt')
    travelDur = int(doc.xpathEval("/tripinfos/tripinfo/@duration")[0].content)
    doc.freeDoc()

    return travelDur
Esempio n. 2
0
def getMinTravelTime():
    genRoutes(1, 'u', 1, 'u', 0, 'u', 0, 'u', 0)

    gui = False

    setTLType('sumoConfig\one_intersection\cross.net.xml', 'static')
    changePhaseDurations(
        'sumoConfig\one_intersection\cross.net.xml', 1000, 6, 1, 6)

    if gui:
        sumoExe = "guisim"
        sumoConfig = "sumoConfig\one_intersection\cross.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)
    else:
        sumoExe = "sumo"
        sumoConfig = "sumoConfig\one_intersection\cross.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)

    sumoProcess.wait()

    doc = libxml2.parseFile('tripinfo.txt')
    travelDur = int(doc.xpathEval("/tripinfos/tripinfo/@duration")[0].content)
    doc.freeDoc()

    return travelDur
Esempio n. 3
0
def getSaturationFlow():
    genRoutes(300, 'u', 3600, 'u', 0, 'u', 0, 'u', 0)

    gui = False

    setTLType('sumoConfig\cross_sat\cross_sat.net.xml', 'static')
    changePhaseDurations('sumoConfig\cross_sat\cross_sat.net.xml', 1800, 6,
                         300, 6)

    if gui:
        sumoExe = "guisim"
        sumoConfig = "sumoConfig\cross_sat\cross_sat.sumocfg"
        sumoProcess = subprocess.Popen("%s -c %s" % (sumoExe, sumoConfig),
                                       shell=True,
                                       stdout=sys.stdout)
    else:
        sumoExe = "sumo"
        sumoConfig = "sumoConfig\cross_sat\cross_sat.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000"
            % (sumoExe, sumoConfig),
            shell=True,
            stdout=sys.stdout)

    sumoProcess.wait()

    doc = libxml2.parseFile('sumoConfig\cross_sat\cross.out')
    veh = [
        int(d.content)
        for d in doc.xpathEval("/detector/interval[@id='SAT']/@nVehEntered")
    ]
    doc.freeDoc()

    sumVeh = [sum(veh[1:(i + 1)]) for i in range(len(veh))]

    xSat = range(323, 538)
    ySat = sumVeh[323:538]
    [aSat, b] = linreg(xSat, ySat)
    print('Saturation flow: ', aSat * 3600)
    ySatN = [aSat * xSat[i] + b for i in range(len(xSat))]

    x = range(700, 850)
    y = sumVeh[700:850]
    [a, b] = linreg(x, y)
    print('Saturation flow 2: ', a * 3600)
    ynew = [a * x[i] + b for i in range(len(x))]

    #    plot(range(len(veh)), sumVeh, xSat, ySatN, x, ynew)
    #    legend(('Anzahl Fahrzeuge', 'saturation flow = %f' % (aSat * 3600), 'flow = %f' % (a * 3600)))
    #    xlabel('Time t')
    # ylabel('# vehicles')
    #
    #    show()

    return (aSat * 3600)
Esempio n. 4
0
def getSaturationFlow():
    genRoutes(300, 'u', 3600, 'u', 0, 'u', 0, 'u', 0)

    gui = False

    setTLType('sumoConfig\cross_sat\cross_sat.net.xml', 'static')
    changePhaseDurations(
        'sumoConfig\cross_sat\cross_sat.net.xml', 1800, 6, 300, 6)

    if gui:
        sumoExe = "guisim"
        sumoConfig = "sumoConfig\cross_sat\cross_sat.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)
    else:
        sumoExe = "sumo"
        sumoConfig = "sumoConfig\cross_sat\cross_sat.sumocfg"
        sumoProcess = subprocess.Popen(
            "%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)

    sumoProcess.wait()

    doc = libxml2.parseFile('sumoConfig\cross_sat\cross.out')
    veh = [int(d.content)
           for d in doc.xpathEval("/detector/interval[@id='SAT']/@nVehEntered")]
    doc.freeDoc()

    sumVeh = [sum(veh[1:(i + 1)]) for i in range(len(veh))]

    xSat = range(323, 538)
    ySat = sumVeh[323:538]
    [aSat, b] = linreg(xSat, ySat)
    print('Saturation flow: ', aSat * 3600)
    ySatN = [aSat * xSat[i] + b for i in range(len(xSat))]

    x = range(700, 850)
    y = sumVeh[700:850]
    [a, b] = linreg(x, y)
    print('Saturation flow 2: ', a * 3600)
    ynew = [a * x[i] + b for i in range(len(x))]

#    plot(range(len(veh)), sumVeh, xSat, ySatN, x, ynew)
#    legend(('Anzahl Fahrzeuge', 'saturation flow = %f' % (aSat * 3600), 'flow = %f' % (a * 3600)))
#    xlabel('Time t')
# ylabel('# vehicles')
#
#    show()

    return (aSat * 3600)
Esempio n. 5
0
                        [greenWE, greenNS] = getOptGreenTimes(
                            satFlowRateWE, satFlowRateNS, intergreenLength, intergreenLength)
                        if (greenWE + greenNS > GSum):
                            greenWE = GSum / ((vehphNS * 1.0 / vehphWE) + 1)
                            greenNS = GSum / ((vehphWE * 1.0 / vehphNS) + 1)
                    else:
                        greenWE = GSum / ((vehphNS * 1.0 / vehphWE) + 1)
                        greenNS = GSum / ((vehphWE * 1.0 / vehphNS) + 1)

                    print(greenWE)
                    print(greenNS)

                    changePhaseDurations(os.path.join('sumoConfig', 'one_intersection', 'cross.net.xml'), int(
                        round(greenWE)), intergreenLength, int(round(greenNS)), intergreenLength)

                genRoutes(
                    N, distrWE, vehphWE, distrWE, 0, distrNS, vehphNS, distrNS, 0)

                if gui:
                    sumoExe = "guisim"
                    sumoConfig = os.path.join(
                        'sumoConfig', 'one_intersection', 'cross.sumocfg')
                    sumoProcess = subprocess.Popen(
                        "%s -c %s" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)
                else:
                    sumoExe = "sumo"
                    sumoConfig = os.path.join(
                        'sumoConfig', 'one_intersection', 'cross.sumocfg')
                    sumoProcess = subprocess.Popen("%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000 --actuated-tl.max-gap %f --actuated-tl.detector-pos %f" % (
                        sumoExe, sumoConfig, maxGap, detPos), shell=True, stdout=sys.stdout)

                sumoProcess.wait()
Esempio n. 6
0
                        [greenWE, greenNS] = getOptGreenTimes(
                            satFlowRateWE, satFlowRateNS, intergreenLength, intergreenLength)
                        if (greenWE + greenNS > GSum):
                            greenWE = GSum / ((vehphNS * 1.0 / vehphWE) + 1)
                            greenNS = GSum / ((vehphWE * 1.0 / vehphNS) + 1)
                    else:
                        greenWE = GSum / ((vehphNS * 1.0 / vehphWE) + 1)
                        greenNS = GSum / ((vehphWE * 1.0 / vehphNS) + 1)

                    print greenWE
                    print greenNS

                    changePhaseDurations(os.path.join('sumoConfig', 'one_intersection', 'cross.net.xml'), int(
                        round(greenWE)), intergreenLength, int(round(greenNS)), intergreenLength)

                genRoutes(
                    N, distrWE, vehphWE, distrWE, 0, distrNS, vehphNS, distrNS, 0)

                if gui:
                    sumoExe = "guisim"
                    sumoConfig = os.path.join(
                        'sumoConfig', 'one_intersection', 'cross.sumocfg')
                    sumoProcess = subprocess.Popen(
                        "%s -c %s" % (sumoExe, sumoConfig), shell=True, stdout=sys.stdout)
                else:
                    sumoExe = "sumo"
                    sumoConfig = os.path.join(
                        'sumoConfig', 'one_intersection', 'cross.sumocfg')
                    sumoProcess = subprocess.Popen("%s -c %s --no-duration-log --no-step-log --time-to-teleport 10000000 --actuated-tl.max-gap %f --actuated-tl.detector-pos %f" % (
                        sumoExe, sumoConfig, maxGap, detPos), shell=True, stdout=sys.stdout)

                sumoProcess.wait()