sumolib.scenario.scenarios.basic_crossl

 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_crossl.py
14# @author  Daniel Krajzewicz
15# @author  Michael Behrisch
16# @date    2014-09-01
17
18from __future__ import absolute_import
19from __future__ import print_function
20
21from . import fileNeedsRebuild, Scenario
22import os
23import sumolib.net.generator.cross as netGenerator
24import sumolib.net.generator.demand as demandGenerator
25from sumolib.net.generator.network import Edge, Lane
26
27
28class Scenario_BasicCrossL(Scenario):
29    NAME = "BasicCrossL"
30    THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME)
31    TLS_FILE = os.path.join(THIS_DIR, "tls.add.xml")
32    NET_FILE = os.path.join(THIS_DIR, "net.net.xml")
33
34    def __init__(self, withDefaultDemand=True):
35        Scenario.__init__(self, self.NAME)
36        self.netName = self.fullPath(self.NET_FILE)
37        self.demandName = self.fullPath("routes.rou.xml")
38        # network
39        if fileNeedsRebuild(self.netName, "netconvert"):
40            print("Network in '%s' needs to be rebuild" % self.netName)
41            defaultEdge = Edge(numLanes=1, maxSpeed=13.89)
42            defaultEdge.addSplit(100, 1)
43            defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
44            netGen = netGenerator.cross(None, defaultEdge)
45            # not nice, the network name should be given/returned
46            netGen.build(self.netName)
47        # demand
48        if withDefaultDemand:
49            print("Demand in '%s' needs to be rebuild" % self.demandName)
50            self.demand = demandGenerator.Demand()
51            # why isn't it possible to get a network and return all possible
52            # routes or whatever - to ease the process
53            self.demand.addStream(demandGenerator.Stream(
54                None, 0, 3600, 1000, "2/1_to_1/1", "1/1_to_0/1", {.2: "hdv", .8: "passenger"}))
55            if fileNeedsRebuild(self.demandName, "duarouter"):
56                self.demand.build(0, 3600, self.netName, self.demandName)
class Scenario_BasicCrossL(sumolib.scenario.scenarios.Scenario):
29class Scenario_BasicCrossL(Scenario):
30    NAME = "BasicCrossL"
31    THIS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), NAME)
32    TLS_FILE = os.path.join(THIS_DIR, "tls.add.xml")
33    NET_FILE = os.path.join(THIS_DIR, "net.net.xml")
34
35    def __init__(self, withDefaultDemand=True):
36        Scenario.__init__(self, self.NAME)
37        self.netName = self.fullPath(self.NET_FILE)
38        self.demandName = self.fullPath("routes.rou.xml")
39        # network
40        if fileNeedsRebuild(self.netName, "netconvert"):
41            print("Network in '%s' needs to be rebuild" % self.netName)
42            defaultEdge = Edge(numLanes=1, maxSpeed=13.89)
43            defaultEdge.addSplit(100, 1)
44            defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
45            netGen = netGenerator.cross(None, defaultEdge)
46            # not nice, the network name should be given/returned
47            netGen.build(self.netName)
48        # demand
49        if withDefaultDemand:
50            print("Demand in '%s' needs to be rebuild" % self.demandName)
51            self.demand = demandGenerator.Demand()
52            # why isn't it possible to get a network and return all possible
53            # routes or whatever - to ease the process
54            self.demand.addStream(demandGenerator.Stream(
55                None, 0, 3600, 1000, "2/1_to_1/1", "1/1_to_0/1", {.2: "hdv", .8: "passenger"}))
56            if fileNeedsRebuild(self.demandName, "duarouter"):
57                self.demand.build(0, 3600, self.netName, self.demandName)
Scenario_BasicCrossL(withDefaultDemand=True)
35    def __init__(self, withDefaultDemand=True):
36        Scenario.__init__(self, self.NAME)
37        self.netName = self.fullPath(self.NET_FILE)
38        self.demandName = self.fullPath("routes.rou.xml")
39        # network
40        if fileNeedsRebuild(self.netName, "netconvert"):
41            print("Network in '%s' needs to be rebuild" % self.netName)
42            defaultEdge = Edge(numLanes=1, maxSpeed=13.89)
43            defaultEdge.addSplit(100, 1)
44            defaultEdge.lanes = [Lane(dirs="rs"), Lane(dirs="l")]
45            netGen = netGenerator.cross(None, defaultEdge)
46            # not nice, the network name should be given/returned
47            netGen.build(self.netName)
48        # demand
49        if withDefaultDemand:
50            print("Demand in '%s' needs to be rebuild" % self.demandName)
51            self.demand = demandGenerator.Demand()
52            # why isn't it possible to get a network and return all possible
53            # routes or whatever - to ease the process
54            self.demand.addStream(demandGenerator.Stream(
55                None, 0, 3600, 1000, "2/1_to_1/1", "1/1_to_0/1", {.2: "hdv", .8: "passenger"}))
56            if fileNeedsRebuild(self.demandName, "duarouter"):
57                self.demand.build(0, 3600, self.netName, self.demandName)
NAME = 'BasicCrossL'
THIS_DIR = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/BasicCrossL'
TLS_FILE = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/BasicCrossL/tls.add.xml'
NET_FILE = '/home/delphi/gcc/sumo/tools/sumolib/scenario/scenarios/BasicCrossL/net.net.xml'
netName
demandName