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