sumolib.scenario.scenarios.rilsa1

 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.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 subprocess
24import sumolib.net.generator.demand as demandGenerator
25import sumolib
26
27
28flowsRiLSA1 = [
29    ["nmp", [
30        ["ms", 359, 9],
31        ["me", 59, 9],
32        ["mw", 64, 12]
33    ]],
34
35    ["wmp", [
36        ["me", 508, 10],
37        ["mn", 80, 14],
38        ["ms", 130, 2]
39    ]],
40
41    ["emp", [
42        ["mw", 571, 10],
43        ["mn", 57, 9],
44        ["ms", 47, 3]
45    ]],
46
47    ["smp", [
48        ["mn", 354, 2],
49        ["me", 49, 2],
50        ["mw", 92, 2]
51    ]]
52
53]
54
55
56class Scenario_RiLSA1(Scenario):
57    NAME = "RiLSA1"
58    THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME)
59    TLS_FILE = os.path.join(THIS_DIR, "tls.add.xml")
60    NET_FILE = os.path.join(THIS_DIR, "rilsa1.net.xml")
61
62    def __init__(self, withDefaultDemand=True):
63        Scenario.__init__(self, self.NAME)
64        self.netName = self.fullPath(self.NET_FILE)
65        self.demandName = self.fullPath("routes.rou.xml")
66        # network
67        if fileNeedsRebuild(self.netName, "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                    self.demand.addStream(demandGenerator.Stream(
78                        f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], {"hdv": prob, "passenger": iprob}))
79            if fileNeedsRebuild(self.demandName, "duarouter"):
80                self.demand.build(0, 3600, self.netName, self.demandName)
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]]]]
class Scenario_RiLSA1(sumolib.scenario.scenarios.Scenario):
57class Scenario_RiLSA1(Scenario):
58    NAME = "RiLSA1"
59    THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME)
60    TLS_FILE = os.path.join(THIS_DIR, "tls.add.xml")
61    NET_FILE = os.path.join(THIS_DIR, "rilsa1.net.xml")
62
63    def __init__(self, withDefaultDemand=True):
64        Scenario.__init__(self, self.NAME)
65        self.netName = self.fullPath(self.NET_FILE)
66        self.demandName = self.fullPath("routes.rou.xml")
67        # network
68        if fileNeedsRebuild(self.netName, "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                    self.demand.addStream(demandGenerator.Stream(
79                        f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], {"hdv": prob, "passenger": iprob}))
80            if fileNeedsRebuild(self.demandName, "duarouter"):
81                self.demand.build(0, 3600, self.netName, self.demandName)
Scenario_RiLSA1(withDefaultDemand=True)
63    def __init__(self, withDefaultDemand=True):
64        Scenario.__init__(self, self.NAME)
65        self.netName = self.fullPath(self.NET_FILE)
66        self.demandName = self.fullPath("routes.rou.xml")
67        # network
68        if fileNeedsRebuild(self.netName, "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                    self.demand.addStream(demandGenerator.Stream(
79                        f[0] + "__" + rel[0], 0, 3600, rel[1], f[0], rel[0], {"hdv": prob, "passenger": iprob}))
80            if fileNeedsRebuild(self.demandName, "duarouter"):
81                self.demand.build(0, 3600, self.netName, self.demandName)
NAME = 'RiLSA1'
THIS_DIR = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/RiLSA1'
TLS_FILE = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/RiLSA1/tls.add.xml'
NET_FILE = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/RiLSA1/rilsa1.net.xml'
netName
demandName