How to use the sumo.tools.detector.flowrouter.Route function in sumo

To help you get started, we’ve selected a few sumo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse / sumo / sumo / tools / detector / flowrouter.py View on Github external
def updateFlow(self, startVertex, endVertex):
        assert endVertex.flowDelta < sys.maxsize
        if options.limit and endVertex.flowDelta > options.limit:
            endVertex.flowDelta = options.limit
        stubs = [Route(endVertex.flowDelta, [])]
        if DEBUG:
            print("  updateFlow start=%s end=%s flowDelta=%s" % (startVertex,
                                                                 endVertex, endVertex.flowDelta))
        upstreamBackEdges = list(self.getBackEdges(startVertex, endVertex))
        newRoutes = []
        alteredRoutes = []
        flowDeltas = []
        cycleStartStep = (startVertex == endVertex)
        currVertex = endVertex
        while currVertex != startVertex or cycleStartStep:
            cycleStartStep = False
            currEdge = currVertex.inPathEdge
            if currEdge.target == currVertex:
                if DEBUG:  # and not currEdge.kind == 'junction':
                    print("    incFlow edge=%s delta=%s" % (currEdge, endVertex.flowDelta))
                flowDeltas.append((currEdge, endVertex.flowDelta))
github eclipse / sumo / sumo / tools / detector / flowrouter.py View on Github external
continue
                    edgePos = route.edges.index(currEdge)
                    backPath = False
                    hadForward = False
                    for edge in route.edges[edgePos + 1:]:
                        if edge in backSet:
                            if hadForward:
                                if DEBUG:
                                    print("      skipping", route, "because", edge, "is in", backSet)
                                backPath = True
                                break
                        else:
                            hadForward = True
                    if backPath:
                        continue
                    newRoute = Route(min(routeStub.frequency, route.frequency if route.newFrequency is None else route.newFrequency),
                                     route.edges[:edgePos] + routeStub.edges)
                    newRoutes.append(newRoute)
                    for edge in newRoute.edges:
                        edge.newRoutes.append(route)
                    newStubs.append(Route(newRoute.frequency,
                                          route.edges[edgePos + 1:]))
                    if route.newFrequency is None:
                        route.newFrequency = route.frequency
                    route.newFrequency -= newRoute.frequency
                    alteredRoutes.append(route)
                    routeStub.frequency -= newRoute.frequency
                    if routeStub.frequency == 0:
                        break
                if routeStub.frequency > 0:
                    if DEBUG:
                        print("      Could not split", routeStub)
github eclipse / sumo / sumo / tools / detector / flowrouter.py View on Github external
if edge in backSet:
                            if hadForward:
                                if DEBUG:
                                    print("      skipping", route, "because", edge, "is in", backSet)
                                backPath = True
                                break
                        else:
                            hadForward = True
                    if backPath:
                        continue
                    newRoute = Route(min(routeStub.frequency, route.frequency if route.newFrequency is None else route.newFrequency),
                                     route.edges[:edgePos] + routeStub.edges)
                    newRoutes.append(newRoute)
                    for edge in newRoute.edges:
                        edge.newRoutes.append(route)
                    newStubs.append(Route(newRoute.frequency,
                                          route.edges[edgePos + 1:]))
                    if route.newFrequency is None:
                        route.newFrequency = route.frequency
                    route.newFrequency -= newRoute.frequency
                    alteredRoutes.append(route)
                    routeStub.frequency -= newRoute.frequency
                    if routeStub.frequency == 0:
                        break
                if routeStub.frequency > 0:
                    if DEBUG:
                        print("      Could not split", routeStub)
                    return False
        stubs.extend(newStubs)
        return True