Changes in / [df9e412:49db841]
- File:
-
- 1 edited
-
benchmark/convoy/genConvoyStats.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/convoy/genConvoyStats.py
rdf9e412 r49db841 111 111 global handoff, maxCycle, maxCycleSum 112 112 113 # print("CurrNode: " + str(currNode) + " StartNode: " + str(startNode))113 # print("CurrNode: " + str(currNode)) 114 114 # print(currCycle) 115 115 # if we visit a node from a previous call then return since we have already … … 121 121 # found a cycle 122 122 if visited[currNode]: 123 # if currNode == startNode:124 123 # print("LocalVisited, curr: " + str(currSum) + ", max: " + str(maxCycleSum) + ", Start: " + str(startNode) ) 125 124 # if the cycle contains the start node check if it is our new max cycle … … 131 130 132 131 visited[currNode] = True 133 # print(visited) 132 134 133 for idx, val in enumerate(handoff[currNode]): 135 134 # continue if no edge 136 #if val == 0:137 #continue135 if val == 0: 136 continue 138 137 139 138 currCycle.append(currNode) 140 139 findLargestCycle(startNode, idx, visited, globalVisited, currSum + val, currCycle) 141 140 currCycle.pop() 142 # print(currNode) 141 143 142 visited[currNode] = False 144 143 … … 148 147 global handoff, sumPerRow, handoffTotal, maxCycle, maxCycleSum, minBound, maxBound, expected 149 148 currThds = len(handoff) 149 150 # find largest cycle 151 globalVisited = [False] * currThds 152 for i in range(currThds): 153 visited = [False] * currThds 154 findLargestCycle(i, i, visited, globalVisited, 0, []) 155 globalVisited[i] = True 150 156 151 152 # This is NP-Hard and is currently not tractable so we just estimate the largest cycle 153 # the code to do so is commented below 154 155 # find largest cycle 156 # globalVisited = [False] * currThds 157 # for i in range(currThds): 158 # # print(i) 159 # visited = [False] * currThds 160 # findLargestCycle(i, i, visited, globalVisited, 0, []) 161 # globalVisited[i] = True 162 163 # # calculate stats 164 # cycleHandoffs = [] 165 # cycleHandoffs.append(handoff[maxCycle[-1]][maxCycle[0]]) 166 # sumOfMaxCycleRows = sumPerRow[maxCycle[0]] 167 168 # # expected handoff is MULT P( handoff ) for each handoff in max cycle 169 # expectedConvoy = handoff[maxCycle[-1]][maxCycle[0]] / sumPerRow[maxCycle[-1]] 170 # for idx, val in enumerate(maxCycle[1:]): 171 # cycleHandoffs.append(handoff[maxCycle[idx]][val]) 172 # sumOfMaxCycleRows += sumPerRow[val] 173 # expectedConvoy = expectedConvoy * handoff[maxCycle[idx]][val] / sumPerRow[maxCycle[idx]] 174 175 # # adjust expected bound 176 # # if max cycle contains all nodes, sumOfMaxCycleRows / handoffTotal == 1 177 # # else this adjusts the expected bound to compensate for the cycle not visiting all nodes 178 # # also mult by 100 to turn into percentage from decimal 179 # expectedConvoy = expectedConvoy * sumOfMaxCycleRows * 100 / handoffTotal 180 181 ################################ 182 183 #start of approximation code is here: 184 185 # instead we take the maximum handoff from each row and assume it is all a cycle as an approximation 186 maxCycle = [] 187 maxCycleSum = 0 157 # calculate stats 188 158 cycleHandoffs = [] 189 expectedConvoy = 100 190 for i in range(currThds): 191 currMax = max(handoff[i]) 192 maxCycle.append(i) 193 cycleHandoffs.append(currMax) 194 maxCycleSum += currMax 195 expectedConvoy = expectedConvoy * currMax / sumPerRow[i] 196 197 sumOfMaxCycleRows = handoffTotal 198 199 # end of approximation code 200 ################################################### 159 cycleHandoffs.append(handoff[maxCycle[-1]][maxCycle[0]]) 160 sumOfMaxCycleRows = sumPerRow[maxCycle[0]] 161 162 # expected handoff is MULT P( handoff ) for each handoff in max cycle 163 expectedConvoy = handoff[maxCycle[-1]][maxCycle[0]] / sumPerRow[maxCycle[-1]] 164 for idx, val in enumerate(maxCycle[1:]): 165 cycleHandoffs.append(handoff[maxCycle[idx]][val]) 166 sumOfMaxCycleRows += sumPerRow[val] 167 expectedConvoy = expectedConvoy * handoff[maxCycle[idx]][val] / sumPerRow[maxCycle[idx]] 168 169 # adjust expected bound 170 # if max cycle contains all nodes, sumOfMaxCycleRows / handoffTotal == 1 171 # else this adjusts the expected bound to compensate for the cycle not visiting all nodes 172 # also mult by 100 to turn into percentage from decimal 173 expectedConvoy = expectedConvoy * sumOfMaxCycleRows * 100 / handoffTotal 201 174 202 175 # upper bound is the percentage of all handoffs that occur in the maximum possible cycle
Note:
See TracChangeset
for help on using the changeset viewer.