def compute_flowInterval(self): """Method to compute a single flowInterval""" # Get lowerBoundTime lowerBoundTime = 0 if not self.flowIntervals else self.flowIntervals[ -1][1] # Compute resettingEdges cmp_queue = lambda v, w, t: \ Utilities.is_greater_tol(self.node_label(w, t), self.node_label(v, t) + self.network[v][w]['transitTime']) resettingEdges = [(v, w) for v, w in self.network.edges() if cmp_queue(v, w, lowerBoundTime)] \ if lowerBoundTime > 0 else [] edges_to_choose_from = self.network.edges( ) # Fulledges can be non resetting! fullEdges = [(v, w) for v, w in edges_to_choose_from if self.is_full(v, w, self.node_label(v, lowerBoundTime)) ] if lowerBoundTime > 0 else [] minInflowBound = None interval = FlowInterval_spillback(self.network, resettingEdges=resettingEdges, fullEdges=fullEdges, lowerBoundTime=lowerBoundTime, inflowRate=self.inflowRate, minCapacity=self.minOutCapacity, counter=self.counter, outputDirectory=self.rootPath, templateFile=self.templateFile, scipFile=self.scipFile, timeout=self.timeout, minInflowBound=minInflowBound) if lowerBoundTime == 0: interval.shortestPathNetwork = Utilities.get_shortest_path_network( self.network) # Compute shortest path network for v, w in interval.shortestPathNetwork.edges(): interval.shortestPathNetwork[v][w][ 'inflowBound'] = self.network[v][w]['inCapacity'] else: interval.shortestPathNetwork = Utilities.get_shortest_path_network( self.network, labels={ v: self.node_label(v, lowerBoundTime) for v in self.network }) # Compute shortest path network for v, w in interval.shortestPathNetwork.edges(): vTimeLower = self.node_label(v, lowerBoundTime) minimizer = self.get_outflow( v, w, vTimeLower) if (v, w) in fullEdges else float('inf') interval.shortestPathNetwork[v][w]['inflowBound'] = min( minimizer, self.network[v][w]['inCapacity']) minInflowBound = Utilities.compute_min_attr_of_network( interval.shortestPathNetwork, 'inflowBound') interval.set_minInflowBound(minInflowBound) start = time.time() interval.get_ntf() ''' if self.advancedAlgo: interval.get_ntf_advanced() else: interval.get_ntf() ''' end = time.time() self.computationalTime += (end - start) interval.computationalTime = end - start self.preprocessedNodes += interval.preprocessedNodes self.preprocessedEdges += interval.preprocessedEdges self.lowerBoundsToIntervalDict[lowerBoundTime] = interval if lowerBoundTime == 0: self.init_edge_properties() interval.compute_alpha({ node: self.node_label(node, lowerBoundTime) for node in self.network }) self.flowIntervals.append( (interval.lowerBoundTime, interval.upperBoundTime, interval)) # Update in/out-flow rates self.update_edge_properties(lowerBoundTime, interval) self.counter += 1 self.numberOfSolvedIPs += interval.numberOfSolvedIPs self.infinityReached = (interval.alpha == float('inf'))
def compute_flowInterval(self): """Method to compute a single flowInterval""" # Get lowerBoundTime lowerBoundTime = 0 if not self.flowIntervals else self.flowIntervals[ -1][1] # Compute resettingEdges resettingEdges = [(v, w) for v, w in self.network.edges() if Utilities.is_greater_tol( self.node_label(w, lowerBoundTime), self.node_label(v, lowerBoundTime) + self.network[v][w]['transitTime'], TOL) ] if lowerBoundTime > 0 else [] interval = FlowInterval( self.network, resettingEdges=resettingEdges, lowerBoundTime=lowerBoundTime, inflowRate=self.inflowRate, minCapacity=self.minCapacity, counter=self.counter, outputDirectory=self.rootPath, templateFile=self.templateFile, scipFile=self.scipFile, timeout=self.timeout, ) if lowerBoundTime == 0: interval.shortestPathNetwork = Utilities.get_shortest_path_network( self.network) # Compute shortest path network else: interval.shortestPathNetwork = Utilities.get_shortest_path_network( self.network, labels={ v: self.node_label(v, lowerBoundTime) for v in self.network }) # Compute shortest path network start = time.time() if self.advancedAlgo: interval.get_ntf_advanced() else: interval.get_ntf() end = time.time() self.computationalTime += (end - start) interval.computationalTime = end - start self.preprocessedNodes += interval.preprocessedNodes self.preprocessedEdges += interval.preprocessedEdges self.lowerBoundsToIntervalDict[lowerBoundTime] = interval interval.compute_alpha({ node: self.node_label(node, lowerBoundTime) for node in self.network }) self.flowIntervals.append( (interval.lowerBoundTime, interval.upperBoundTime, interval)) # Update in/out-flow rates self.update_edge_properties(lowerBoundTime, interval) self.counter += 1 self.numberOfSolvedIPs += interval.numberOfSolvedIPs self.infinityReached = (interval.alpha == float('inf'))