sumolib.scenario.scenarios.basic_rilsacorridor3
1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 2# Copyright (C) 2012-2026 German Aerospace Center (DLR) and others. 3# This program and the accompanying materials are made available under the 4# terms of the Eclipse Public License 2.0 which is available at 5# https://www.eclipse.org/legal/epl-2.0/ 6# This Source Code may also be made available under the following Secondary 7# Licenses when the conditions for such availability set forth in the Eclipse 8# Public License 2.0 are satisfied: GNU General Public License, version 2 9# or later which is available at 10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 12 13# @file basic_rilsacorridor3.py 14# @author Daniel Krajzewicz 15# @date 2014-09-01 16 17from __future__ import absolute_import 18from __future__ import print_function 19 20 21from . import fileNeedsRebuild, Scenario 22import os 23import shutil 24import sumolib.net.generator.grid as netGenerator 25import sumolib.net.generator.demand as demandGenerator 26from sumolib.net.generator.network import Edge, Lane 27 28 29flowsRiLSA1 = [ 30 ["nmp", [ 31 ["ms", 359, 9], 32 ["me", 59, 9], 33 ["mw", 64, 12] 34 ]], 35 36 ["wmp", [ 37 ["me", 508, 10], 38 ["mn", 80, 14], 39 ["ms", 130, 2] 40 ]], 41 42 ["emp", [ 43 ["mw", 571, 10], 44 ["mn", 57, 9], 45 ["ms", 47, 3] 46 ]], 47 48 ["smp", [ 49 ["mn", 354, 2], 50 ["me", 49, 2], 51 ["mw", 92, 2] 52 ]] 53 54] 55 56 57class Scenario_BasicRiLSACorridor3(Scenario): 58 NAME = "BasicRiLSACorridor3" 59 THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME) 60 TLS_FILE = "tls.add.xml" 61 NET_FILE = "network.net.xml" 62 63 def __init__(self, name, params, withDefaultDemand=True): 64 Scenario.__init__(self, self.THIS_DIR) 65 self.params = params 66 self.demandName = self.fullPath("routes.rou.xml") 67 self.netName = self.fullPath(self.NET_FILE) 68 # network 69 if fileNeedsRebuild(self.fullPath(self.NET_FILE), "netconvert"): 70 print("Network in '%s' needs to be rebuild" % self.netName) 71 # , Lane(dirs="l", disallowed="pedestrian")] 72 lanes = [Lane(dirs="s", allowed="pedestrian"), Lane( 73 dirs="rs", disallowed="pedestrian")] 74 defaultEdge = Edge(numLanes=2, maxSpeed=13.89, lanes=lanes) 75 defaultEdge.addSplit(100, 0, 1) 76 defaultEdge.lanes[-1].dirs = "l" 77 netGen = netGenerator.grid(5, 3, None, defaultEdge) 78 for n in netGen._nodes: 79 nid = n.split("/") 80 nid[0] = int(nid[0]) 81 nid[1] = int(nid[1]) 82 if nid[0] > 0 and nid[0] < 6 and nid[1] > 0 and nid[1] < 4: 83 netGen._nodes[n].addCrossing( 84 "%s/%s_to_%s.-100" % (nid[0] - 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] - 1, nid[1])) 85 netGen._nodes[n].addCrossing( 86 "%s/%s_to_%s.-100" % (nid[0] + 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] + 1, nid[1])) 87 netGen._nodes[n].addCrossing( 88 "%s/%s_to_%s.-100" % (nid[0], nid[1] - 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] - 1)) 89 netGen._nodes[n].addCrossing( 90 "%s/%s_to_%s.-100" % (nid[0], nid[1] + 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] + 1)) 91 # not nice, the network name should be given/returned 92 netGen.build(self.netName) 93 if True: 94 fdow = open(self.fullPath(self.TLS_FILE), "w") 95 fdow.write('<additional>\n\n') 96 for y in range(1, 4): 97 for x in range(1, 6): 98 eedge = "%s/%s_to_%s/%s.-100" % (x - 1, y, x, y) 99 wedge = "%s/%s_to_%s/%s.-100" % (x + 1, y, x, y) 100 nedge = "%s/%s_to_%s/%s.-100" % (x, y + 1, x, y) 101 sedge = "%s/%s_to_%s/%s.-100" % (x, y - 1, x, y) 102 fdow.write( 103 ' <tlLogic id="%s/%s" type="actuated" programID="adapted" offset="0">\n' % (x, y)) 104 fdow.write( 105 (' <phase duration="31" state="rrrrrGGgrrrrrGGgGrGr" minDur="10" maxDur="50" ' + 106 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 107 eedge, eedge, wedge, wedge)) 108 fdow.write( 109 ' <phase duration="4" state="rrrrryygrrrrryygrrrr" type="transient"/>\n') 110 fdow.write( 111 (' <phase duration="6" state="rrrrrrrGrrrrrrrGrrrr" minDur="2" maxDur="20" ' + 112 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (eedge, wedge)) 113 fdow.write( 114 ' <phase duration="4" state="rrrrrrryrrrrrrryrrrr" type="transient"/>\n') 115 fdow.write( 116 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 117 fdow.write( 118 (' <phase duration="31" state="rGGgrrrrrGGgrrrrrGrG" minDur="10" maxDur="50" ' + 119 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 120 sedge, sedge, nedge, nedge)) 121 fdow.write( 122 ' <phase duration="4" state="ryygrrrrryygrrrrrrrr" type="transient"/>\n') 123 fdow.write( 124 (' <phase duration="6" state="rrrGrrrrrrrGrrrrrrrr" minDur="2" maxDur="20" ' + 125 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (sedge, nedge)) 126 fdow.write( 127 ' <phase duration="4" state="rrryrrrrrrryrrrrrrrr" type="transient"/>\n') 128 fdow.write( 129 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 130 fdow.write(' </tlLogic>\n\n') 131 fdow.write('</additional>\n') 132 # demand 133 if withDefaultDemand: 134 self.demand = demandGenerator.Demand() 135 for f in flowsRiLSA1: 136 for oe, rel in enumerate(f[1]): 137 flow = int(rel[1] * .75) 138 prob = rel[2] / 100. 139 iprob = 1. - prob 140 pkwEprob = iprob * self.params["equipment-rate"] 141 pkwNprob = iprob - pkwEprob 142 lkwEprob = prob * self.params["equipment-rate"] 143 lkwNprob = prob - lkwEprob 144 for ie in range(2, 5): # over input 145 via = [] 146 if f[0] == "nmp": 147 iedge = "%s/4_to_%s/3" % (ie, ie) 148 for ve in range(5, 0, -1): 149 via.append("%s/%s_to_%s/%s" % 150 (ie, ve, ie, ve - 1)) 151 if f[0] == "smp": 152 iedge = "%s/0_to_%s/1" % (ie, ie) 153 for ve in range(0, 5, 1): 154 via.append("%s/%s_to_%s/%s" % 155 (ie, ve, ie, ve + 1)) 156 if f[0] == "wmp": 157 if ie > 2: 158 continue 159 iedge = "0/%s_to_1/%s" % (ie, ie) 160 for ve in range(0, 5, 1): 161 via.append("%s/%s_to_%s/%s" % 162 (ve, ie, ve + 1, ie)) 163 if f[0] == "emp": 164 if ie > 2: 165 continue 166 iedge = "6/%s_to_5/%s" % (ie, ie) 167 for ve in range(5, 0, -1): 168 via.append("%s/%s_to_%s/%s" % 169 (ve, ie, ve - 1, ie)) 170 if oe == 0: 171 # if ie<2 or ie>2: continue # discard vehicles not 172 # passing the center 173 if rel[0] == "mn": 174 oedge = "%s/3_to_%s/4.-100" % (ie, ie) 175 if rel[0] == "ms": 176 oedge = "%s/1_to_%s/0.-100" % (ie, ie) 177 if rel[0] == "mw": 178 oedge = "1/%s_to_0/%s.-100" % (ie, ie) 179 if rel[0] == "me": 180 oedge = "5/%s_to_6/%s.-100" % (ie, ie) 181 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, flow, iedge, 182 oedge, 183 {"passenger": pkwEprob, 184 "COLOMBO_undetectable_passenger": pkwNprob, 185 "hdv": lkwEprob, 186 "COLOMBO_undetectable_hdv": lkwNprob})) 187 continue 188 for oee in range(1, 4): 189 if rel[0] == "mn": 190 oedge = "%s/3_to_%s/4.-100" % (oee, oee) 191 if rel[0] == "ms": 192 oedge = "%s/1_to_%s/0.-100" % (oee, oee) 193 if rel[0] == "mw": 194 oedge = "1/%s_to_0/%s.-100" % (oee, oee) 195 if rel[0] == "me": 196 oedge = "5/%s_to_6/%s.-100" % (oee, oee) 197 # if (ie<2 or ie>2) and (oee<2 or oee>2): continue 198 # # discard vehicles not passing the center 199 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.), 200 iedge, oedge, 201 {"passenger": pkwEprob, 202 "COLOMBO_undetectable_passenger": pkwNprob, 203 "hdv": lkwEprob, 204 "COLOMBO_undetectable_hdv": lkwNprob})) 205 if fileNeedsRebuild(self.demandName, "duarouter"): 206 self.demand.build(0, 86400, self.netName, self.demandName) 207 208 shutil.copy( 209 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 210 shutil.copy( 211 self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE)) 212 print("Huah")
flowsRiLSA1 =
[['nmp', [['ms', 359, 9], ['me', 59, 9], ['mw', 64, 12]]], ['wmp', [['me', 508, 10], ['mn', 80, 14], ['ms', 130, 2]]], ['emp', [['mw', 571, 10], ['mn', 57, 9], ['ms', 47, 3]]], ['smp', [['mn', 354, 2], ['me', 49, 2], ['mw', 92, 2]]]]
58class Scenario_BasicRiLSACorridor3(Scenario): 59 NAME = "BasicRiLSACorridor3" 60 THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME) 61 TLS_FILE = "tls.add.xml" 62 NET_FILE = "network.net.xml" 63 64 def __init__(self, name, params, withDefaultDemand=True): 65 Scenario.__init__(self, self.THIS_DIR) 66 self.params = params 67 self.demandName = self.fullPath("routes.rou.xml") 68 self.netName = self.fullPath(self.NET_FILE) 69 # network 70 if fileNeedsRebuild(self.fullPath(self.NET_FILE), "netconvert"): 71 print("Network in '%s' needs to be rebuild" % self.netName) 72 # , Lane(dirs="l", disallowed="pedestrian")] 73 lanes = [Lane(dirs="s", allowed="pedestrian"), Lane( 74 dirs="rs", disallowed="pedestrian")] 75 defaultEdge = Edge(numLanes=2, maxSpeed=13.89, lanes=lanes) 76 defaultEdge.addSplit(100, 0, 1) 77 defaultEdge.lanes[-1].dirs = "l" 78 netGen = netGenerator.grid(5, 3, None, defaultEdge) 79 for n in netGen._nodes: 80 nid = n.split("/") 81 nid[0] = int(nid[0]) 82 nid[1] = int(nid[1]) 83 if nid[0] > 0 and nid[0] < 6 and nid[1] > 0 and nid[1] < 4: 84 netGen._nodes[n].addCrossing( 85 "%s/%s_to_%s.-100" % (nid[0] - 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] - 1, nid[1])) 86 netGen._nodes[n].addCrossing( 87 "%s/%s_to_%s.-100" % (nid[0] + 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] + 1, nid[1])) 88 netGen._nodes[n].addCrossing( 89 "%s/%s_to_%s.-100" % (nid[0], nid[1] - 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] - 1)) 90 netGen._nodes[n].addCrossing( 91 "%s/%s_to_%s.-100" % (nid[0], nid[1] + 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] + 1)) 92 # not nice, the network name should be given/returned 93 netGen.build(self.netName) 94 if True: 95 fdow = open(self.fullPath(self.TLS_FILE), "w") 96 fdow.write('<additional>\n\n') 97 for y in range(1, 4): 98 for x in range(1, 6): 99 eedge = "%s/%s_to_%s/%s.-100" % (x - 1, y, x, y) 100 wedge = "%s/%s_to_%s/%s.-100" % (x + 1, y, x, y) 101 nedge = "%s/%s_to_%s/%s.-100" % (x, y + 1, x, y) 102 sedge = "%s/%s_to_%s/%s.-100" % (x, y - 1, x, y) 103 fdow.write( 104 ' <tlLogic id="%s/%s" type="actuated" programID="adapted" offset="0">\n' % (x, y)) 105 fdow.write( 106 (' <phase duration="31" state="rrrrrGGgrrrrrGGgGrGr" minDur="10" maxDur="50" ' + 107 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 108 eedge, eedge, wedge, wedge)) 109 fdow.write( 110 ' <phase duration="4" state="rrrrryygrrrrryygrrrr" type="transient"/>\n') 111 fdow.write( 112 (' <phase duration="6" state="rrrrrrrGrrrrrrrGrrrr" minDur="2" maxDur="20" ' + 113 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (eedge, wedge)) 114 fdow.write( 115 ' <phase duration="4" state="rrrrrrryrrrrrrryrrrr" type="transient"/>\n') 116 fdow.write( 117 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 118 fdow.write( 119 (' <phase duration="31" state="rGGgrrrrrGGgrrrrrGrG" minDur="10" maxDur="50" ' + 120 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 121 sedge, sedge, nedge, nedge)) 122 fdow.write( 123 ' <phase duration="4" state="ryygrrrrryygrrrrrrrr" type="transient"/>\n') 124 fdow.write( 125 (' <phase duration="6" state="rrrGrrrrrrrGrrrrrrrr" minDur="2" maxDur="20" ' + 126 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (sedge, nedge)) 127 fdow.write( 128 ' <phase duration="4" state="rrryrrrrrrryrrrrrrrr" type="transient"/>\n') 129 fdow.write( 130 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 131 fdow.write(' </tlLogic>\n\n') 132 fdow.write('</additional>\n') 133 # demand 134 if withDefaultDemand: 135 self.demand = demandGenerator.Demand() 136 for f in flowsRiLSA1: 137 for oe, rel in enumerate(f[1]): 138 flow = int(rel[1] * .75) 139 prob = rel[2] / 100. 140 iprob = 1. - prob 141 pkwEprob = iprob * self.params["equipment-rate"] 142 pkwNprob = iprob - pkwEprob 143 lkwEprob = prob * self.params["equipment-rate"] 144 lkwNprob = prob - lkwEprob 145 for ie in range(2, 5): # over input 146 via = [] 147 if f[0] == "nmp": 148 iedge = "%s/4_to_%s/3" % (ie, ie) 149 for ve in range(5, 0, -1): 150 via.append("%s/%s_to_%s/%s" % 151 (ie, ve, ie, ve - 1)) 152 if f[0] == "smp": 153 iedge = "%s/0_to_%s/1" % (ie, ie) 154 for ve in range(0, 5, 1): 155 via.append("%s/%s_to_%s/%s" % 156 (ie, ve, ie, ve + 1)) 157 if f[0] == "wmp": 158 if ie > 2: 159 continue 160 iedge = "0/%s_to_1/%s" % (ie, ie) 161 for ve in range(0, 5, 1): 162 via.append("%s/%s_to_%s/%s" % 163 (ve, ie, ve + 1, ie)) 164 if f[0] == "emp": 165 if ie > 2: 166 continue 167 iedge = "6/%s_to_5/%s" % (ie, ie) 168 for ve in range(5, 0, -1): 169 via.append("%s/%s_to_%s/%s" % 170 (ve, ie, ve - 1, ie)) 171 if oe == 0: 172 # if ie<2 or ie>2: continue # discard vehicles not 173 # passing the center 174 if rel[0] == "mn": 175 oedge = "%s/3_to_%s/4.-100" % (ie, ie) 176 if rel[0] == "ms": 177 oedge = "%s/1_to_%s/0.-100" % (ie, ie) 178 if rel[0] == "mw": 179 oedge = "1/%s_to_0/%s.-100" % (ie, ie) 180 if rel[0] == "me": 181 oedge = "5/%s_to_6/%s.-100" % (ie, ie) 182 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, flow, iedge, 183 oedge, 184 {"passenger": pkwEprob, 185 "COLOMBO_undetectable_passenger": pkwNprob, 186 "hdv": lkwEprob, 187 "COLOMBO_undetectable_hdv": lkwNprob})) 188 continue 189 for oee in range(1, 4): 190 if rel[0] == "mn": 191 oedge = "%s/3_to_%s/4.-100" % (oee, oee) 192 if rel[0] == "ms": 193 oedge = "%s/1_to_%s/0.-100" % (oee, oee) 194 if rel[0] == "mw": 195 oedge = "1/%s_to_0/%s.-100" % (oee, oee) 196 if rel[0] == "me": 197 oedge = "5/%s_to_6/%s.-100" % (oee, oee) 198 # if (ie<2 or ie>2) and (oee<2 or oee>2): continue 199 # # discard vehicles not passing the center 200 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.), 201 iedge, oedge, 202 {"passenger": pkwEprob, 203 "COLOMBO_undetectable_passenger": pkwNprob, 204 "hdv": lkwEprob, 205 "COLOMBO_undetectable_hdv": lkwNprob})) 206 if fileNeedsRebuild(self.demandName, "duarouter"): 207 self.demand.build(0, 86400, self.netName, self.demandName) 208 209 shutil.copy( 210 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 211 shutil.copy( 212 self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE)) 213 print("Huah")
Scenario_BasicRiLSACorridor3(name, params, withDefaultDemand=True)
64 def __init__(self, name, params, withDefaultDemand=True): 65 Scenario.__init__(self, self.THIS_DIR) 66 self.params = params 67 self.demandName = self.fullPath("routes.rou.xml") 68 self.netName = self.fullPath(self.NET_FILE) 69 # network 70 if fileNeedsRebuild(self.fullPath(self.NET_FILE), "netconvert"): 71 print("Network in '%s' needs to be rebuild" % self.netName) 72 # , Lane(dirs="l", disallowed="pedestrian")] 73 lanes = [Lane(dirs="s", allowed="pedestrian"), Lane( 74 dirs="rs", disallowed="pedestrian")] 75 defaultEdge = Edge(numLanes=2, maxSpeed=13.89, lanes=lanes) 76 defaultEdge.addSplit(100, 0, 1) 77 defaultEdge.lanes[-1].dirs = "l" 78 netGen = netGenerator.grid(5, 3, None, defaultEdge) 79 for n in netGen._nodes: 80 nid = n.split("/") 81 nid[0] = int(nid[0]) 82 nid[1] = int(nid[1]) 83 if nid[0] > 0 and nid[0] < 6 and nid[1] > 0 and nid[1] < 4: 84 netGen._nodes[n].addCrossing( 85 "%s/%s_to_%s.-100" % (nid[0] - 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] - 1, nid[1])) 86 netGen._nodes[n].addCrossing( 87 "%s/%s_to_%s.-100" % (nid[0] + 1, nid[1], n), "%s_to_%s/%s" % (n, nid[0] + 1, nid[1])) 88 netGen._nodes[n].addCrossing( 89 "%s/%s_to_%s.-100" % (nid[0], nid[1] - 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] - 1)) 90 netGen._nodes[n].addCrossing( 91 "%s/%s_to_%s.-100" % (nid[0], nid[1] + 1, n), "%s_to_%s/%s" % (n, nid[0], nid[1] + 1)) 92 # not nice, the network name should be given/returned 93 netGen.build(self.netName) 94 if True: 95 fdow = open(self.fullPath(self.TLS_FILE), "w") 96 fdow.write('<additional>\n\n') 97 for y in range(1, 4): 98 for x in range(1, 6): 99 eedge = "%s/%s_to_%s/%s.-100" % (x - 1, y, x, y) 100 wedge = "%s/%s_to_%s/%s.-100" % (x + 1, y, x, y) 101 nedge = "%s/%s_to_%s/%s.-100" % (x, y + 1, x, y) 102 sedge = "%s/%s_to_%s/%s.-100" % (x, y - 1, x, y) 103 fdow.write( 104 ' <tlLogic id="%s/%s" type="actuated" programID="adapted" offset="0">\n' % (x, y)) 105 fdow.write( 106 (' <phase duration="31" state="rrrrrGGgrrrrrGGgGrGr" minDur="10" maxDur="50" ' + 107 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 108 eedge, eedge, wedge, wedge)) 109 fdow.write( 110 ' <phase duration="4" state="rrrrryygrrrrryygrrrr" type="transient"/>\n') 111 fdow.write( 112 (' <phase duration="6" state="rrrrrrrGrrrrrrrGrrrr" minDur="2" maxDur="20" ' + 113 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (eedge, wedge)) 114 fdow.write( 115 ' <phase duration="4" state="rrrrrrryrrrrrrryrrrr" type="transient"/>\n') 116 fdow.write( 117 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 118 fdow.write( 119 (' <phase duration="31" state="rGGgrrrrrGGgrrrrrGrG" minDur="10" maxDur="50" ' + 120 'type="target;decisional" targetLanes="%s_1 %s_2 %s_1 %s_2"/>\n') % ( 121 sedge, sedge, nedge, nedge)) 122 fdow.write( 123 ' <phase duration="4" state="ryygrrrrryygrrrrrrrr" type="transient"/>\n') 124 fdow.write( 125 (' <phase duration="6" state="rrrGrrrrrrrGrrrrrrrr" minDur="2" maxDur="20" ' + 126 'type="decisional" targetLanes="%s_2 %s_2"/>\n') % (sedge, nedge)) 127 fdow.write( 128 ' <phase duration="4" state="rrryrrrrrrryrrrrrrrr" type="transient"/>\n') 129 fdow.write( 130 ' <phase duration="4" state="rrrrrrrrrrrrrrrrrrrr" type="transient;commit"/>\n') 131 fdow.write(' </tlLogic>\n\n') 132 fdow.write('</additional>\n') 133 # demand 134 if withDefaultDemand: 135 self.demand = demandGenerator.Demand() 136 for f in flowsRiLSA1: 137 for oe, rel in enumerate(f[1]): 138 flow = int(rel[1] * .75) 139 prob = rel[2] / 100. 140 iprob = 1. - prob 141 pkwEprob = iprob * self.params["equipment-rate"] 142 pkwNprob = iprob - pkwEprob 143 lkwEprob = prob * self.params["equipment-rate"] 144 lkwNprob = prob - lkwEprob 145 for ie in range(2, 5): # over input 146 via = [] 147 if f[0] == "nmp": 148 iedge = "%s/4_to_%s/3" % (ie, ie) 149 for ve in range(5, 0, -1): 150 via.append("%s/%s_to_%s/%s" % 151 (ie, ve, ie, ve - 1)) 152 if f[0] == "smp": 153 iedge = "%s/0_to_%s/1" % (ie, ie) 154 for ve in range(0, 5, 1): 155 via.append("%s/%s_to_%s/%s" % 156 (ie, ve, ie, ve + 1)) 157 if f[0] == "wmp": 158 if ie > 2: 159 continue 160 iedge = "0/%s_to_1/%s" % (ie, ie) 161 for ve in range(0, 5, 1): 162 via.append("%s/%s_to_%s/%s" % 163 (ve, ie, ve + 1, ie)) 164 if f[0] == "emp": 165 if ie > 2: 166 continue 167 iedge = "6/%s_to_5/%s" % (ie, ie) 168 for ve in range(5, 0, -1): 169 via.append("%s/%s_to_%s/%s" % 170 (ve, ie, ve - 1, ie)) 171 if oe == 0: 172 # if ie<2 or ie>2: continue # discard vehicles not 173 # passing the center 174 if rel[0] == "mn": 175 oedge = "%s/3_to_%s/4.-100" % (ie, ie) 176 if rel[0] == "ms": 177 oedge = "%s/1_to_%s/0.-100" % (ie, ie) 178 if rel[0] == "mw": 179 oedge = "1/%s_to_0/%s.-100" % (ie, ie) 180 if rel[0] == "me": 181 oedge = "5/%s_to_6/%s.-100" % (ie, ie) 182 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, flow, iedge, 183 oedge, 184 {"passenger": pkwEprob, 185 "COLOMBO_undetectable_passenger": pkwNprob, 186 "hdv": lkwEprob, 187 "COLOMBO_undetectable_hdv": lkwNprob})) 188 continue 189 for oee in range(1, 4): 190 if rel[0] == "mn": 191 oedge = "%s/3_to_%s/4.-100" % (oee, oee) 192 if rel[0] == "ms": 193 oedge = "%s/1_to_%s/0.-100" % (oee, oee) 194 if rel[0] == "mw": 195 oedge = "1/%s_to_0/%s.-100" % (oee, oee) 196 if rel[0] == "me": 197 oedge = "5/%s_to_6/%s.-100" % (oee, oee) 198 # if (ie<2 or ie>2) and (oee<2 or oee>2): continue 199 # # discard vehicles not passing the center 200 self.demand.addStream(demandGenerator.Stream(iedge + "__" + oedge, 0, 3600, int(flow / 3.), 201 iedge, oedge, 202 {"passenger": pkwEprob, 203 "COLOMBO_undetectable_passenger": pkwNprob, 204 "hdv": lkwEprob, 205 "COLOMBO_undetectable_hdv": lkwNprob})) 206 if fileNeedsRebuild(self.demandName, "duarouter"): 207 self.demand.build(0, 86400, self.netName, self.demandName) 208 209 shutil.copy( 210 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 211 shutil.copy( 212 self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE)) 213 print("Huah")