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