sumolib.scenario.scenarios.rilsa1_both_tls24
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 rilsa1_both_tls24.py 14# @author Daniel Krajzewicz 15# @date 2014-09-01 16 17from __future__ import absolute_import 18 19 20from . import fileNeedsRebuild, Scenario 21import os 22import subprocess 23import shutil 24import sumolib.net.generator.demand as demandGenerator 25import sumolib 26 27flowsRiLSA1 = [ 28 ["nmp1", [ 29 ["ms2", 359, 9], 30 ["me2", 59, 9], 31 ["mw2", 64, 12] 32 ]], 33 34 ["wmp1", [ 35 ["me2", 508, 10], 36 ["mn2", 80, 14], 37 ["ms2", 130, 2] 38 ]], 39 40 ["emp1", [ 41 ["mw2", 571, 10], 42 ["mn2", 57, 9], 43 ["ms2", 47, 3] 44 ]], 45 46 ["smp1", [ 47 ["mn2", 354, 2], 48 ["me2", 49, 2], 49 ["mw2", 92, 2] 50 ]] 51 52] 53 54 55class Scenario_RiLSA1BothTLS24(Scenario): 56 NAME = "RiLSA1BothTLS24" 57 THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME) 58 TLS_FILE = "tls.add.xml" 59 NET_FILE = "rilsa1both.net.xml" 60 61 def __init__(self, params, withDefaultDemand=True): 62 Scenario.__init__(self, self.THIS_DIR) 63 self.params = params 64 if "equipment-rate" not in self.params: 65 self.params["equipment-rate"] = 1 66 # network 67 if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "netconvert"): 68 netconvert = sumolib.checkBinary("netconvert") 69 subprocess.call([netconvert, "-c", os.path.join(self.THIS_DIR, "build.netc.cfg")]) 70 # build the demand model (streams) 71 if withDefaultDemand: 72 self.demand = demandGenerator.Demand() 73 for f in flowsRiLSA1: 74 for rel in f[1]: 75 prob = rel[2] / 100. 76 iprob = 1. - prob 77 78 pkwEprob = iprob * self.params["equipment-rate"] 79 pkwNprob = iprob - pkwEprob 80 lkwEprob = prob * self.params["equipment-rate"] 81 lkwNprob = prob - lkwEprob 82 83 self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], 84 {"passenger": pkwEprob, 85 "COLOMBO_undetectable_passenger": pkwNprob, 86 "hdv": lkwEprob, 87 "COLOMBO_undetectable_hdv": lkwNprob})) 88 if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"): 89 self.demand.build( 90 0, 3600, self.fullPath(self.NET_FILE), self.fullPath("routes.rou.xml")) 91 self.demandName = self.fullPath("routes.rou.xml") 92 93 self.netName = self.sandboxPath(self.NET_FILE) 94 shutil.copy( 95 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 96 # shutil.copy(self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE))
flowsRiLSA1 =
[['nmp1', [['ms2', 359, 9], ['me2', 59, 9], ['mw2', 64, 12]]], ['wmp1', [['me2', 508, 10], ['mn2', 80, 14], ['ms2', 130, 2]]], ['emp1', [['mw2', 571, 10], ['mn2', 57, 9], ['ms2', 47, 3]]], ['smp1', [['mn2', 354, 2], ['me2', 49, 2], ['mw2', 92, 2]]]]
56class Scenario_RiLSA1BothTLS24(Scenario): 57 NAME = "RiLSA1BothTLS24" 58 THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME) 59 TLS_FILE = "tls.add.xml" 60 NET_FILE = "rilsa1both.net.xml" 61 62 def __init__(self, params, withDefaultDemand=True): 63 Scenario.__init__(self, self.THIS_DIR) 64 self.params = params 65 if "equipment-rate" not in self.params: 66 self.params["equipment-rate"] = 1 67 # network 68 if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "netconvert"): 69 netconvert = sumolib.checkBinary("netconvert") 70 subprocess.call([netconvert, "-c", os.path.join(self.THIS_DIR, "build.netc.cfg")]) 71 # build the demand model (streams) 72 if withDefaultDemand: 73 self.demand = demandGenerator.Demand() 74 for f in flowsRiLSA1: 75 for rel in f[1]: 76 prob = rel[2] / 100. 77 iprob = 1. - prob 78 79 pkwEprob = iprob * self.params["equipment-rate"] 80 pkwNprob = iprob - pkwEprob 81 lkwEprob = prob * self.params["equipment-rate"] 82 lkwNprob = prob - lkwEprob 83 84 self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], 85 {"passenger": pkwEprob, 86 "COLOMBO_undetectable_passenger": pkwNprob, 87 "hdv": lkwEprob, 88 "COLOMBO_undetectable_hdv": lkwNprob})) 89 if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"): 90 self.demand.build( 91 0, 3600, self.fullPath(self.NET_FILE), self.fullPath("routes.rou.xml")) 92 self.demandName = self.fullPath("routes.rou.xml") 93 94 self.netName = self.sandboxPath(self.NET_FILE) 95 shutil.copy( 96 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 97 # shutil.copy(self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE))
Scenario_RiLSA1BothTLS24(params, withDefaultDemand=True)
62 def __init__(self, params, withDefaultDemand=True): 63 Scenario.__init__(self, self.THIS_DIR) 64 self.params = params 65 if "equipment-rate" not in self.params: 66 self.params["equipment-rate"] = 1 67 # network 68 if fileNeedsRebuild(os.path.join(self.THIS_DIR, self.NET_FILE), "netconvert"): 69 netconvert = sumolib.checkBinary("netconvert") 70 subprocess.call([netconvert, "-c", os.path.join(self.THIS_DIR, "build.netc.cfg")]) 71 # build the demand model (streams) 72 if withDefaultDemand: 73 self.demand = demandGenerator.Demand() 74 for f in flowsRiLSA1: 75 for rel in f[1]: 76 prob = rel[2] / 100. 77 iprob = 1. - prob 78 79 pkwEprob = iprob * self.params["equipment-rate"] 80 pkwNprob = iprob - pkwEprob 81 lkwEprob = prob * self.params["equipment-rate"] 82 lkwNprob = prob - lkwEprob 83 84 self.demand.addStream(demandGenerator.Stream(f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], 85 {"passenger": pkwEprob, 86 "COLOMBO_undetectable_passenger": pkwNprob, 87 "hdv": lkwEprob, 88 "COLOMBO_undetectable_hdv": lkwNprob})) 89 if fileNeedsRebuild(self.fullPath("routes.rou.xml"), "duarouter"): 90 self.demand.build( 91 0, 3600, self.fullPath(self.NET_FILE), self.fullPath("routes.rou.xml")) 92 self.demandName = self.fullPath("routes.rou.xml") 93 94 self.netName = self.sandboxPath(self.NET_FILE) 95 shutil.copy( 96 self.fullPath(self.NET_FILE), self.sandboxPath(self.NET_FILE)) 97 # shutil.copy(self.fullPath(self.TLS_FILE), self.sandboxPath(self.TLS_FILE))