How to use the sumolib.net.generator.demand.Stream function in sumolib

To help you get started, we’ve selected a few sumolib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse / sumo / tests / complex / scenario_generation / demand_models / runner.py View on Github external
sys.path.append(os.path.join(SUMO_HOME, 'tools'))

from sumolib.net.generator.network import Edge  # noqa
from sumolib.net.generator.demand import Demand, Stream, LinearChange, WaveComposition  # noqa

demand = Demand()
demand.addStream(Stream(None, None, None, 800, "from", "to", "passenger"))
vehicles1 = []
for s in demand.streams:
    vehicles1.extend(s.toVehicles(0, 86400))

# demand.build(0, 3600, 3600, "net.net.xml", "linear.rou.xml")

demand = Demand()
demand.addStream(Stream(None, 0, 39600, 400, "from", "to", "passenger"))
demand.addStream(Stream(None, 39600, 46800, LinearChange(
    400, 1200, 39600, 46800), "from", "to", "passenger"))
demand.addStream(Stream(None, 46800, 86400, 1200, "from", "to", "passenger"))
vehicles2 = []
for s in demand.streams:
    vehicles2.extend(s.toVehicles(0, 86400))
# demand.build(0, 3600, 3600, "net.net.xml", "linear.rou.xml")

vehicles3 = []  # [600, 0, .000025, 14400]
demand = Demand()
demand.addStream(Stream(None, None, None, WaveComposition(
    800, [[400, 0, .000025, 14400], [200, 0, .00001, 14400]]), "from", "to", "passenger"))
for s in demand.streams:
    vehicles3.extend(s.toVehicles(0, 86400))
# demand.build(0, 3600, "net.net.xml", "linear.rou.xml")

STEP = 300
github eclipse / sumo / sumo / tools / sumolib / scenario / scenarios / basic_crossl.py View on Github external
# network
        if fileNeedsRebuild(self.netName, "netconvert"):
            print("Network in '%s' needs to be rebuild" % self.netName)
            defaultEdge = Edge(numLanes=1, maxSpeed=13.89)
            defaultEdge.addSplit(100, 1)
            defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
            netGen = netGenerator.cross(None, defaultEdge)
            # not nice, the network name should be given/returned
            netGen.build(self.netName)
        # demand
        if withDefaultDemand:
            print("Demand in '%s' needs to be rebuild" % self.demandName)
            self.demand = demandGenerator.Demand()
            # why isn't it possible to get a network and return all possible
            # routes or whatever - to ease the process
            self.demand.addStream(demandGenerator.Stream(
                None, 0, 3600, 1000, "2/1_to_1/1", "1/1_to_0/1", {.2: "hdv", .8: "passenger"}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 3600, self.netName, self.demandName)
github eclipse / sumo / sumo / tools / sumolib / scenario / scenarios / rilsa1.py View on Github external
Scenario.__init__(self, self.NAME)
        self.netName = self.fullPath(self.NET_FILE)
        self.demandName = self.fullPath("routes.rou.xml")
        # network
        if fileNeedsRebuild(self.netName, "netconvert"):
            netconvert = sumolib.checkBinary("netconvert")
            retCode = subprocess.call(
                [netconvert, "-c", os.path.join(self.THIS_DIR, "build.netc.cfg")])
        # build the demand model (streams)
        if withDefaultDemand:
            self.demand = demandGenerator.Demand()
            for f in flowsRiLSA1:
                for rel in f[1]:
                    prob = rel[2] / 100.
                    iprob = 1. - prob
                    self.demand.addStream(demandGenerator.Stream(
                        f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], {"hdv": prob, "passenger": iprob}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 3600, self.netName, self.demandName)
github eclipse / sumo / sumo / tools / sumolib / scenario / scenarios / basic_corridor.py View on Github external
xpos = xoff
            for i in range(1, 6):
                netGen._nodes["%s/0" % i].x = xpos
                netGen._nodes["%s/1" % i].x = xpos
                netGen._nodes["%s/2" % i].x = xpos
                xpos = xpos + xoff
            netGen._nodes["6/1"].x = xpos
            # not nice, the network name should be given/returned
            netGen.build(self.netName)
        # demand
        if withDefaultDemand:
            print("Demand in '%s' needs to be rebuild" % self.demandName)
            self.demand = demandGenerator.Demand()
            # why isn't it possible to get a network and return all possible
            # routes or whatever - to ease the process
            self.demand.addStream(demandGenerator.Stream(
                None, 0, 3600, 1000, "6/1_to_5/1", "1/1_to_0/1", {.2: "hdv", .8: "passenger"}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 3600, self.netName, self.demandName)
github eclipse / sumo / sumo / tools / sumolib / scenario / scenarios / basic_rilsacorridor3.py View on Github external
oedge = "5/%s_to_6/%s.-100" % (ie, ie)
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, flow, iedge, oedge,
                                                                         {"passenger": pkwEprob, "COLOMBO_undetectable_passenger": pkwNprob, "hdv": lkwEprob, "COLOMBO_undetectable_hdv": lkwNprob}))
                            continue
                        for oee in range(1, 4):
                            if rel[0] == "mn":
                                oedge = "%s/3_to_%s/4.-100" % (oee, oee)
                            if rel[0] == "ms":
                                oedge = "%s/1_to_%s/0.-100" % (oee, oee)
                            if rel[0] == "mw":
                                oedge = "1/%s_to_0/%s.-100" % (oee, oee)
                            if rel[0] == "me":
                                oedge = "5/%s_to_6/%s.-100" % (oee, oee)
                            # if (ie<2 or ie>2) and (oee<2 or oee>2): continue
                            # # discard vehicles not passing the center
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.), iedge, oedge,
                                                                         {"passenger": pkwEprob, "COLOMBO_undetectable_passenger": pkwNprob, "hdv": lkwEprob, "COLOMBO_undetectable_hdv": lkwNprob}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 86400, self.netName, self.demandName)

        shutil.copy(
            self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE))
        shutil.copy(
            self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE))
        print("Huah")
