def update_edge_properties(self, lowerBoundTime, interval):
        """
        Updates the edge properties after computation of a new flowInterval
        :param lowerBoundTime: lowerBoundTime of flowInterval
        :param interval: flowInterval
        """

        for v, w in self.network.edges():
            # Inflow changes
            vTimeLower, vTimeUpper = self.node_label(
                v, interval.lowerBoundTime), self.node_label(
                    v, interval.upperBoundTime)
            inflowChangeBool = Utilities.is_not_eq_tol(
                interval.NTFNodeLabelDict[v],
                0)  # Can we extend the inflow interval?
            inflowVal = interval.NTFEdgeFlowDict[
                (v,
                 w)] / interval.NTFNodeLabelDict[v] if inflowChangeBool else 0
            if inflowChangeBool:
                self.network[v][w]['inflow'][(vTimeLower,
                                              vTimeUpper)] = inflowVal

            if vTimeUpper < float('inf'):
                vLastTime = next(
                    reversed(self.network[v][w]['cumulativeInflow']))
                self.network[v][w]['cumulativeInflow'][
                    vTimeUpper] = self.network[v][w]['cumulativeInflow'][
                        vLastTime] + inflowVal * (vTimeUpper - vTimeLower)

            # Outflow changes
            wTimeLower, wTimeUpper = self.node_label(
                w, interval.lowerBoundTime), self.node_label(
                    w, interval.upperBoundTime)
            outflowChangeBool = Utilities.is_not_eq_tol(
                interval.NTFNodeLabelDict[w],
                0)  # Can we extend the outflow interval?
            outflowVal = interval.NTFEdgeFlowDict[
                (v,
                 w)] / interval.NTFNodeLabelDict[w] if outflowChangeBool else 0
            if outflowChangeBool:
                self.network[v][w]['outflow'][(wTimeLower,
                                               wTimeUpper)] = outflowVal

            if wTimeUpper < float('inf'):
                wLastTime = next(
                    reversed(self.network[v][w]['cumulativeOutflow']))
                self.network[v][w]['cumulativeOutflow'][
                    wTimeUpper] = self.network[v][w]['cumulativeOutflow'][
                        wLastTime] + outflowVal * (wTimeUpper - wTimeLower)

            # Queue size changes
            if vTimeUpper < float('inf'):
                self.update_queue_size(v, w, vTimeLower, vTimeUpper)
            self.animationIntervals[(v, w)].append(
                ((vTimeLower, vTimeUpper), (wTimeLower, wTimeUpper)))

            if vTimeUpper <= wTimeUpper and vTimeUpper != float('inf'):
                # Lies on shortest path
                self.network[v][w]['load'][vTimeUpper] = self.arc_load(
                    v, w, vTimeUpper)
Exemplo n.º 2
0
    def update_edge_properties(self, lowerBoundTime, interval):
        """
        Updates the edge properties after computation of a new flowInterval
        :param lowerBoundTime: lowerBoundTime of flowInterval
        :param interval: flowInterval
        """
        if lowerBoundTime == 0:
            # init in/outflow
            for v, w in self.network.edges():
                vTimeLower = self.node_label(v, 0)
                wTimeLower = self.node_label(w, 0)

                self.network[v][w]['inflow'] = OrderedDict()
                self.network[v][w]['inflow'][(0, vTimeLower)] = 0

                self.network[v][w]['outflow'] = OrderedDict()
                self.network[v][w]['outflow'][(0, wTimeLower)] = 0

                self.network[v][w]['cumulativeInflow'] = OrderedDict()
                self.network[v][w]['cumulativeInflow'][0] = 0
                self.network[v][w]['cumulativeInflow'][vTimeLower] = 0

                self.network[v][w]['cumulativeOutflow'] = OrderedDict()
                self.network[v][w]['cumulativeOutflow'][0] = 0
                self.network[v][w]['cumulativeOutflow'][wTimeLower] = 0

                self.network[v][w]['queueSize'] = OrderedDict()
                self.network[v][w]['queueSize'][0] = 0
                self.network[v][w]['queueSize'][
                    vTimeLower + self.network[v][w]['transitTime']] = 0

        for v, w in self.network.edges():

            # Inflow changes
            vTimeLower, vTimeUpper = self.node_label(
                v, interval.lowerBoundTime), self.node_label(
                    v, interval.upperBoundTime)
            inflowChangeBool = Utilities.is_not_eq_tol(
                interval.NTFNodeLabelDict[v],
                0)  # Can we extend the inflow interval?
            inflowVal = interval.NTFEdgeFlowDict[
                (v,
                 w)] / interval.NTFNodeLabelDict[v] if inflowChangeBool else 0
            if inflowChangeBool:
                self.network[v][w]['inflow'][(vTimeLower,
                                              vTimeUpper)] = inflowVal

            if vTimeUpper < float('inf'):
                vLastTime = next(
                    reversed(self.network[v][w]['cumulativeInflow']))
                self.network[v][w]['cumulativeInflow'][
                    vTimeUpper] = self.network[v][w]['cumulativeInflow'][
                        vLastTime] + inflowVal * (vTimeUpper - vTimeLower)

            # Outflow changes
            wTimeLower, wTimeUpper = self.node_label(
                w, interval.lowerBoundTime), self.node_label(
                    w, interval.upperBoundTime)
            outflowChangeBool = Utilities.is_not_eq_tol(
                interval.NTFNodeLabelDict[w],
                0)  # Can we extend the outflow interval?
            outflowVal = interval.NTFEdgeFlowDict[
                (v,
                 w)] / interval.NTFNodeLabelDict[w] if outflowChangeBool else 0
            if outflowChangeBool:
                self.network[v][w]['outflow'][(wTimeLower,
                                               wTimeUpper)] = outflowVal

            if wTimeUpper < float('inf'):
                wLastTime = next(
                    reversed(self.network[v][w]['cumulativeOutflow']))
                self.network[v][w]['cumulativeOutflow'][
                    wTimeUpper] = self.network[v][w]['cumulativeOutflow'][
                        wLastTime] + outflowVal * (wTimeUpper - wTimeLower)

            # Queue size changes
            if vTimeUpper < float('inf'):
                lastQueueSizeTime = next(
                    reversed(self.network[v][w]['queueSize']))
                lastQueueSize = self.network[v][w]['queueSize'][
                    lastQueueSizeTime]
                self.network[v][w]['queueSize'][
                    vTimeUpper + self.network[v][w]['transitTime']] = max(
                        0, lastQueueSize +
                        (inflowVal - self.network[v][w]['outCapacity']) *
                        (vTimeUpper - vTimeLower))

            self.animationIntervals[(v, w)].append(
                ((vTimeLower, vTimeUpper), (wTimeLower, wTimeUpper)))