Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
defaultEdge.addSplit(100, 1)
defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
netGen = netGenerator.corridor(5, None, defaultEdge)
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)
defaultEdge.addSplit(100, 1)
defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
netGen = netGenerator.corridor(5, None, defaultEdge)
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)
def __init__(self, params, withDefaultDemand=True):
Scenario.__init__(self, self.THIS_DIR)
self.params = params
if "equipment-rate" not in self.params:
self.params["equipment-rate"] = 1
# network
if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "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
pkwEprob = iprob * self.params["equipment-rate"]
pkwNprob = iprob - pkwEprob
lkwEprob = prob * self.params["equipment-rate"]
lkwNprob = prob - lkwEprob
self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0],
{"passenger": pkwEprob, "COLOMBO_undetectable_passenger": pkwNprob, "hdv": lkwEprob, "COLOMBO_undetectable_hdv": lkwNprob}))
if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"):
self.demand.build(
0, 3600, self.fullPath(self.NET_FILE), self.fullPath("routes.rou.xml"))
self.demandName = self.fullPath("routes.rou.xml")
def __init__(self, params, withDefaultDemand=True):
Scenario.__init__(self, self.THIS_DIR)
self.params = params
if "equipment-rate" not in self.params:
self.params["equipment-rate"] = 1
# network
if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "netconvert"):
netconvert = sumolib.checkBinary("netconvert")
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
pkwEprob = iprob * self.params["equipment-rate"]
pkwNprob = iprob - pkwEprob
lkwEprob = prob * self.params["equipment-rate"]
lkwNprob = prob - lkwEprob
self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0],
{"passenger": pkwEprob,
"COLOMBO_undetectable_passenger": pkwNprob,
"hdv": lkwEprob,
"COLOMBO_undetectable_hdv": lkwNprob}))
if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"):
' \n')
fdow.write(
' \n' % (sedge, sedge, nedge, nedge))
fdow.write(
' \n')
fdow.write(
' \n' % (sedge, nedge))
fdow.write(
' \n')
fdow.write(
' \n')
fdow.write(' \n\n')
fdow.write('\n')
# demand
if withDefaultDemand:
self.demand = demandGenerator.Demand()
for f in flowsRiLSA1:
for oe, rel in enumerate(f[1]):
flow = int(rel[1] * .75)
prob = rel[2] / 100.
iprob = 1. - prob
pkwEprob = iprob * self.params["equipment-rate"]
pkwNprob = iprob - pkwEprob
lkwEprob = prob * self.params["equipment-rate"]
lkwNprob = prob - lkwEprob
for ie in range(2, 5): # over input
via = []
if f[0] == "nmp":
iedge = "%s/4_to_%s/3" % (ie, ie)
for ve in range(5, 0, -1):
via.append("%s/%s_to_%s/%s" %
(ie, ve, ie, ve - 1))
def __init__(self, params, withDefaultDemand=True):
Scenario.__init__(self, self.THIS_DIR)
self.params = params
if "equipment-rate" not in self.params:
self.params["equipment-rate"] = 1
# network
if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "netconvert"):
netconvert = sumolib.checkBinary("netconvert")
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
pkwEprob = iprob * self.params["equipment-rate"]
pkwNprob = iprob - pkwEprob
lkwEprob = prob * self.params["equipment-rate"]
lkwNprob = prob - lkwEprob
self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0],
{"passenger": pkwEprob,
"COLOMBO_undetectable_passenger": pkwNprob,
"hdv": lkwEprob,
"COLOMBO_undetectable_hdv": lkwNprob}))
if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"):
'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % (
sedge, sedge, nedge, nedge))
fdow.write(
' \n')
fdow.write(
(' \n') % (sedge, nedge))
fdow.write(
' \n')
fdow.write(
' \n')
fdow.write(' \n\n')
fdow.write('\n')
# demand
if withDefaultDemand:
self.demand = demandGenerator.Demand()
for f in flowsRiLSA1:
for oe, rel in enumerate(f[1]):
flow = int(rel[1] * .75)
prob = rel[2] / 100.
iprob = 1. - prob
pkwEprob = iprob * self.params["equipment-rate"]
pkwNprob = iprob - pkwEprob
lkwEprob = prob * self.params["equipment-rate"]
lkwNprob = prob - lkwEprob
for ie in range(1, 4): # over input
via = []
if f[0] == "nmp":
iedge = "%s/4_to_%s/3" % (ie, ie)
for ve in range(4, 0, -1):
via.append("%s/%s_to_%s/%s" %
(ie, ve, ie, ve - 1))
def extrapolateDemand(stream, freq, probs, pivot=demandGenerator.PIVOT__PEAK, tBeg=0):
ret = demandGenerator.Demand()
if pivot == demandGenerator.PIVOT__PEAK:
mmax = 0
mpos = []
for i, p in enumerate(probs):
if p > mmax:
mpos = i
mmax = p
# !!! should be done
# if count(probs, p)>1:
# raise "more than one maximum value"
# else:
# pivot = mpos
pivot = mpos
t = tBeg
for i, p in enumerate(probs):
# ok, this works just if _numberModel is a number