github eclipse / sumo / tools / sumolib / scenario / scenarios / basic_rilsanet.py View on Github external
{"passenger": pkwEprob,
                                                                          "COLOMBO_undetectable_passenger": pkwNprob,
                                                                          "hdv": lkwEprob,
                                                                          "COLOMBO_undetectable_hdv": lkwNprob}))
                            continue
                        for oee in range(1, 4):
                            if rel[0] == "mn":
                                oedge = "%s/3_to_%s/4.-100" % (oee, oee)
                            if rel[0] == "ms":
                                oedge = "%s/1_to_%s/0.-100" % (oee, oee)
                            if rel[0] == "mw":
                                oedge = "1/%s_to_0/%s.-100" % (oee, oee)
                            if rel[0] == "me":
                                oedge = "3/%s_to_4/%s.-100" % (oee, oee)
                            print("%s %s " % (oee, via))
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.),
                                                                         iedge, oedge,
                                                                         {"passenger": pkwEprob,
                                                                          "COLOMBO_undetectable_passenger": pkwNprob,
                                                                          "hdv": lkwEprob,
                                                                          "COLOMBO_undetectable_hdv": lkwNprob}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 86400, self.netName, self.demandName)

        shutil.copy(self.NET_FILE, self.sandboxPath(self.NET_FILE))
        shutil.copy(self.TLS_FILE, self.sandboxPath(self.TLS_FILE))
github eclipse / sumo / sumo / tools / sumolib / scenario / scenarios / basic_rilsanet.py View on Github external
if rel[0] == "me":
                                oedge = "3/%s_to_4/%s.-100" % (ie, ie)
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, flow, iedge, oedge,
                                                                         {"passenger": pkwEprob, "COLOMBO_undetectable_passenger": pkwNprob, "hdv": lkwEprob, "COLOMBO_undetectable_hdv": lkwNprob}))
                            continue
                        for oee in range(1, 4):
                            if rel[0] == "mn":
                                oedge = "%s/3_to_%s/4.-100" % (oee, oee)
                            if rel[0] == "ms":
                                oedge = "%s/1_to_%s/0.-100" % (oee, oee)
                            if rel[0] == "mw":
                                oedge = "1/%s_to_0/%s.-100" % (oee, oee)
                            if rel[0] == "me":
                                oedge = "3/%s_to_4/%s.-100" % (oee, oee)
                            print("%s %s " % (oee, via))
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.), iedge, oedge,
                                                                         {"passenger": pkwEprob, "COLOMBO_undetectable_passenger": pkwNprob, "hdv": lkwEprob, "COLOMBO_undetectable_hdv": lkwNprob}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 86400, self.netName, self.demandName)

        shutils.copy(self.NET_FILE, self.sandboxPath(self.NET_FILE))
        shutils.copy(self.TLS_FILE, self.sandboxPath(self.TLS_FILE))
github eclipse / sumo / tools / sumolib / scenario / scenarios / basic_rilsacorridor3.py View on Github external
"COLOMBO_undetectable_passenger": pkwNprob,
                                                                          "hdv": lkwEprob,
                                                                          "COLOMBO_undetectable_hdv": lkwNprob}))
                            continue
                        for oee in range(1, 4):
                            if rel[0] == "mn":
                                oedge = "%s/3_to_%s/4.-100" % (oee, oee)
                            if rel[0] == "ms":
                                oedge = "%s/1_to_%s/0.-100" % (oee, oee)
                            if rel[0] == "mw":
                                oedge = "1/%s_to_0/%s.-100" % (oee, oee)
                            if rel[0] == "me":
                                oedge = "5/%s_to_6/%s.-100" % (oee, oee)
                            # if (ie<2 or ie>2) and (oee<2 or oee>2): continue
                            # # discard vehicles not passing the center
                            self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.),
                                                                         iedge, oedge,
                                                                         {"passenger": pkwEprob,
                                                                          "COLOMBO_undetectable_passenger": pkwNprob,
                                                                          "hdv": lkwEprob,
                                                                          "COLOMBO_undetectable_hdv": lkwNprob}))
            if fileNeedsRebuild(self.demandName, "duarouter"):
                self.demand.build(0, 86400, self.netName, self.demandName)

        shutil.copy(
            self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE))
        shutil.copy(
            self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE))
        print("Huah")