Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your...
-
Upload
nickolas-williams -
Category
Documents
-
view
215 -
download
1
Transcript of Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your...
![Page 1: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/1.jpg)
Administration
• CI meetings resume next week, as usual• Some TAs in labs, plus Dr. Betz
– Go to your lab as usual– If your TA is not there, ask for help from
another TA– Update your wiki as usual we are still
grading its quality / your project management• Your TA will grade if he/she still working• Or if your TA is out at end of term, Dr. Betz + CI will
assign grade, based on wiki quality & CI input
• Self-evaluation of oral presentation 1– Due Monday, March 9
![Page 2: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/2.jpg)
BFS with Re-expansionbool bfsPath (Node* sourceNode, int destID) { ... bool found = false;
while (wavefront not empty && has entry < bestPathLen) { waveElem wave = wavefront.front (); wavefront.pop_front(); // Remove from wavefront Node *node = wave.node;
if (wave.pathLen < node->pathLen) { node->reachingEdge = wave.edgeID; node->pathLen = wave.pathLen;
if (node->id == destID) { found = true; bestPathLen = node->pathLen; }
![Page 3: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/3.jpg)
BFS with Re-expansion
for each (outEdge of node) { Node *toNode = outEdge.toNode; wavefront.push_back ( waveElem(toNode, outEdge.id, node.pathLen + travelTime (outEdge)); } } // End if best path to this node } // End while wavefront might yield a better solution
return (found); }
![Page 4: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/4.jpg)
Complexitywhile (wavefront not empty && has entry < bestPathLen) {
• If we use a visited flag:– Executes maximum N times– Work in loop is O(1)O(N)
~100,000 10-7
< 1 s
• BFS with re-expansion:– Difficult to bound – But in practice much less than O(2N) of DFS with re-expansion
• How could we limit re-expansion?
![Page 5: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/5.jpg)
Limiting Re-expansion
• Only re-visit a node in BFS when– We find a new path with a lower cost to that
node
![Page 6: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/6.jpg)
Re-Expansion Wastes CPU
![Page 7: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/7.jpg)
BFS Wavefrontbool bfsPath (Node* sourceNode, int destID) {
list<waveElem> wavefront;
while (wavefront not empty && has entry < bestPathLen) { waveElem wave = wavefront.front (); wavefront.pop_front(); // Remove from wavefront Node *node = wave.node;
if (wave.pathLen < node->pathLen) { ... wavefront.push_back ( waveElem(toNode, outEdge.id, node.pathLen + travelTime (outEdge)); ...
78, 20s 2, 5s 39, 12s Wavefront: FIFO Queue
![Page 8: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/8.jpg)
c, 10 s
Take the Smallest Entry in Wavefront?source
dest
c
a
b
d
wavefront =0
1
2
3
{0/0s}{1/20s,2/5s}{1/20s,1/10s}{1/20s,3/16s}
4
{1/20s,4/19s}{1/20s}
b, 5 s
d, 16 s
e, 19 s
e
t = 5 s
t = 5 s
t = 20 s
t = 6 s
t = 3 s Found shortest path with no re-expansion
Djikstra’s algorithm
![Page 9: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/9.jpg)
How Much Work To Get Smallest?
• Linked list– Insertion: O(1)– Remove smallest: scan entire list
• O(M), where M is active wavefront entries• M can be up to O(N), but usually more like O(N0.5)
• Binary tree?– Insertion: O(log M)– Remove smallest
• O(log M)
78, 20s 2, 5s 39, 12s list<waveElem> wavefront
![Page 10: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/10.jpg)
Overall Complexity
• O(N) items added/removed in wavefront– Work to remove next item:
• Linked list: O(M) O(N0.5) to O(N)• Binary tree: O(log M) O (log N)
• Overall complexity– Linked list: O(N1.5) to O(N2)
• N 100,000 and ~10-7 s per function• 3.2 s to 1000 s (wide range!)
– Binary tree: O(N logN)• <1 s
![Page 11: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/11.jpg)
Anything Faster than Binary Tree?
• Heap– Insertion: O(log N)– Removal of smallest element: O(log N)– But absolute time smaller than binary tree
![Page 12: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/12.jpg)
(Min) Heap
• Like a binary tree– But not fully sorted
• Key of parent < key of children– For all nodes in the tree– Very good for priority queues
3
20 36
40 35 37 60
50
Smallest item always at root
of heap
No ordering between sibling
nodes in the heap
![Page 13: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/13.jpg)
BFS and Dijkstra Demo
![Page 14: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/14.jpg)
Better than Dijkstra’s Algorithm?
![Page 15: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/15.jpg)
Dijkstra / BFS: Not So Smart!
Why are we examining nodes in the wrong direction?Wasted CPU time!
![Page 16: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/16.jpg)
Ideas?
• Only look at nodes that take us closer to the destination?– distToDest(node) < distToDest (predecessor)
• Too severe – can result in no path, or not shortest path
![Page 17: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/17.jpg)
A* Algorithms
• Enhancements to Dijkstra’s algorithm• Use domain-specific heuristics
– E.g. we are working in a map– Can estimate which graph nodes are closer vs. further
from dest
• Incorporate into the wavefront sorting/ordering• Look at the most promising partial solutions first• “Best-first search”
![Page 18: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/18.jpg)
A* Search
Mostly searches in the right direction, but will explore some in other directions
Can go around blockages (e.g. 401)
![Page 19: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/19.jpg)
A* Demo
![Page 20: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/20.jpg)
Milestone 3 Speed
• 11% of final mark• 7%: path quality and speed
– Some cleverness required for full marks– Implement some A* techniques to pass hardest speed
tests– Read up online
• Milestone 4 (another 11% of mark)– Find a good path to connect M intersections
• Courier company
– Will have a CPU time limit– Will benefit from fast path-finding algorithms
• A good milestone 3 implementation will help you!
![Page 21: Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.](https://reader033.fdocuments.in/reader033/viewer/2022052701/56649f1f5503460f94c37d70/html5/thumbnails/21.jpg)
Milestone 3 User Interface
• Make it usable: 4% of final mark• Lots of ideas in m3 handout
– Don’t need to implement them all