1 00:00:00,060 --> 00:00:02,500 The following content is provided under a Creative 2 00:00:02,500 --> 00:00:04,019 Commons license. 3 00:00:04,019 --> 00:00:06,360 Your support will help MIT OpenCourseWare 4 00:00:06,360 --> 00:00:10,730 continue to offer high quality educational resources for free. 5 00:00:10,730 --> 00:00:13,340 To make a donation or view additional materials 6 00:00:13,340 --> 00:00:17,248 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,248 --> 00:00:17,873 at ocw.mit.edu. 8 00:00:21,130 --> 00:00:24,210 PROFESSOR: This week's problem is from the 2008 quiz 9 00:00:24,210 --> 00:00:25,710 one on search. 10 00:00:25,710 --> 00:00:30,060 It is motivated by the search of evil overlord, Mark Vader, who 11 00:00:30,060 --> 00:00:32,780 is shopping for a new evil stronghold. 12 00:00:32,780 --> 00:00:34,720 He starts from his current stronghold, 13 00:00:34,720 --> 00:00:37,450 which is S, the Depth-First Search Star. 14 00:00:37,450 --> 00:00:40,420 Now the Depth-First Search Star has the following qualities. 15 00:00:40,420 --> 00:00:44,530 It has a small, thermal Exhaust Pipe Weakness. 16 00:00:44,530 --> 00:00:47,240 It has the quality of That's No Moon, 17 00:00:47,240 --> 00:00:49,870 but it does not have a Race of Enslaved Minions, 18 00:00:49,870 --> 00:00:54,240 or a Secret Escape Route, or Sharks with Laser Beams. 19 00:00:54,240 --> 00:00:56,360 Now when I originally wrote this problem in 2008, 20 00:00:56,360 --> 00:00:58,810 there was another quality that very important. 21 00:00:58,810 --> 00:01:03,060 It was a giant Laser, and it did have that property, as did 22 00:01:03,060 --> 00:01:05,470 Dr. Evil's Moon Base, but that was removed 23 00:01:05,470 --> 00:01:06,710 to make it easier to solve. 24 00:01:06,710 --> 00:01:10,110 So we're going to solve it without the giant laser, 25 00:01:10,110 --> 00:01:12,520 that we can just have the Sharks with Laser Beams. 26 00:01:12,520 --> 00:01:21,030 So Mark Vader has gone to Ackbar's Emporium of New Evil 27 00:01:21,030 --> 00:01:24,260 Strongholds, which are listed on the left, 28 00:01:24,260 --> 00:01:27,420 and he's trying to figure out the best 29 00:01:27,420 --> 00:01:31,160 way to get from his current stronghold 30 00:01:31,160 --> 00:01:34,290 to his goal stronghold, the 603 Fortress, which 31 00:01:34,290 --> 00:01:37,170 has the admirable qualities of no small thermal Exhaust Pipe 32 00:01:37,170 --> 00:01:40,980 Weakness, and it still has That's No Moon. 33 00:01:40,980 --> 00:01:42,660 It has a Race of Enslaved Minions, 34 00:01:42,660 --> 00:01:45,480 and a Secret Escape Route, and Sharks with Laser Beams. 35 00:01:45,480 --> 00:01:48,640 So it's got everything you would want and no weakness. 36 00:01:48,640 --> 00:01:53,120 However, he can only move between fortresses that 37 00:01:53,120 --> 00:01:56,430 have exactly one difference. 38 00:01:56,430 --> 00:01:58,980 Fortunately, Mark remembers how to perform the search 39 00:01:58,980 --> 00:02:01,810 techniques he learned in 6.034 from his mentor, Emperor 40 00:02:01,810 --> 00:02:03,140 Palpatine. 41 00:02:03,140 --> 00:02:06,040 So we've got several fortresses here. 42 00:02:06,040 --> 00:02:07,980 We've got the Depth-First Search Star. 43 00:02:07,980 --> 00:02:12,070 We've also got Shaoul Ghoul, which 44 00:02:12,070 --> 00:02:15,510 has the qualities, basically, of That's 45 00:02:15,510 --> 00:02:17,620 No Moon, and none of the other qualities. 46 00:02:17,620 --> 00:02:22,740 Dol Guldur here, has got the Exhaust Pipe Weakness somehow, 47 00:02:22,740 --> 00:02:25,450 despite being Sauron's stronghold. 48 00:02:25,450 --> 00:02:28,630 It's not a moon, and it has those enslaved minions. 49 00:02:28,630 --> 00:02:30,120 I guess the Orcs are enslaved. 50 00:02:30,120 --> 00:02:33,565 Moonraker, here, only has the Exhaust Pipe Weakness, 51 00:02:33,565 --> 00:02:35,230 so it's not very good. 52 00:02:35,230 --> 00:02:39,100 But James Bond didn't need to deal with stuff. 53 00:02:39,100 --> 00:02:42,340 Zeal Underwater Palace has That's 54 00:02:42,340 --> 00:02:44,760 No Moon and a Secret Escape Route. 55 00:02:44,760 --> 00:02:48,750 Zeromus' Lunar Core has an Exhaust Pipe Weakness 56 00:02:48,750 --> 00:02:50,620 and a Race of Enslaved Minions. 57 00:02:50,620 --> 00:02:54,950 Whalers of the Moon Ride has the Exhaust Pipe Weakness, 58 00:02:54,950 --> 00:02:57,980 Race of Enslaved Minions, and Sharks with Laser Beams. 59 00:02:57,980 --> 00:02:59,730 6.03 Fortress we've already been over. 60 00:02:59,730 --> 00:03:02,640 Atlantis has all qualities except for a Secret Escape 61 00:03:02,640 --> 00:03:03,350 Route. 62 00:03:03,350 --> 00:03:07,230 Willy Wonka's Factory has some of everything. 63 00:03:07,230 --> 00:03:09,240 It is, after all, Willy Wonka's Factory. 64 00:03:09,240 --> 00:03:12,012 Highlight, the Race of Enslaved Minions, the Oompa Loompas. 65 00:03:12,012 --> 00:03:14,620 And Dr. Evil's Moon Base is only missing 66 00:03:14,620 --> 00:03:19,860 That's No Moon, because it is a moon, because it's a moon base. 67 00:03:19,860 --> 00:03:23,970 So if you got all the references that 68 00:03:23,970 --> 00:03:27,114 were used in making those fortresses, I'm sorry. 69 00:03:27,114 --> 00:03:28,488 There's nothing I can do for you. 70 00:03:37,110 --> 00:03:39,920 Now, Mark, being a clever evil overlord, 71 00:03:39,920 --> 00:03:45,540 realizes that he can produce a graph of the exploration 72 00:03:45,540 --> 00:03:48,510 choices with edges joining strongholds that 73 00:03:48,510 --> 00:03:50,160 differ by just one feature. 74 00:03:50,160 --> 00:03:52,150 So although this is a graph here, 75 00:03:52,150 --> 00:03:56,380 as Patrick often says-- and you get to hear again right now-- 76 00:03:56,380 --> 00:03:58,720 search is about choice, not just about maps. 77 00:03:58,720 --> 00:04:01,450 So we're not moving around anywhere in the real world, 78 00:04:01,450 --> 00:04:04,080 but we certainly are going to move around 79 00:04:04,080 --> 00:04:07,200 this graph to pick between these many stronghold choices. 80 00:04:07,200 --> 00:04:09,010 How can we decide where to travel? 81 00:04:09,010 --> 00:04:10,660 Well, we're about to find out. 82 00:04:10,660 --> 00:04:13,730 So we've got this lovely graph right here, 83 00:04:13,730 --> 00:04:16,980 and now we're going to get to do depth-first search 84 00:04:16,980 --> 00:04:19,019 on the graph. 85 00:04:19,019 --> 00:04:21,550 Now there's a lot of ways to do search, 86 00:04:21,550 --> 00:04:23,410 and you've seen Patrick do it, you 87 00:04:23,410 --> 00:04:26,710 may have seen some people do it in recitation. 88 00:04:26,710 --> 00:04:29,650 And I'm going to offer you guys a unique opportunity to see me 89 00:04:29,650 --> 00:04:33,650 do search in one of several ways, or possibly more. 90 00:04:33,650 --> 00:04:35,920 I have the tried and true method. 91 00:04:35,920 --> 00:04:37,870 You have the queue, or agenda, or whatever 92 00:04:37,870 --> 00:04:38,930 you want to call it. 93 00:04:38,930 --> 00:04:40,970 You keep track of it at every level. 94 00:04:40,970 --> 00:04:43,560 You make damn sure that everything you're doing 95 00:04:43,560 --> 00:04:44,180 is right. 96 00:04:44,180 --> 00:04:47,340 It takes a long time, and you get the answer right. 97 00:04:47,340 --> 00:04:50,170 Or there's one where you only work with the goal tree, 98 00:04:50,170 --> 00:04:53,920 and you draw it really fast, and you might make a mistake, 99 00:04:53,920 --> 00:04:56,070 but it's going to solve it more quickly. 100 00:04:56,070 --> 00:04:59,310 So who would rather see the reliable, but slower, approach? 101 00:05:03,070 --> 00:05:06,271 Who would rather see the faster, but less reliable, approach? 102 00:05:06,271 --> 00:05:06,770 All right. 103 00:05:06,770 --> 00:05:08,917 Monte Carlo people here, rather than Las Vegas. 104 00:05:08,917 --> 00:05:10,500 If you don't know what that is, you'll 105 00:05:10,500 --> 00:05:12,200 learn it in algorithms class. 106 00:05:12,200 --> 00:05:12,750 All right. 107 00:05:12,750 --> 00:05:14,520 Then there's a third approach that I probably 108 00:05:14,520 --> 00:05:16,853 won't show you unless there's overwhelming favor for it. 109 00:05:16,853 --> 00:05:19,390 That is the approach that is manically fast 110 00:05:19,390 --> 00:05:21,670 and will solve depth-first search in no time at all, 111 00:05:21,670 --> 00:05:24,560 but it is very likely to make mistakes. 112 00:05:24,560 --> 00:05:26,310 That is the approach that I use when 113 00:05:26,310 --> 00:05:27,800 solving depth-first search. 114 00:05:27,800 --> 00:05:30,466 I've used it enough times that I don't make mistakes that often, 115 00:05:30,466 --> 00:05:31,910 but even I still do. 116 00:05:31,910 --> 00:05:33,480 So does anyone want to see that one? 117 00:05:35,741 --> 00:05:36,240 OK. 118 00:05:36,240 --> 00:05:37,530 Not that many people. 119 00:05:37,530 --> 00:05:38,650 Well, it doesn't take much time, but I'm 120 00:05:38,650 --> 00:05:40,722 just afraid that if I show it you, that you'll be like, ooh, 121 00:05:40,722 --> 00:05:41,930 that's the only way to do it. 122 00:05:41,930 --> 00:05:45,370 So we'll save that for later if we have more time. 123 00:05:45,370 --> 00:05:47,690 It essentially, for people that are interested, 124 00:05:47,690 --> 00:05:50,010 involves just using your chalk or finger 125 00:05:50,010 --> 00:05:51,820 to trace through the tree really fast 126 00:05:51,820 --> 00:05:56,440 and figure out what it's doing by drawing little tiny lines. 127 00:05:56,440 --> 00:05:59,540 It is very fast, but it's not very accurate. 128 00:05:59,540 --> 00:06:02,230 And you have shown, basically, no work if you get it wrong, 129 00:06:02,230 --> 00:06:03,800 so shame on you. 130 00:06:03,800 --> 00:06:06,237 OK. 131 00:06:06,237 --> 00:06:07,820 Well, let's do the somewhat faster way 132 00:06:07,820 --> 00:06:10,270 where we don't draw out the entire agenda, 133 00:06:10,270 --> 00:06:12,980 and then people who were the almost nobody who 134 00:06:12,980 --> 00:06:15,670 raised their hand for that way can check it out 135 00:06:15,670 --> 00:06:18,342 in tutorial the way that you do it using the agenda. 136 00:06:18,342 --> 00:06:19,800 So let's do it using the goal tree. 137 00:06:19,800 --> 00:06:21,620 So it's a bit faster that way. 138 00:06:21,620 --> 00:06:24,922 So we're going to start, starting at S, the start node, 139 00:06:24,922 --> 00:06:26,480 and going to G, the goal node. 140 00:06:26,480 --> 00:06:29,376 That's a standard notation, but make sure 141 00:06:29,376 --> 00:06:30,750 that when you're taking the test, 142 00:06:30,750 --> 00:06:33,920 you check to make sure where the start node is, 143 00:06:33,920 --> 00:06:35,900 where the goal node is. 144 00:06:35,900 --> 00:06:39,780 It's pretty much an asshole move to have 145 00:06:39,780 --> 00:06:41,416 a G node that isn't the goal node, 146 00:06:41,416 --> 00:06:43,040 but sometimes there won't be an S node. 147 00:06:43,040 --> 00:06:44,914 That's a pretty good clue that something else 148 00:06:44,914 --> 00:06:46,250 is the start node. 149 00:06:46,250 --> 00:06:49,650 Now there's a few little white star ideas that we have, 150 00:06:49,650 --> 00:06:52,080 or silver star ideas, for search. 151 00:06:52,080 --> 00:06:53,870 One is lexicography. 152 00:06:53,870 --> 00:06:54,940 What it lexicography? 153 00:06:54,940 --> 00:06:55,640 Who cares? 154 00:06:55,640 --> 00:06:58,330 Well, the most famous lexicographer I know of 155 00:06:58,330 --> 00:07:02,220 is Samuel Johnson, who wrote a really famous dictionary. 156 00:07:02,220 --> 00:07:04,480 And the only reason we care about it in this class 157 00:07:04,480 --> 00:07:07,060 is because you'll always see the instructions "break 158 00:07:07,060 --> 00:07:09,560 ties in lexicographic order." 159 00:07:09,560 --> 00:07:11,900 And then you might be like, wow, that's 160 00:07:11,900 --> 00:07:15,680 really rather a wordy word, or a sesquipedalion word, 161 00:07:15,680 --> 00:07:18,239 or whatever really long word you want to use to describe 162 00:07:18,239 --> 00:07:19,280 the word "lexicographic." 163 00:07:19,280 --> 00:07:20,860 What the heck does it mean? 164 00:07:20,860 --> 00:07:24,040 Basically, it means alphabetical order, 165 00:07:24,040 --> 00:07:27,670 like you would do in a dictionary. 166 00:07:27,670 --> 00:07:32,730 So for instance, in alphabetical order, A comes before B. 167 00:07:32,730 --> 00:07:36,310 So you would go to A before B. No, even beyond that point, 168 00:07:36,310 --> 00:07:40,450 there's several ways to do a lexicographic tiebreak. 169 00:07:40,450 --> 00:07:43,220 And it's not always consistent between algorithms 170 00:07:43,220 --> 00:07:45,830 how you would do a lexicographic tiebreaker. 171 00:07:45,830 --> 00:07:47,410 In the most recent time that Patrick 172 00:07:47,410 --> 00:07:49,700 was kind of randomly talking to the staff, 173 00:07:49,700 --> 00:07:52,600 he made it clear that the way he would like us to do it, 174 00:07:52,600 --> 00:07:55,000 and therefore, the way we'd like you to do it, 175 00:07:55,000 --> 00:07:59,347 is to tiebreak based on the very latest nodes at the end. 176 00:07:59,347 --> 00:08:01,430 So you might say, that's not really lexicographic. 177 00:08:01,430 --> 00:08:06,105 Wouldn't SAB come before SGA in the dictionary? 178 00:08:08,880 --> 00:08:12,980 And my answer to you is, yes, it would. 179 00:08:15,980 --> 00:08:19,180 Yes, yes, it definitely would. 180 00:08:19,180 --> 00:08:24,682 However, that is apparently what we're 181 00:08:24,682 --> 00:08:26,890 doing, according to the last thing that Patrick said, 182 00:08:26,890 --> 00:08:29,030 and we will keep you updated if he decides 183 00:08:29,030 --> 00:08:31,960 to go back to dictionary order. 184 00:08:31,960 --> 00:08:35,260 So that's lexicography. 185 00:08:35,260 --> 00:08:37,260 You might be wondering what the picture here is. 186 00:08:37,260 --> 00:08:39,720 Well, this is our friend, the ouroboros. 187 00:08:39,720 --> 00:08:41,840 Long has it been a symbol in alchemy 188 00:08:41,840 --> 00:08:49,350 of infinity, eternity, or maybe a sort of infinite energy 189 00:08:49,350 --> 00:08:51,680 engine, turning iron into gold. 190 00:08:51,680 --> 00:08:54,900 But today, unfortunately, the ouroboros 191 00:08:54,900 --> 00:09:02,100 is an endangered species because no biting your own tail 192 00:09:02,100 --> 00:09:03,860 in 6.034. 193 00:09:03,860 --> 00:09:05,630 A lot of people mess up from this. 194 00:09:05,630 --> 00:09:07,550 It's an honest mistake. 195 00:09:07,550 --> 00:09:11,034 I mean, we've gotten some emails from staff members who 196 00:09:11,034 --> 00:09:12,450 couldn't solve one of the problems 197 00:09:12,450 --> 00:09:13,741 because they forgot about this. 198 00:09:13,741 --> 00:09:16,870 So it's OK if you forget, but try your best to remember. 199 00:09:16,870 --> 00:09:19,520 No biting your own tail is the only smart thing 200 00:09:19,520 --> 00:09:20,360 our system does. 201 00:09:20,360 --> 00:09:23,540 You'll remember last week when we were talking about rules, 202 00:09:23,540 --> 00:09:27,090 and we were saying that the rule system is not a smart creature. 203 00:09:30,280 --> 00:09:33,631 It doesn't know that "not Polly is dead" 204 00:09:33,631 --> 00:09:35,380 should be the same as "Polly is not dead", 205 00:09:35,380 --> 00:09:36,338 or something like that. 206 00:09:36,338 --> 00:09:38,990 It's too dumb to figure that out. 207 00:09:38,990 --> 00:09:42,230 Well, this system is also dumb, but one thing it knows 208 00:09:42,230 --> 00:09:46,800 is that Patrick really hates if the same node appears twice 209 00:09:46,800 --> 00:09:49,010 within the same path. 210 00:09:49,010 --> 00:09:51,210 And it will destroy that immediately, 211 00:09:51,210 --> 00:09:53,330 before even adding it to the queue. 212 00:09:53,330 --> 00:09:53,860 It's gone. 213 00:09:53,860 --> 00:09:55,090 It's not considered. 214 00:09:55,090 --> 00:09:55,920 It's out of there. 215 00:09:55,920 --> 00:10:00,320 So very important, sad ouroboros, 216 00:10:00,320 --> 00:10:02,740 no biting your own tail. 217 00:10:02,740 --> 00:10:03,419 All right. 218 00:10:03,419 --> 00:10:04,960 So now that I've gotten through that, 219 00:10:04,960 --> 00:10:08,130 let's actually solve the problem with some depth-first search. 220 00:10:08,130 --> 00:10:09,020 How will we do that? 221 00:10:09,020 --> 00:10:11,436 Well, we're not going to use the queue, as popular demand, 222 00:10:11,436 --> 00:10:12,820 we're going to use a goal tree. 223 00:10:12,820 --> 00:10:19,560 So we'll start at node S. What are our choices at node S? 224 00:10:19,560 --> 00:10:22,850 Well, I'm going to force you guys to help. 225 00:10:22,850 --> 00:10:26,020 So it won't be quite as fast, but it'll be fun. 226 00:10:26,020 --> 00:10:28,566 So what are our choices at node S? 227 00:10:28,566 --> 00:10:29,065 You. 228 00:10:30,230 --> 00:10:30,771 AUDIENCE: Me? 229 00:10:30,771 --> 00:10:31,685 PROFESSOR: Yes. 230 00:10:31,685 --> 00:10:33,520 AUDIENCE: A or B? 231 00:10:33,520 --> 00:10:35,370 PROFESSOR: Not quite, and this is something 232 00:10:35,370 --> 00:10:36,510 I like about this problem. 233 00:10:36,510 --> 00:10:37,680 You got most of them. 234 00:10:37,680 --> 00:10:41,040 Do you see that there might be another choice? 235 00:10:41,040 --> 00:10:41,560 Everyone? 236 00:10:41,560 --> 00:10:43,730 Yeah, C. This is a big problem that 237 00:10:43,730 --> 00:10:48,870 has happened on a few different quiz problems where there's 238 00:10:48,870 --> 00:10:51,334 a sort of a grid that looks like a tree, 239 00:10:51,334 --> 00:10:53,000 or a graph that looks like a tree, where 240 00:10:53,000 --> 00:10:56,210 people aren't as willing to go up as they are to go down. 241 00:10:56,210 --> 00:10:59,090 You can see it on some of the other past quiz problems too. 242 00:10:59,090 --> 00:11:01,780 Make sure that you check the connectivity, 243 00:11:01,780 --> 00:11:04,570 and also note that unless otherwise specified-- 244 00:11:04,570 --> 00:11:10,250 and I don't think we've really done this much-- the little 245 00:11:10,250 --> 00:11:13,390 connecting edges in our graphs are bidirectional. 246 00:11:13,390 --> 00:11:15,320 You'll see a big arrow, and probably 247 00:11:15,320 --> 00:11:18,050 instructions written at least eight font sizes higher 248 00:11:18,050 --> 00:11:19,570 than all the rest of them, and bold, 249 00:11:19,570 --> 00:11:22,610 if we're going to do something different for this quiz. 250 00:11:22,610 --> 00:11:24,240 It happens that they do it sometimes, 251 00:11:24,240 --> 00:11:26,140 where I'll just say in recitation, we never do this. 252 00:11:26,140 --> 00:11:27,515 And then on the quiz, they do it. 253 00:11:27,515 --> 00:11:31,050 But it will be in giant bold letters, which also leads me 254 00:11:31,050 --> 00:11:32,960 to another silver star idea that I forgot 255 00:11:32,960 --> 00:11:34,085 to tell you guys last week. 256 00:11:34,085 --> 00:11:35,727 So I hope people didn't ditch out on me, 257 00:11:35,727 --> 00:11:36,670 like, oh, Mark's boring. 258 00:11:36,670 --> 00:11:37,670 We won't come next week. 259 00:11:37,670 --> 00:11:40,380 And then miss this one because it just came to my mind. 260 00:11:40,380 --> 00:11:42,975 That is, read the instructions. 261 00:11:42,975 --> 00:11:45,410 It is a very important thing for the quizzes, 262 00:11:45,410 --> 00:11:48,140 and Patrick will, in a later lecture, 263 00:11:48,140 --> 00:11:50,170 tell you guys, ask why five times, 264 00:11:50,170 --> 00:11:52,430 and he'll explain why that's a gold star idea. 265 00:11:52,430 --> 00:11:55,880 My parallel to this is read the instructions five times. 266 00:11:55,880 --> 00:11:59,580 Maybe not five, maybe three or four, but at least three. 267 00:11:59,580 --> 00:12:01,020 Read the instructions. 268 00:12:01,020 --> 00:12:02,139 Read them again. 269 00:12:02,139 --> 00:12:04,180 Then read them a third time only paying attention 270 00:12:04,180 --> 00:12:06,690 to whatever is bold and eight sizes larger 271 00:12:06,690 --> 00:12:09,370 than all the other ones, cause there's going to be something 272 00:12:09,370 --> 00:12:10,680 there that's that size. 273 00:12:10,680 --> 00:12:13,800 And it going to be the thing that everyone misses. 274 00:12:13,800 --> 00:12:16,750 So make sure you're not everyone, 275 00:12:16,750 --> 00:12:19,140 and you read the instructions a lot of times. 276 00:12:19,140 --> 00:12:20,990 But anyway, so yeah, we've got it right. 277 00:12:20,990 --> 00:12:26,140 S goes to A, B, and C. OK. 278 00:12:26,140 --> 00:12:28,070 We're looking at A, B, and C as possibilities. 279 00:12:28,070 --> 00:12:31,110 Everyone, help me make the lexicographic tiebreak. 280 00:12:31,110 --> 00:12:32,140 Where do we go? 281 00:12:32,140 --> 00:12:32,760 AUDIENCE: A. 282 00:12:32,760 --> 00:12:33,885 PROFESSOR: A. That's right. 283 00:12:37,240 --> 00:12:40,129 Actually, I'll call on you guys for other ones, 284 00:12:40,129 --> 00:12:41,670 but that first step is pretty simple. 285 00:12:41,670 --> 00:12:43,390 We could have everyone do it together. 286 00:12:43,390 --> 00:12:45,100 Everyone, A only leads to? 287 00:12:45,100 --> 00:12:45,890 AUDIENCE: D. 288 00:12:45,890 --> 00:12:46,890 PROFESSOR: That's right. 289 00:12:46,890 --> 00:12:49,232 Why doesn't it lead to S as well? 290 00:12:49,232 --> 00:12:50,642 AUDIENCE: [CHATTER] 291 00:12:50,642 --> 00:12:52,100 PROFESSOR: No biting your own tail. 292 00:12:52,100 --> 00:12:53,020 Everyone's right. 293 00:12:53,020 --> 00:12:53,980 Good job, everyone. 294 00:12:53,980 --> 00:12:54,480 All right. 295 00:12:54,480 --> 00:12:56,460 S leads to these three. 296 00:12:56,460 --> 00:13:01,060 You go to A, go to D. Dead end. 297 00:13:01,060 --> 00:13:01,955 Backtrack. 298 00:13:01,955 --> 00:13:02,455 OK. 299 00:13:02,455 --> 00:13:04,760 When we backtrack, we backtrack up to A. 300 00:13:04,760 --> 00:13:06,450 There's no other children. 301 00:13:06,450 --> 00:13:09,040 We backtrack up to S. Where will we go now? 302 00:13:09,040 --> 00:13:09,540 AUDIENCE: B. 303 00:13:09,540 --> 00:13:11,110 PROFESSOR: B. It's the next one alphabetically. 304 00:13:11,110 --> 00:13:11,800 All right. 305 00:13:11,800 --> 00:13:14,290 B can't go to S, so it only goes to? 306 00:13:14,290 --> 00:13:15,175 AUDIENCE: H. 307 00:13:15,175 --> 00:13:15,800 PROFESSOR: Yes. 308 00:13:15,800 --> 00:13:18,300 When we're at H, we can go to? 309 00:13:18,300 --> 00:13:19,440 AUDIENCE: [CHATTER] 310 00:13:19,440 --> 00:13:21,380 PROFESSOR: F or I. That's right. 311 00:13:21,380 --> 00:13:22,685 You guys get this. 312 00:13:22,685 --> 00:13:24,140 Depth-first search is easy. 313 00:13:24,140 --> 00:13:25,080 All right. 314 00:13:25,080 --> 00:13:26,900 But we choose? 315 00:13:26,900 --> 00:13:28,080 F. That's right. 316 00:13:28,080 --> 00:13:30,750 When we're at F, we can go to? 317 00:13:30,750 --> 00:13:33,450 E and J. That's right. 318 00:13:33,450 --> 00:13:35,030 We'll choose? 319 00:13:35,030 --> 00:13:36,650 E. When we're at E, we can go to? 320 00:13:39,550 --> 00:13:42,610 We can go to C. It's not on this particular path. 321 00:13:42,610 --> 00:13:46,300 People are correct when they say C. When we go to C, 322 00:13:46,300 --> 00:13:48,680 we can go to nowhere. 323 00:13:48,680 --> 00:13:49,280 We're dead. 324 00:13:49,280 --> 00:13:50,350 Backtrack. 325 00:13:50,350 --> 00:13:51,230 We backtrack. 326 00:13:51,230 --> 00:13:53,800 We can't do anything at E. We go to F. 327 00:13:53,800 --> 00:13:57,380 Now I forgot to tell you guys, but this is an important note. 328 00:13:57,380 --> 00:13:58,920 Someone's going to get this wrong. 329 00:13:58,920 --> 00:14:01,200 It's going to be one of you. 330 00:14:01,200 --> 00:14:03,410 Look around you, all through the room. 331 00:14:03,410 --> 00:14:05,730 At least one of you is going to do this. 332 00:14:05,730 --> 00:14:07,650 So, now I'm going to tell you not to do this, 333 00:14:07,650 --> 00:14:10,020 and then hopefully, that will still 334 00:14:10,020 --> 00:14:12,350 be true, but for fewer people. 335 00:14:12,350 --> 00:14:15,550 When I went to D, and then I backtracked, and I went to S, 336 00:14:15,550 --> 00:14:18,870 how many times did I backtrack? 337 00:14:18,870 --> 00:14:20,760 Once. 338 00:14:20,760 --> 00:14:22,016 I backtracked once. 339 00:14:22,016 --> 00:14:23,390 This would have been more obvious 340 00:14:23,390 --> 00:14:25,490 if we were doing the really slow boring agenda 341 00:14:25,490 --> 00:14:31,990 way, or queue way, because when we got to SAD, 342 00:14:31,990 --> 00:14:34,810 and we expanded it, and there was nothing left, 343 00:14:34,810 --> 00:14:36,380 we throw it off the top of the queue, 344 00:14:36,380 --> 00:14:37,963 and go to the next thing on the queue. 345 00:14:37,963 --> 00:14:40,130 And it turns out the next thing on the queue is SB. 346 00:14:40,130 --> 00:14:42,449 That step was only taken once. 347 00:14:42,449 --> 00:14:44,490 Since we're using the goal tree, which is faster, 348 00:14:44,490 --> 00:14:47,760 it looked like we did two, but we didn't. 349 00:14:47,760 --> 00:14:51,177 And if you use the queue, you'll see that because it'll go S, 350 00:14:51,177 --> 00:14:52,510 and then we expand that, SASBSC. 351 00:14:52,510 --> 00:14:53,690 SBIC OK. 352 00:14:53,690 --> 00:14:54,430 We expand SA. 353 00:14:54,430 --> 00:14:55,990 SADSBSC. 354 00:14:55,990 --> 00:14:56,740 We expand SAD. 355 00:14:56,740 --> 00:14:57,550 It's dead. 356 00:14:57,550 --> 00:14:58,660 SBSC. 357 00:14:58,660 --> 00:14:59,540 One backtrack. 358 00:14:59,540 --> 00:15:00,930 We're back at SB. 359 00:15:00,930 --> 00:15:04,650 So, so far we've done two, not four. 360 00:15:04,650 --> 00:15:07,980 It's pretty intuitive to say that you did two there. 361 00:15:07,980 --> 00:15:11,160 It turns out you didn't because of the algorithm that's 362 00:15:11,160 --> 00:15:15,820 backing what lets us do this goal tree search. 363 00:15:15,820 --> 00:15:19,824 So try to make sure you're not the one who says two. 364 00:15:19,824 --> 00:15:21,240 And I, on the other hand, will try 365 00:15:21,240 --> 00:15:24,870 to make sure that we don't take off too many points if you do. 366 00:15:24,870 --> 00:15:25,370 Question? 367 00:15:25,370 --> 00:15:28,178 AUDIENCE: So any time you backtrack, regardless 368 00:15:28,178 --> 00:15:31,760 of how much it chains, any backtracking 369 00:15:31,760 --> 00:15:32,945 is just considered once. 370 00:15:32,945 --> 00:15:36,580 PROFESSOR: It is always going to be considered one step. 371 00:15:36,580 --> 00:15:38,740 It's possible to backtrack two times in a row. 372 00:15:38,740 --> 00:15:40,930 Like, if B didn't go to anything, instead 373 00:15:40,930 --> 00:15:43,420 of going to H, then we might backtrack twice 374 00:15:43,420 --> 00:15:45,370 before we got to SC. 375 00:15:45,370 --> 00:15:47,853 Generally, anytime you draw a swizzle, if you're like me, 376 00:15:47,853 --> 00:15:49,853 and you draw a swizzle-- I suggest the swizzles. 377 00:15:49,853 --> 00:15:51,570 They're very nice little things. 378 00:15:51,570 --> 00:15:53,980 But any time you draw a swizzle on your graph, 379 00:15:53,980 --> 00:15:56,450 you have backtracked once. 380 00:15:56,450 --> 00:15:58,750 You could even write BT next to the swizzle, 381 00:15:58,750 --> 00:16:01,270 and go back and count those, or even just count the swizzles 382 00:16:01,270 --> 00:16:01,940 at the end. 383 00:16:01,940 --> 00:16:02,719 You've got it. 384 00:16:02,719 --> 00:16:03,510 You got the answer. 385 00:16:03,510 --> 00:16:06,009 Because they often ask, how many times have you backtracked? 386 00:16:08,830 --> 00:16:09,330 All right. 387 00:16:09,330 --> 00:16:11,590 So good questions, everyone. 388 00:16:11,590 --> 00:16:14,740 So anyway, we backtracked from C. Nothing at E. We go back. 389 00:16:14,740 --> 00:16:18,460 We were at F. So we were at SBHF. 390 00:16:18,460 --> 00:16:21,090 We go to J. It's the only choice. 391 00:16:21,090 --> 00:16:23,180 At J, we can only go to? 392 00:16:23,180 --> 00:16:23,680 AUDIENCE: I. 393 00:16:23,680 --> 00:16:26,140 PROFESSOR: And at I, we can only go to? 394 00:16:26,140 --> 00:16:28,000 And we win. 395 00:16:28,000 --> 00:16:30,950 It's not an optimal search, so as soon as we see anything 396 00:16:30,950 --> 00:16:33,450 with a G on the queue, boom. 397 00:16:33,450 --> 00:16:35,310 Winner. 398 00:16:35,310 --> 00:16:36,020 All right. 399 00:16:36,020 --> 00:16:37,960 And we're done. 400 00:16:37,960 --> 00:16:38,830 We did it. 401 00:16:38,830 --> 00:16:40,342 That wasn't too bad. 402 00:16:40,342 --> 00:16:42,550 For those of you who are vaguely interested in seeing 403 00:16:42,550 --> 00:16:45,254 how I would do it the really super fast way, 404 00:16:45,254 --> 00:16:46,420 it goes something like this. 405 00:16:46,420 --> 00:16:46,850 All right. 406 00:16:46,850 --> 00:16:47,400 ABC. 407 00:16:47,400 --> 00:16:48,520 A comes first. 408 00:16:48,520 --> 00:16:51,361 Only D. Backtrack. 409 00:16:51,361 --> 00:16:51,860 All right. 410 00:16:51,860 --> 00:16:53,360 B comes first. 411 00:16:53,360 --> 00:16:55,630 H. F comes first. 412 00:16:55,630 --> 00:16:57,160 E. C. Nothing. 413 00:16:57,160 --> 00:16:57,660 Backtrack. 414 00:17:00,250 --> 00:17:01,222 We came that way. 415 00:17:01,222 --> 00:17:01,722 JIG. 416 00:17:04,450 --> 00:17:06,940 So that's the really fast way to do depth-first search. 417 00:17:06,940 --> 00:17:08,950 Don't do that, kids. 418 00:17:08,950 --> 00:17:11,880 We don't like-- well, maybe you can. 419 00:17:11,880 --> 00:17:13,380 If you get it right, we're not going 420 00:17:13,380 --> 00:17:16,349 to take off points usually. 421 00:17:16,349 --> 00:17:18,720 Generally, when we say draw the goal tree below, 422 00:17:18,720 --> 00:17:20,250 it's just assigned partial credit. 423 00:17:20,250 --> 00:17:22,990 However, we are pretty strict about that. 424 00:17:22,990 --> 00:17:26,660 If anything is wrong, except for maybe, like, OK, 425 00:17:26,660 --> 00:17:29,510 you write everything exactly right, and forget G at the end. 426 00:17:29,510 --> 00:17:31,760 If anything that's not completely understandable 427 00:17:31,760 --> 00:17:34,070 is wrong, you will probably lose all of the points, 428 00:17:34,070 --> 00:17:37,450 and it'll be a lot of points if you don't draw the goal tree. 429 00:17:37,450 --> 00:17:41,950 I will emphasize drawing the goal tree is a good idea. 430 00:17:41,950 --> 00:17:42,450 All right. 431 00:17:42,450 --> 00:17:46,130 So now let's do a breadth-first search. 432 00:17:46,130 --> 00:17:49,740 Before we do the breadth-first search on this tree, 433 00:17:49,740 --> 00:17:52,800 I will tell you guys that there is also a fast way 434 00:17:52,800 --> 00:17:56,550 to do the breadth-first search which is less risky, 435 00:17:56,550 --> 00:17:58,280 and it really depends on how nice they 436 00:17:58,280 --> 00:18:01,012 are about what they ask for. 437 00:18:01,012 --> 00:18:02,970 In this case, the breadth-first search question 438 00:18:02,970 --> 00:18:06,100 asks, what path does Mark find using breadth-first search? 439 00:18:06,100 --> 00:18:07,710 Rather than saying, what nodes does 440 00:18:07,710 --> 00:18:10,065 he expand in order, or anything like that. 441 00:18:10,065 --> 00:18:11,350 That is important. 442 00:18:11,350 --> 00:18:14,010 If that question is asked you, there 443 00:18:14,010 --> 00:18:17,354 is a trick that will let you solve it very, very quickly. 444 00:18:17,354 --> 00:18:19,020 In fact, faster than depth-first search. 445 00:18:19,020 --> 00:18:22,030 You can solve it by inspection in about 30 seconds. 446 00:18:22,030 --> 00:18:23,890 Does anyone know what the answer is? 447 00:18:23,890 --> 00:18:24,924 What path did he find? 448 00:18:24,924 --> 00:18:26,307 AUDIENCE: [CHATTER] 449 00:18:26,307 --> 00:18:27,390 PROFESSOR: That's correct. 450 00:18:27,390 --> 00:18:29,390 So the answer is? 451 00:18:29,390 --> 00:18:31,173 On this graph, the answer is? 452 00:18:31,173 --> 00:18:32,640 AUDIENCE: SBHIG. 453 00:18:32,640 --> 00:18:33,870 PROFESSOR: SBHIG. 454 00:18:33,870 --> 00:18:34,690 That's the answer. 455 00:18:34,690 --> 00:18:37,400 You would have your five points. 456 00:18:37,400 --> 00:18:38,660 Did people see that? 457 00:18:38,660 --> 00:18:41,305 It doesn't always work, so we're going to actually solve it. 458 00:18:41,305 --> 00:18:42,930 But did everyone see that sometimes you 459 00:18:42,930 --> 00:18:44,221 can get away with not doing it? 460 00:18:44,221 --> 00:18:46,320 Because breadth-first search is guaranteed 461 00:18:46,320 --> 00:18:50,040 to give you the path, as we heard correctly, with the least 462 00:18:50,040 --> 00:18:53,377 number of jumps, and if there are more than one that tie 463 00:18:53,377 --> 00:18:55,960 with the least number of jumps, you can just lexicographically 464 00:18:55,960 --> 00:18:59,470 figure it out, in this case with actual dictionary order. 465 00:18:59,470 --> 00:19:02,320 But SBHIG is the only one. 466 00:19:02,320 --> 00:19:04,500 Let's do an actual breadth-first search though, 467 00:19:04,500 --> 00:19:07,680 so we can feel better about ourselves. 468 00:19:07,680 --> 00:19:08,370 OK. 469 00:19:08,370 --> 00:19:15,430 So you've got S, and S goes to, as we saw before, ABC. 470 00:19:15,430 --> 00:19:20,040 Maybe that doesn't have to go quite so high. 471 00:19:20,040 --> 00:19:20,590 All right. 472 00:19:20,590 --> 00:19:23,440 As we saw before, S goes to ABC. 473 00:19:23,440 --> 00:19:25,910 And you already told me that A goes to D, 474 00:19:25,910 --> 00:19:30,820 and you told me that B goes to H. But what does C go to? 475 00:19:30,820 --> 00:19:32,830 E. That's right. 476 00:19:32,830 --> 00:19:34,260 As you can see, we're expanding it 477 00:19:34,260 --> 00:19:37,170 level by level, left to right. 478 00:19:37,170 --> 00:19:38,080 All right. 479 00:19:38,080 --> 00:19:45,260 So SAD, were does SAD go to? 480 00:19:45,260 --> 00:19:46,950 SAD goes to nowhere. 481 00:19:46,950 --> 00:19:48,300 It's dead. 482 00:19:48,300 --> 00:19:49,580 SBH. 483 00:19:49,580 --> 00:19:50,090 Now, wait. 484 00:19:50,090 --> 00:19:51,298 You might say, wait a minute. 485 00:19:51,298 --> 00:19:53,490 Patrick said that we're using this weird dictionary 486 00:19:53,490 --> 00:19:56,560 order where E is at the end that comes before H. That's 487 00:19:56,560 --> 00:19:58,281 our tiebreak order, but it turns out 488 00:19:58,281 --> 00:20:00,280 that breadth-first search and depth-first search 489 00:20:00,280 --> 00:20:03,677 don't sort in any way. 490 00:20:03,677 --> 00:20:04,510 It's very important. 491 00:20:04,510 --> 00:20:07,830 They don't sort the paths that are currently on the queue. 492 00:20:07,830 --> 00:20:12,490 So you're going to just go left to right, left to right, 493 00:20:12,490 --> 00:20:13,300 left to right. 494 00:20:13,300 --> 00:20:15,752 And only at each node are you going to break ties 495 00:20:15,752 --> 00:20:16,710 in lexicographic order. 496 00:20:16,710 --> 00:20:17,820 All right? 497 00:20:17,820 --> 00:20:19,080 So SBH. 498 00:20:19,080 --> 00:20:26,112 H goes to, as we already know, F and I. E, we 499 00:20:26,112 --> 00:20:27,570 think we already know, but we don't 500 00:20:27,570 --> 00:20:29,903 quite because this is E coming from the other direction. 501 00:20:29,903 --> 00:20:32,027 E, this time goes to F. That's right. 502 00:20:32,027 --> 00:20:33,860 Well, actually, you guys do already know it. 503 00:20:33,860 --> 00:20:34,170 All right. 504 00:20:34,170 --> 00:20:34,860 Great. 505 00:20:34,860 --> 00:20:36,430 Now we come over here. 506 00:20:36,430 --> 00:20:42,610 HF goes to, as we already know, E and J. 507 00:20:42,610 --> 00:20:50,865 I goes to, as we don't already know, HI goes to G and J. 508 00:20:50,865 --> 00:20:51,555 That's right. 509 00:20:56,100 --> 00:20:58,911 And as it turns out, by an implementation detail, 510 00:20:58,911 --> 00:20:59,410 we're done. 511 00:21:02,980 --> 00:21:03,570 Questions? 512 00:21:03,570 --> 00:21:04,710 Does it not expand depth at all? 513 00:21:04,710 --> 00:21:06,290 Now this is an implementation detail. 514 00:21:06,290 --> 00:21:09,620 It's perfectly sane and reasonable 515 00:21:09,620 --> 00:21:12,250 to make a breadth-first search that 516 00:21:12,250 --> 00:21:14,937 likes to finish its entire level that it's working on. 517 00:21:14,937 --> 00:21:16,520 However, in our implementation, and we 518 00:21:16,520 --> 00:21:18,769 would have seen this if we had been pedantic and drawn 519 00:21:18,769 --> 00:21:20,790 out the entire queue-- that's another reason why 520 00:21:20,790 --> 00:21:24,700 drawing out the entire queue is, as I said, more reliable. 521 00:21:24,700 --> 00:21:27,480 In our implementation, since it's not an optimal search, 522 00:21:27,480 --> 00:21:29,630 the moment anywhere on the queue, 523 00:21:29,630 --> 00:21:33,187 you add something with a G at the end, you finish. 524 00:21:33,187 --> 00:21:35,770 And because of the fact that the way breadth-first search does 525 00:21:35,770 --> 00:21:38,020 its mojo, is that it adds everything 526 00:21:38,020 --> 00:21:40,060 to the end of the queue. 527 00:21:40,060 --> 00:21:41,990 That's how it does it level by level, right? 528 00:21:41,990 --> 00:21:44,365 It adds it to the end of the queue, instead of the front. 529 00:21:44,365 --> 00:21:47,426 Well, then you'll add it to the end of the queue, 530 00:21:47,426 --> 00:21:49,425 and then you will have it on the queue with a G. 531 00:21:49,425 --> 00:21:51,150 So you won't have to do SCEF. 532 00:21:53,887 --> 00:21:54,595 Another question? 533 00:21:54,595 --> 00:21:57,101 AUDIENCE: I'm just wondering, so the breadth-first search, 534 00:21:57,101 --> 00:22:00,686 there was no backtracking [INAUDIBLE] had no other-- 535 00:22:00,686 --> 00:22:02,190 PROFESSOR: Ah. 536 00:22:02,190 --> 00:22:03,200 That's a good question. 537 00:22:03,200 --> 00:22:07,800 So the question was, so for the breadth-first search, 538 00:22:07,800 --> 00:22:09,370 there was no backtracking. 539 00:22:09,370 --> 00:22:09,960 D died. 540 00:22:09,960 --> 00:22:12,470 Why didn't we backtrack or something? 541 00:22:12,470 --> 00:22:15,640 The answer to that one is, for breadth-first search, 542 00:22:15,640 --> 00:22:19,410 backtracking doesn't really, it isn't really a thing, 543 00:22:19,410 --> 00:22:20,980 like it is for depth-first search. 544 00:22:20,980 --> 00:22:21,260 Why? 545 00:22:21,260 --> 00:22:22,740 Well, because breadth-first search, 546 00:22:22,740 --> 00:22:27,040 we're sending our infinite monkeys down every path. 547 00:22:27,040 --> 00:22:29,396 In depth-first search, we're really focused in now. 548 00:22:29,396 --> 00:22:30,770 We're like, we want to get there. 549 00:22:30,770 --> 00:22:31,220 We want to get there. 550 00:22:31,220 --> 00:22:32,910 Ooh, this way, this way, this way, this way. 551 00:22:32,910 --> 00:22:34,326 And might have gone the wrong way, 552 00:22:34,326 --> 00:22:36,410 and then we hit a dead end, we're like, oh, crap. 553 00:22:36,410 --> 00:22:37,580 And we go backwards. 554 00:22:37,580 --> 00:22:39,950 But for breadth-first search, we really 555 00:22:39,950 --> 00:22:41,100 are like an evil overlord. 556 00:22:41,100 --> 00:22:44,150 And we're like Mark Vader saying, storm troopers, 557 00:22:44,150 --> 00:22:45,600 go every direction. 558 00:22:45,600 --> 00:22:48,320 And then from there, go every other direction. 559 00:22:48,320 --> 00:22:50,920 And so, even though, yes, when we got to D, some of the storm 560 00:22:50,920 --> 00:22:53,319 troopers hit a dead end, and probably it was reflective, 561 00:22:53,319 --> 00:22:55,360 and they shot it, and hit themselves or something 562 00:22:55,360 --> 00:22:56,530 like that. 563 00:22:56,530 --> 00:22:58,280 Meanwhile, the storm troopers we sent to B 564 00:22:58,280 --> 00:23:00,185 and C are still fine, so we don't need to backtrack. 565 00:23:00,185 --> 00:23:01,630 AUDIENCE: Cause there are, like, other troops going down 566 00:23:01,630 --> 00:23:02,340 the tree. 567 00:23:02,340 --> 00:23:03,490 PROFESSOR: Yeah, there are other troops going down 568 00:23:03,490 --> 00:23:04,670 the tree in every direction. 569 00:23:04,670 --> 00:23:06,086 Whereas in the depth-first search, 570 00:23:06,086 --> 00:23:08,250 we only sent-- we were like, there are definitely 571 00:23:08,250 --> 00:23:09,902 no droids on this escape pod. 572 00:23:09,902 --> 00:23:11,485 Send everyone this straight direction, 573 00:23:11,485 --> 00:23:13,510 and we only sent them to A and D. 574 00:23:13,510 --> 00:23:16,310 And then, so we had to backtrack because we hit a dead end. 575 00:23:16,310 --> 00:23:17,560 Does that make sense? 576 00:23:17,560 --> 00:23:18,864 Another question? 577 00:23:18,864 --> 00:23:19,739 AUDIENCE: [INAUDIBLE] 578 00:23:22,640 --> 00:23:25,540 PROFESSOR: So the question is, in this breadth-first search, 579 00:23:25,540 --> 00:23:27,570 did lexicographic order ever come into play? 580 00:23:27,570 --> 00:23:31,360 The answer is yes, in a very subtle and sneaky way. 581 00:23:31,360 --> 00:23:35,520 Which is, I wrote E before J, F before I, and G 582 00:23:35,520 --> 00:23:39,290 before J. If I was not using lexicographic order, 583 00:23:39,290 --> 00:23:40,969 it might have been reasonable to write, 584 00:23:40,969 --> 00:23:42,510 for instance, when I was expanding I, 585 00:23:42,510 --> 00:23:45,570 to write J before G because J was higher up on the tree 586 00:23:45,570 --> 00:23:46,850 or something like that. 587 00:23:46,850 --> 00:23:48,640 But the only way it came into play 588 00:23:48,640 --> 00:23:51,280 is that I wrote them left to right in alphabetical order 589 00:23:51,280 --> 00:23:54,890 every time, and I wrote ABC. 590 00:23:54,890 --> 00:23:56,023 Another question? 591 00:23:56,023 --> 00:23:57,472 AUDIENCE: We see the F node twice. 592 00:23:57,472 --> 00:23:59,722 Suppose that the goal node wasn't reached [INAUDIBLE], 593 00:23:59,722 --> 00:24:01,356 then you would have visited F again. 594 00:24:01,356 --> 00:24:03,230 PROFESSOR: And we would have visited F again. 595 00:24:03,230 --> 00:24:03,855 That's correct. 596 00:24:03,855 --> 00:24:06,760 The question is, F is listed twice. 597 00:24:06,760 --> 00:24:08,500 So if we hadn't reached the goal node, 598 00:24:08,500 --> 00:24:11,990 let's say that down there, after I is Z, 599 00:24:11,990 --> 00:24:13,740 and after Z is the goal node, then 600 00:24:13,740 --> 00:24:14,990 would we have visited F again? 601 00:24:14,990 --> 00:24:15,880 The answer is yes. 602 00:24:15,880 --> 00:24:17,920 As I said, this is the approach that throws 603 00:24:17,920 --> 00:24:19,490 your troops every possible way. 604 00:24:19,490 --> 00:24:21,005 So there's storm troopers going from E to F, 605 00:24:21,005 --> 00:24:22,550 and there's storm troopers going from H to F, 606 00:24:22,550 --> 00:24:23,900 and they're going everywhere. 607 00:24:23,900 --> 00:24:26,100 Now there is a way to cut down on this. 608 00:24:26,100 --> 00:24:29,040 You could do breadth-first search with an extended list. 609 00:24:29,040 --> 00:24:30,970 If you did do breadth-first search 610 00:24:30,970 --> 00:24:32,980 with an extended list, that would 611 00:24:32,980 --> 00:24:36,520 be sort of equivalent to as soon as you expand one node, 612 00:24:36,520 --> 00:24:40,020 as soon you send storm troopers out of I to look at G and J, 613 00:24:40,020 --> 00:24:42,520 one of them stays at I, and if any other storm troopers come 614 00:24:42,520 --> 00:24:44,874 to I, and they're like, we want to see what's past I, 615 00:24:44,874 --> 00:24:45,790 he's like, no, no, no. 616 00:24:45,790 --> 00:24:48,260 We've already sent troops past I. We've got this. 617 00:24:48,260 --> 00:24:50,370 Go back home. 618 00:24:50,370 --> 00:24:50,900 It's OK. 619 00:24:50,900 --> 00:24:52,700 There are no rebels here, but it might 620 00:24:52,700 --> 00:24:54,480 be Han Solo dressed up as a storm trooper, 621 00:24:54,480 --> 00:24:56,570 as we'll see in the next problem. 622 00:24:56,570 --> 00:24:59,530 Where our extended list screws us over. 623 00:24:59,530 --> 00:25:02,440 But for this problem, do you see what I mean? 624 00:25:02,440 --> 00:25:04,200 With an extended list, we could avoid this 625 00:25:04,200 --> 00:25:05,880 because the extended list basically 626 00:25:05,880 --> 00:25:08,260 says, once I've expanded and searched past here, 627 00:25:08,260 --> 00:25:09,590 don't do it again. 628 00:25:09,590 --> 00:25:12,300 But if you don't have one, yeah, you'll do F twice. 629 00:25:12,300 --> 00:25:15,572 In fact, didn't we do something twice here? 630 00:25:15,572 --> 00:25:16,850 Oh, it turns out we didn't. 631 00:25:16,850 --> 00:25:18,480 But we easily could have. 632 00:25:18,480 --> 00:25:19,620 We almost did E twice. 633 00:25:19,620 --> 00:25:22,710 We almost did F twice. 634 00:25:22,710 --> 00:25:24,980 It turns out we didn't, but we could have. 635 00:25:24,980 --> 00:25:26,177 Another question? 636 00:25:26,177 --> 00:25:29,159 AUDIENCE: [INAUDIBLE] for the implementation of the queue 637 00:25:29,159 --> 00:25:33,632 that when you expand I, that both G and J 638 00:25:33,632 --> 00:25:39,596 were added simultaneously and in lexicographic order? 639 00:25:39,596 --> 00:25:43,572 Or is there a piece where it would be [INAUDIBLE] order, 640 00:25:43,572 --> 00:25:46,965 G got added before J, so hence, it stopped [INAUDIBLE]? 641 00:25:46,965 --> 00:25:47,548 PROFESSOR: Ha. 642 00:25:47,548 --> 00:25:50,670 That is a very good question that provokes a minor change. 643 00:25:50,670 --> 00:25:55,620 The question is, when you expand SBHI, 644 00:25:55,620 --> 00:25:58,427 is SBHIG added before SBHIJ because 645 00:25:58,427 --> 00:26:00,010 of lexicographic ordering, or are they 646 00:26:00,010 --> 00:26:01,650 both added at the same time? 647 00:26:01,650 --> 00:26:03,480 The answer is, simultaneous. 648 00:26:03,480 --> 00:26:05,530 When you do the expansion, you instantly 649 00:26:05,530 --> 00:26:09,110 receive say, a list maybe, or whatever data structure you 650 00:26:09,110 --> 00:26:11,660 like, containing all of the children, 651 00:26:11,660 --> 00:26:16,440 and they get appended to the queue at once in order. 652 00:26:16,440 --> 00:26:19,080 So you will receive all of them. 653 00:26:19,080 --> 00:26:21,330 I suppose you could create some kind of search problem 654 00:26:21,330 --> 00:26:24,065 where you have, like, an adversary node, like a wumpus, 655 00:26:24,065 --> 00:26:25,190 or you're hunting a wumpus. 656 00:26:25,190 --> 00:26:28,085 And if you don't want to add the exact wumpus to your search 657 00:26:28,085 --> 00:26:29,010 tree, or you lose. 658 00:26:29,010 --> 00:26:31,999 You only want to add the one next to the wumpus. 659 00:26:31,999 --> 00:26:32,540 I don't know. 660 00:26:32,540 --> 00:26:33,630 I'm making this up. 661 00:26:33,630 --> 00:26:35,890 And unfortunately, you would have 662 00:26:35,890 --> 00:26:37,630 to add all the children at once. 663 00:26:37,630 --> 00:26:42,200 Our current algorithm does not add one at a time. 664 00:26:42,200 --> 00:26:42,700 All right. 665 00:26:42,700 --> 00:26:44,420 So we've done a breadth-first search. 666 00:26:44,420 --> 00:26:44,940 Great. 667 00:26:44,940 --> 00:26:47,530 Now we're going to do some optimal search. 668 00:26:47,530 --> 00:26:49,790 That is going to require me to draw 669 00:26:49,790 --> 00:26:52,510 a slightly different graph. 670 00:26:52,510 --> 00:26:57,050 I will draw it on what is left of the bottom here. 671 00:26:57,050 --> 00:27:01,620 And then we'll solve it on what is left of the bottom here. 672 00:27:01,620 --> 00:27:02,120 All right. 673 00:27:02,120 --> 00:27:03,910 Mark has his new stronghold, and he wants 674 00:27:03,910 --> 00:27:07,070 to invade parallel universes. 675 00:27:07,070 --> 00:27:10,450 Now he's programmed his evil supercomputer 676 00:27:10,450 --> 00:27:11,960 to find the shortest path of jumps 677 00:27:11,960 --> 00:27:14,085 from his starting universe to the goal universe, 678 00:27:14,085 --> 00:27:18,920 G. It takes a certain amount of energy 679 00:27:18,920 --> 00:27:20,410 to move from universe to universe 680 00:27:20,410 --> 00:27:23,250 based on the differing factors between those universes. 681 00:27:23,250 --> 00:27:26,290 Like maybe in one universe, a butterfly 682 00:27:26,290 --> 00:27:31,370 didn't flap its wings in China, whereas in the other universe, 683 00:27:31,370 --> 00:27:34,480 sentient reptiles rule the earth. 684 00:27:34,480 --> 00:27:37,170 And so, Mark's supercomputer has tried 685 00:27:37,170 --> 00:27:39,890 to create a heuristic value that determines 686 00:27:39,890 --> 00:27:42,970 how different the universes are to guess, sort of, how 687 00:27:42,970 --> 00:27:45,520 much energy it's going to take to get from his start 688 00:27:45,520 --> 00:27:48,550 universe, S, to his goal universe, G, 689 00:27:48,550 --> 00:27:53,080 given that currently his armies are at a particular universe. 690 00:27:53,080 --> 00:27:56,870 In other words, OK, it's not A you put in search, 691 00:27:56,870 --> 00:27:59,520 but dammit, we're going to have a heuristic 692 00:27:59,520 --> 00:28:00,590 distance to the goal. 693 00:28:00,590 --> 00:28:02,710 And we're going to have a graph with distances. 694 00:28:02,710 --> 00:28:06,660 So let's see what it looks like. 695 00:28:06,660 --> 00:28:07,310 All right. 696 00:28:33,320 --> 00:28:37,960 And down here is G. So this otherwise unassuming heart 697 00:28:37,960 --> 00:28:40,800 shape hides an evil invasion force. 698 00:28:40,800 --> 00:28:43,640 So let's see. 699 00:28:43,640 --> 00:28:45,146 The distance here is 100. 700 00:28:45,146 --> 00:28:48,275 The distance here is 3, 4. 701 00:28:48,275 --> 00:28:50,600 The distance here is 4. 702 00:28:50,600 --> 00:29:00,890 The distance here is 50, 50, 14, 4, 16, 16. 703 00:29:00,890 --> 00:29:03,430 Oh sorry, these are connected. 704 00:29:03,430 --> 00:29:07,410 30 and 10. 705 00:29:07,410 --> 00:29:15,680 The heuristic values are 0 at the start node, 50 at B, 706 00:29:15,680 --> 00:29:38,290 60 at A, 55 at C, 50 at D, 56 at E, 50 at F, 707 00:29:38,290 --> 00:29:43,760 0 at G because it's the goal node, 39 at H. 708 00:29:43,760 --> 00:29:45,145 I'll draw the little H smaller. 709 00:29:49,500 --> 00:29:55,030 And 0 at I. Well, after all, I goes right to G. It can be 0. 710 00:29:55,030 --> 00:29:55,936 It'll be great. 711 00:29:55,936 --> 00:29:56,436 OK. 712 00:29:58,940 --> 00:30:02,020 Now, this time Mark is trying to conserve the energy 713 00:30:02,020 --> 00:30:03,700 of his parallel universe jump. 714 00:30:03,700 --> 00:30:06,150 That, understandably, takes a lot of energy. 715 00:30:06,150 --> 00:30:09,180 So he needs to program in the shortest 716 00:30:09,180 --> 00:30:13,431 number of universe jumps that will get him to the goal. 717 00:30:13,431 --> 00:30:15,180 He doesn't mean the least number of jumps. 718 00:30:15,180 --> 00:30:17,305 He means the least amount of energy on these edges. 719 00:30:17,305 --> 00:30:19,926 He's not interested in getting to this new world, 720 00:30:19,926 --> 00:30:21,300 and not having enough energy left 721 00:30:21,300 --> 00:30:23,000 to blast the crap out of it. 722 00:30:23,000 --> 00:30:26,140 So we need to find the shortest path. 723 00:30:26,140 --> 00:30:29,680 So first Mark programs a simple branch and bound search. 724 00:30:29,680 --> 00:30:32,040 He adds in an extended list to his branch 725 00:30:32,040 --> 00:30:34,630 and bound just to make it a little bit faster. 726 00:30:34,630 --> 00:30:36,600 As usual, he breaks ties of equal length 727 00:30:36,600 --> 00:30:38,470 in lexicographic order. 728 00:30:38,470 --> 00:30:42,450 So let's list the nodes that Mark's computer adds 729 00:30:42,450 --> 00:30:45,467 to the extended list in order. 730 00:30:45,467 --> 00:30:47,050 Distances are shown next to the edges. 731 00:30:47,050 --> 00:30:49,530 Ignore the number in parentheses for now. 732 00:30:49,530 --> 00:30:52,180 They are heuristics, and we're not using them. 733 00:30:52,180 --> 00:30:53,740 So that brings me to another point 734 00:30:53,740 --> 00:30:55,720 that I'd like to drive home before we 735 00:30:55,720 --> 00:30:59,320 go for the home stretch and solve these problems. 736 00:30:59,320 --> 00:31:01,740 What the heck is the difference between branch and bound 737 00:31:01,740 --> 00:31:03,290 and A*? 738 00:31:03,290 --> 00:31:04,130 OK. 739 00:31:04,130 --> 00:31:05,740 I like to liken it to the following. 740 00:31:05,740 --> 00:31:08,880 I probably should have, I'll make this a silver star idea. 741 00:31:15,580 --> 00:31:16,130 OK. 742 00:31:16,130 --> 00:31:18,194 The silver star idea is pizza. 743 00:31:18,194 --> 00:31:19,610 It doesn't really look like pizza, 744 00:31:19,610 --> 00:31:20,943 but that's the silver star idea. 745 00:31:20,943 --> 00:31:23,230 Branch and bound is a cheese pizza. 746 00:31:23,230 --> 00:31:24,210 It's simple. 747 00:31:24,210 --> 00:31:25,600 If you order it for a large group 748 00:31:25,600 --> 00:31:27,433 event of college students, they will eat it, 749 00:31:27,433 --> 00:31:30,650 and things will be OK. 750 00:31:30,650 --> 00:31:34,330 Now A* search is some kind of meat lover's or supreme pizza. 751 00:31:34,330 --> 00:31:35,530 Maybe a meat lover's pizza. 752 00:31:35,530 --> 00:31:36,960 It's got all these extra toppings. 753 00:31:36,960 --> 00:31:38,793 A lot of people are really going to like it. 754 00:31:38,793 --> 00:31:39,650 It might be better. 755 00:31:39,650 --> 00:31:41,025 But then you've got a vegetarian, 756 00:31:41,025 --> 00:31:43,840 and everything's screwed up. 757 00:31:43,840 --> 00:31:49,130 So basically, A* is just branch and bound with some extra 758 00:31:49,130 --> 00:31:49,990 toppings added on. 759 00:31:49,990 --> 00:31:54,970 In this case, one of the toppings is an extended list, 760 00:31:54,970 --> 00:31:57,320 an extended list which we'll see keeps 761 00:31:57,320 --> 00:32:00,920 track of where we've passed through and already expanded 762 00:32:00,920 --> 00:32:03,140 out, and it never goes back. 763 00:32:03,140 --> 00:32:06,980 The other topping that we're going to add is a heuristic. 764 00:32:06,980 --> 00:32:09,090 A heuristic tells us about how far 765 00:32:09,090 --> 00:32:11,210 we think we have left until we're at the end, 766 00:32:11,210 --> 00:32:13,830 so we don't go through really short paths that go completely 767 00:32:13,830 --> 00:32:15,330 in the wrong direction. 768 00:32:15,330 --> 00:32:16,480 All right? 769 00:32:16,480 --> 00:32:19,700 Between the two of those, we get our supreme pizza, 770 00:32:19,700 --> 00:32:22,410 but sometimes, as we'll see, they sort of 771 00:32:22,410 --> 00:32:24,280 mess each other up. 772 00:32:24,280 --> 00:32:26,270 So one of the toppings just doesn't go well 773 00:32:26,270 --> 00:32:27,061 with the other one. 774 00:32:27,061 --> 00:32:28,660 Maybe someone doesn't Hawaiian. 775 00:32:28,660 --> 00:32:31,865 They think that the ham doesn't go well with the pineapple. 776 00:32:35,640 --> 00:32:40,290 So let's do a branch and bound that just has an extended list. 777 00:32:40,290 --> 00:32:42,489 Maybe we've got some green peppers on this pizza. 778 00:32:42,489 --> 00:32:43,530 This is going to be safe. 779 00:32:46,220 --> 00:32:47,020 All right. 780 00:32:47,020 --> 00:32:49,480 So we're going to list the nodes as to the extended list, 781 00:32:49,480 --> 00:32:51,580 and the way we're going to do that is, well, 782 00:32:51,580 --> 00:32:53,690 you guys said you like goal tree more than queue, 783 00:32:53,690 --> 00:32:55,770 so let's do it with a goal tree. 784 00:32:55,770 --> 00:33:03,620 So we've got S, and as we already know, 785 00:33:03,620 --> 00:33:06,170 S is the only path. 786 00:33:06,170 --> 00:33:08,460 Our current length at S is 0. 787 00:33:08,460 --> 00:33:11,020 That's the lowest of all of our lengths on the tree cause 788 00:33:11,020 --> 00:33:12,650 it's the only length. 789 00:33:12,650 --> 00:33:21,110 So we go to A, B, and C. It may be hard to see, 790 00:33:21,110 --> 00:33:26,260 so the length of SA is 100. 791 00:33:26,260 --> 00:33:28,250 The length of SB is-- 792 00:33:28,250 --> 00:33:29,935 AUDIENCE: You mean ABEF? 793 00:33:29,935 --> 00:33:32,300 AUDIENCE: Yeah. 794 00:33:32,300 --> 00:33:33,253 [CHATTER] 795 00:33:33,253 --> 00:33:33,836 PROFESSOR: Oh. 796 00:33:33,836 --> 00:33:34,190 You're right. 797 00:33:34,190 --> 00:33:35,106 It's a different tree. 798 00:33:35,106 --> 00:33:37,060 I was doing A, B, and C from the other tree. 799 00:33:37,060 --> 00:33:39,870 Thank you, friends, for correcting my foolishness. 800 00:33:43,480 --> 00:33:45,330 The length of SB is 3. 801 00:33:45,330 --> 00:33:46,690 It is a different tree. 802 00:33:46,690 --> 00:33:49,480 I was trying to save work that wound up 803 00:33:49,480 --> 00:33:52,920 creating more because someone's going to be confused by this. 804 00:33:52,920 --> 00:33:57,680 So the length of A, B, E, and F are 100, 3, 14, and 14. 805 00:33:57,680 --> 00:33:58,820 Which one do we choose? 806 00:33:58,820 --> 00:34:01,360 Lexicographically, it's A. We choose that one, right? 807 00:34:01,360 --> 00:34:02,760 AUDIENCE: [CHATTER] 808 00:34:02,760 --> 00:34:04,530 PROFESSOR: F is going to be 14. 809 00:34:04,530 --> 00:34:05,030 That' a 1. 810 00:34:05,030 --> 00:34:05,529 Sorry. 811 00:34:05,529 --> 00:34:07,150 AUDIENCE: 4. 812 00:34:07,150 --> 00:34:07,980 4. 813 00:34:07,980 --> 00:34:08,896 PROFESSOR: Oh, it's 4? 814 00:34:10,985 --> 00:34:11,860 I wrote this problem. 815 00:34:11,860 --> 00:34:12,420 I should know it. 816 00:34:12,420 --> 00:34:12,961 You're right. 817 00:34:12,961 --> 00:34:14,120 F is 4. 818 00:34:14,120 --> 00:34:15,775 My apologies once more. 819 00:34:15,775 --> 00:34:16,561 That's what I get. 820 00:34:16,561 --> 00:34:17,060 All right. 821 00:34:17,060 --> 00:34:18,601 I'm going to stand over here from now 822 00:34:18,601 --> 00:34:22,050 on when I write over there. 823 00:34:22,050 --> 00:34:22,840 OK. 824 00:34:22,840 --> 00:34:25,060 So which one of these are we going to choose? 825 00:34:25,060 --> 00:34:28,730 Even with the 4, we're going to choose B. That's right. 826 00:34:28,730 --> 00:34:29,889 Lexicographic be damned. 827 00:34:29,889 --> 00:34:31,120 It's only for tiebreaks. 828 00:34:31,120 --> 00:34:32,916 We want the shortest path. 829 00:34:32,916 --> 00:34:34,540 Our special thing with branch and bound 830 00:34:34,540 --> 00:34:37,420 is we take the currently shortest path, whatever it is. 831 00:34:37,420 --> 00:34:38,659 Great. 832 00:34:38,659 --> 00:34:40,739 So we expand B. Fortunately, and I'm 833 00:34:40,739 --> 00:34:43,630 pretty sure I've got this correct this time-- oh wait, 834 00:34:43,630 --> 00:34:45,560 I've got an even better idea. 835 00:34:45,560 --> 00:34:47,480 I'll just take this little hand sheet with me, 836 00:34:47,480 --> 00:34:49,530 and then I don't have to look at that at all. 837 00:34:49,530 --> 00:34:50,030 OK. 838 00:34:50,030 --> 00:34:55,550 So once we expand B, B goes to D. Our path length from B to D 839 00:34:55,550 --> 00:34:59,000 is 4, so what will we write next to little G here? 840 00:34:59,000 --> 00:34:59,630 7. 841 00:34:59,630 --> 00:34:59,920 That's right. 842 00:34:59,920 --> 00:35:00,961 We add them all together. 843 00:35:03,270 --> 00:35:05,696 I'm going to ask you guys again the next time we 844 00:35:05,696 --> 00:35:07,112 do this with the heuristics, which 845 00:35:07,112 --> 00:35:08,360 is going to be the next part of the problem, 846 00:35:08,360 --> 00:35:10,780 and someone's going to give me the wrong answer next time. 847 00:35:10,780 --> 00:35:12,281 So stay tuned for that. 848 00:35:12,281 --> 00:35:12,780 All right. 849 00:35:12,780 --> 00:35:13,702 So we've got SBD. 850 00:35:13,702 --> 00:35:14,660 We've got all of these. 851 00:35:14,660 --> 00:35:16,000 Where do we go next? 852 00:35:16,000 --> 00:35:18,520 F. That's right, because currently 4 853 00:35:18,520 --> 00:35:21,570 is the shortest because you guys corrected me correctly. 854 00:35:21,570 --> 00:35:22,650 So SF. 855 00:35:22,650 --> 00:35:23,940 4 is the shortest. 856 00:35:23,940 --> 00:35:28,104 F only goes to H. And what do we write next to the H? 857 00:35:28,104 --> 00:35:29,030 20. 858 00:35:29,030 --> 00:35:30,980 That's right. 859 00:35:30,980 --> 00:35:32,440 16 plus 4, 20. 860 00:35:32,440 --> 00:35:32,940 All right. 861 00:35:32,940 --> 00:35:35,130 Where's our current shortest? 862 00:35:35,130 --> 00:35:36,870 It's the D, SBD. 863 00:35:36,870 --> 00:35:37,400 All right? 864 00:35:37,400 --> 00:35:38,265 So SBD. 865 00:35:38,265 --> 00:35:41,790 D only goes to I, and we've got a 57. 866 00:35:49,847 --> 00:35:50,430 Wait a minute. 867 00:35:50,430 --> 00:35:53,020 I want to get this problem right, so we better 868 00:35:53,020 --> 00:35:54,650 actually write the extended list, 869 00:35:54,650 --> 00:35:56,460 [INAUDIBLE] because that's the only thing they're asking us 870 00:35:56,460 --> 00:35:57,120 for. 871 00:35:57,120 --> 00:36:01,650 So first we extended S. Then we extended B. Then we 872 00:36:01,650 --> 00:36:08,050 extended F. Then we extended D. All right. 873 00:36:08,050 --> 00:36:09,190 So far, so good. 874 00:36:09,190 --> 00:36:11,840 And I have the answer key, so I know we're doing it right. 875 00:36:11,840 --> 00:36:12,520 OK. 876 00:36:12,520 --> 00:36:14,340 What are we doing next? 877 00:36:14,340 --> 00:36:15,890 E. That's right. 878 00:36:15,890 --> 00:36:22,070 So we extend E. E goes to H. And when E goes to H, 879 00:36:22,070 --> 00:36:25,010 we've got a length of 30. 880 00:36:25,010 --> 00:36:25,650 All right. 881 00:36:25,650 --> 00:36:27,590 Who's our winner now? 882 00:36:27,590 --> 00:36:29,210 Which H? 883 00:36:29,210 --> 00:36:29,949 SFH. 884 00:36:29,949 --> 00:36:30,490 That's right. 885 00:36:30,490 --> 00:36:32,392 SFH is length 20. 886 00:36:32,392 --> 00:36:34,350 Oh yeah, of course I should write an E in here. 887 00:36:34,350 --> 00:36:35,920 I always forget to do that. 888 00:36:35,920 --> 00:36:39,070 SFH is length 20, so we will extend H, 889 00:36:39,070 --> 00:36:41,680 and I'm going to write it here preemptively. 890 00:36:41,680 --> 00:36:47,050 When we extend H over here, H only goes to I, with length 50. 891 00:36:47,050 --> 00:36:47,780 Great. 892 00:36:47,780 --> 00:36:51,170 What's the next shortest? 893 00:36:51,170 --> 00:36:55,242 The next shortest is the other H. However, will we expand it? 894 00:36:55,242 --> 00:36:57,700 You guessed that because I asked that question in that way. 895 00:36:57,700 --> 00:36:58,900 You knew the answer was no. 896 00:36:58,900 --> 00:37:01,510 Why don't we expand it? 897 00:37:01,510 --> 00:37:03,140 It's already on the extended list. 898 00:37:03,140 --> 00:37:03,920 That's right. 899 00:37:03,920 --> 00:37:06,850 So since it's already on the extended list, 900 00:37:06,850 --> 00:37:09,360 this one dies a horrible death. 901 00:37:09,360 --> 00:37:11,920 I like writing an X through it instead of writing a swizzle 902 00:37:11,920 --> 00:37:13,370 at the bottom. 903 00:37:13,370 --> 00:37:15,090 You can do whatever you want. 904 00:37:15,090 --> 00:37:16,350 All right, it's gone. 905 00:37:16,350 --> 00:37:17,120 It's not a choice. 906 00:37:17,120 --> 00:37:20,260 What's the next best one? 907 00:37:20,260 --> 00:37:21,510 SFHI. 908 00:37:21,510 --> 00:37:22,370 That's right. 909 00:37:22,370 --> 00:37:25,770 That goes to G, and the length is 60. 910 00:37:25,770 --> 00:37:31,100 And we've extended I. All right. 911 00:37:31,100 --> 00:37:32,535 Question is, are we done? 912 00:37:35,650 --> 00:37:38,210 The people who say no, I like you. 913 00:37:38,210 --> 00:37:38,852 You're smart. 914 00:37:38,852 --> 00:37:40,310 You realize that just because the G 915 00:37:40,310 --> 00:37:42,850 is on there, that we can't end. 916 00:37:42,850 --> 00:37:46,320 However, the people who said yes, you are either 917 00:37:46,320 --> 00:37:47,864 oblivious or really, really smart, 918 00:37:47,864 --> 00:37:49,530 and I'm going to choose to assume you're 919 00:37:49,530 --> 00:37:52,520 all really, really smart because the really, really smart people 920 00:37:52,520 --> 00:37:53,300 said, OK. 921 00:37:53,300 --> 00:37:55,050 Yes, we're not quite done just because we 922 00:37:55,050 --> 00:37:56,320 added a G. We still have to check 923 00:37:56,320 --> 00:37:57,840 to make sure there are no lengths with shorter path, 924 00:37:57,840 --> 00:37:58,660 but look. 925 00:37:58,660 --> 00:38:01,420 The only one with a shorter path is 926 00:38:01,420 --> 00:38:04,340 I, which is already on the extended list. 927 00:38:04,340 --> 00:38:05,930 So actually, we are done. 928 00:38:05,930 --> 00:38:07,120 Double check. 929 00:38:07,120 --> 00:38:07,940 We've got it. 930 00:38:07,940 --> 00:38:09,970 So these are the paths we extended in order, 931 00:38:09,970 --> 00:38:11,640 and our final path is? 932 00:38:11,640 --> 00:38:12,625 Everyone. 933 00:38:12,625 --> 00:38:15,050 AUDIENCE: [CHATTER] 934 00:38:15,050 --> 00:38:16,620 PROFESSOR: That's right. 935 00:38:16,620 --> 00:38:18,770 SFHIG. 936 00:38:18,770 --> 00:38:21,180 I claim that is the correct path. 937 00:38:21,180 --> 00:38:23,740 However, Mark is frustrated by branch and bound's speed. 938 00:38:23,740 --> 00:38:24,550 I don't know. 939 00:38:24,550 --> 00:38:25,670 I wasn't that frustrated. 940 00:38:25,670 --> 00:38:26,610 Seemed pretty good. 941 00:38:26,610 --> 00:38:29,330 But Mark is frustrated by branch and bound's speed, 942 00:38:29,330 --> 00:38:32,980 so he reprograms his computer to use A*. 943 00:38:32,980 --> 00:38:35,510 Mark counts the number of subspace anomalies between each 944 00:38:35,510 --> 00:38:38,110 universe and the goal, and uses this count as the heuristic 945 00:38:38,110 --> 00:38:38,686 for A*. 946 00:38:38,686 --> 00:38:40,060 These numbers are in parentheses. 947 00:38:40,060 --> 00:38:42,410 Hopefully, you can read them. 948 00:38:42,410 --> 00:38:42,910 Yes? 949 00:38:42,910 --> 00:38:44,820 Oh, we've got a question. 950 00:38:44,820 --> 00:38:45,600 Right here? 951 00:38:45,600 --> 00:38:47,584 AUDIENCE: So, given the implementation, 952 00:38:47,584 --> 00:38:49,568 you said that you expand all possible nodes. 953 00:38:49,568 --> 00:38:52,544 So why doesn't I go to C and D, as well as [INAUDIBLE]? 954 00:38:52,544 --> 00:38:55,040 Like, why doesn't it expand to [INAUDIBLE]? 955 00:38:55,040 --> 00:38:55,750 PROFESSOR: Ah. 956 00:38:55,750 --> 00:38:57,330 That is a very good question. 957 00:38:57,330 --> 00:39:01,000 And the answer is, a very simple answer. 958 00:39:01,000 --> 00:39:02,070 You guys tricked me. 959 00:39:02,070 --> 00:39:04,111 No, but I should have been able to figure it out. 960 00:39:04,111 --> 00:39:08,145 It does go to C and D. The correct tree, which we wouldn't 961 00:39:08,145 --> 00:39:10,270 have lost points for having the incorrect tree here 962 00:39:10,270 --> 00:39:13,000 cause we did get the correct answer, yes. 963 00:39:13,000 --> 00:39:15,622 The reason why it is, that same reason that very first time I 964 00:39:15,622 --> 00:39:17,705 asked someone something, he didn't remember the C. 965 00:39:17,705 --> 00:39:20,860 It's easy to forget to go up the tree. 966 00:39:20,860 --> 00:39:22,890 It does actually have a C and D. However, 967 00:39:22,890 --> 00:39:24,830 they are horrendous paths. 968 00:39:24,830 --> 00:39:29,939 They are 100 and 100 on their path length, 969 00:39:29,939 --> 00:39:30,980 and so it doesn't matter. 970 00:39:30,980 --> 00:39:32,280 But you were correct. 971 00:39:32,280 --> 00:39:34,239 The official answer we had up there is wrong. 972 00:39:34,239 --> 00:39:37,981 AUDIENCE: Would the D get added to this list of children that's 973 00:39:37,981 --> 00:39:39,460 already in the extended list? 974 00:39:39,460 --> 00:39:40,750 PROFESSOR: Good question. 975 00:39:40,750 --> 00:39:44,040 The question is, would the D get added to the children? 976 00:39:44,040 --> 00:39:46,000 After all, it's already in the extended list. 977 00:39:46,000 --> 00:39:50,400 The answer is, we search for, and remove, and kill 978 00:39:50,400 --> 00:39:53,130 all of the attempts to extend something that's 979 00:39:53,130 --> 00:39:56,400 already on the expanded list at the time we try to expand it. 980 00:39:56,400 --> 00:39:58,052 The time we try to expand it is only 981 00:39:58,052 --> 00:39:59,510 when it's on the front of the queue 982 00:39:59,510 --> 00:40:01,890 because it's the currently shortest path. 983 00:40:01,890 --> 00:40:03,692 So that means they get added. 984 00:40:03,692 --> 00:40:05,650 It's just that when it comes time to expand it, 985 00:40:05,650 --> 00:40:07,745 it will get crossed off no matter what. 986 00:40:07,745 --> 00:40:10,292 Turns out, it escaped execution because of the fact 987 00:40:10,292 --> 00:40:11,440 that we never expanded it. 988 00:40:11,440 --> 00:40:13,920 AUDIENCE: So H should go to E as well? 989 00:40:13,920 --> 00:40:16,350 PROFESSOR: So H should go to E as well, is the question. 990 00:40:16,350 --> 00:40:17,520 The answer is yes. 991 00:40:17,520 --> 00:40:20,140 H should go to E as well. 992 00:40:20,140 --> 00:40:21,710 A lot slipped past me this time. 993 00:40:21,710 --> 00:40:25,750 H should go to E as well, with a length of 36, 994 00:40:25,750 --> 00:40:26,910 and it dies there. 995 00:40:30,340 --> 00:40:31,817 This one will actually be checked, 996 00:40:31,817 --> 00:40:33,400 so it actually does make a difference. 997 00:40:33,400 --> 00:40:39,070 If we ask how many times was a node executed due to already 998 00:40:39,070 --> 00:40:41,060 being on the extended list? 999 00:40:41,060 --> 00:40:41,910 Very good. 1000 00:40:41,910 --> 00:40:42,930 Very good notice. 1001 00:40:42,930 --> 00:40:44,210 It should be on there. 1002 00:40:44,210 --> 00:40:46,821 We'll get it right next time. 1003 00:40:46,821 --> 00:40:48,150 All right, everyone. 1004 00:40:48,150 --> 00:40:50,670 So I'm working together with you. 1005 00:40:50,670 --> 00:40:52,000 I made the mistake too. 1006 00:40:52,000 --> 00:40:52,950 Easy one to make. 1007 00:40:52,950 --> 00:40:53,950 It can mess you up. 1008 00:40:53,950 --> 00:40:55,130 It didn't this time. 1009 00:40:55,130 --> 00:40:57,252 We're going to get it-- question? 1010 00:40:57,252 --> 00:41:00,138 AUDIENCE: If G's the goal at the end, 1011 00:41:00,138 --> 00:41:05,551 and you get G in your outcomes, and you know the number that's 1012 00:41:05,551 --> 00:41:07,050 shorter than everything else, do you 1013 00:41:07,050 --> 00:41:09,600 have to actually extend at G? 1014 00:41:09,600 --> 00:41:12,610 PROFESSOR: So, the question is, do you actually extend G? 1015 00:41:12,610 --> 00:41:14,720 Should we even put G in the extended list? 1016 00:41:14,720 --> 00:41:17,750 The answer is, the answer to that question 1017 00:41:17,750 --> 00:41:20,170 is, it is a matter of taste. 1018 00:41:20,170 --> 00:41:22,682 And in the questions where we, in my opinion, 1019 00:41:22,682 --> 00:41:24,890 rather foolishly, asked how many nodes were extended, 1020 00:41:24,890 --> 00:41:26,870 rather than ask you to write them out, 1021 00:41:26,870 --> 00:41:29,230 we generally accept the answer where you didn't extend 1022 00:41:29,230 --> 00:41:32,310 or where you did extend G. It's an implementation detail. 1023 00:41:32,310 --> 00:41:34,860 You can either have a fail safe that, as soon 1024 00:41:34,860 --> 00:41:37,437 as it sees G at the beginning of the list, says, we're out. 1025 00:41:37,437 --> 00:41:38,520 We're not going to extend. 1026 00:41:38,520 --> 00:41:38,870 We're done. 1027 00:41:38,870 --> 00:41:39,500 We win. 1028 00:41:39,500 --> 00:41:42,250 Or a fail safe that, when you're about to extend something, 1029 00:41:42,250 --> 00:41:44,190 and you go into the extension process, 1030 00:41:44,190 --> 00:41:46,650 and it sees that it ends in G, that it wins. 1031 00:41:46,650 --> 00:41:49,340 So it is a matter of taste. 1032 00:41:49,340 --> 00:41:51,720 If you kind of like to watch your little guy 1033 00:41:51,720 --> 00:41:54,040 doing the search win, and have an S and a G, 1034 00:41:54,040 --> 00:41:54,835 you can put it on. 1035 00:41:54,835 --> 00:41:57,670 If you don't, you can not put it on. 1036 00:41:57,670 --> 00:41:59,490 We won't take off points for whether or not 1037 00:41:59,490 --> 00:42:02,180 it has a G at the end because clearly, if you 1038 00:42:02,180 --> 00:42:05,710 did all the other crazy stuff correct, well, 1039 00:42:05,710 --> 00:42:08,240 you could have written in a G if you wanted to. 1040 00:42:08,240 --> 00:42:11,780 I think, unless there's someone who mis-solves the problem 1041 00:42:11,780 --> 00:42:14,020 right at the end, is like, oh, who cares about G? 1042 00:42:14,020 --> 00:42:14,834 Oh no, it's stuck. 1043 00:42:14,834 --> 00:42:15,500 It's a dead end. 1044 00:42:15,500 --> 00:42:16,570 We lose. 1045 00:42:16,570 --> 00:42:19,650 But that would be probably pretty rare. 1046 00:42:19,650 --> 00:42:23,350 So let's solve the A*. 1047 00:42:23,350 --> 00:42:25,600 So I'm not going to make the same mistake twice. 1048 00:42:25,600 --> 00:42:26,840 We go from S to ABEF. 1049 00:42:29,690 --> 00:42:33,910 And S, by the way, had a value of 0. 1050 00:42:33,910 --> 00:42:34,410 All right. 1051 00:42:34,410 --> 00:42:36,550 What is the value at A? 1052 00:42:36,550 --> 00:42:40,611 Well, I think it's 160. 1053 00:42:40,611 --> 00:42:42,360 The question is, how do we calculate this? 1054 00:42:42,360 --> 00:42:44,350 Well, it's the path that we've traveled 1055 00:42:44,350 --> 00:42:49,070 so far plus the heuristic value at the final node. 1056 00:42:49,070 --> 00:42:52,370 This is why someone's going to give me the wrong answer at BD, 1057 00:42:52,370 --> 00:42:53,580 but let's see. 1058 00:42:53,580 --> 00:42:56,040 So we have 160 here. 1059 00:42:56,040 --> 00:42:56,940 OK. 1060 00:42:56,940 --> 00:42:59,766 So SB. 1061 00:42:59,766 --> 00:43:01,140 What is the heuristic value here? 1062 00:43:01,140 --> 00:43:07,790 We've got 3 for the path, and 50 for the heuristic, so it's 53. 1063 00:43:07,790 --> 00:43:08,514 SE. 1064 00:43:08,514 --> 00:43:09,430 What have we got here? 1065 00:43:09,430 --> 00:43:15,420 We've got 14 for the path, 56 for the heuristic, so it's 70. 1066 00:43:15,420 --> 00:43:16,467 All right. 1067 00:43:16,467 --> 00:43:17,720 SF. 1068 00:43:17,720 --> 00:43:22,290 We've got 4 for the path, 50 for the heuristic, 54. 1069 00:43:22,290 --> 00:43:22,980 OK. 1070 00:43:22,980 --> 00:43:24,680 Who's our winner? 1071 00:43:24,680 --> 00:43:25,800 It's B again. 1072 00:43:25,800 --> 00:43:28,370 Barely, but it is the winner. 1073 00:43:28,370 --> 00:43:29,450 Extended list up here. 1074 00:43:29,450 --> 00:43:30,110 SB. 1075 00:43:30,110 --> 00:43:30,680 All right. 1076 00:43:30,680 --> 00:43:34,759 B, as we saw, goes only to D. 1077 00:43:34,759 --> 00:43:36,550 What is the value that I should write here? 1078 00:43:36,550 --> 00:43:39,240 AUDIENCE: [CHATTER] 1079 00:43:39,240 --> 00:43:39,900 PROFESSOR: OK. 1080 00:43:39,900 --> 00:43:43,060 I am happy I heard all the things that I expected to hear. 1081 00:43:43,060 --> 00:43:45,580 I heard the correct answer, which is 57. 1082 00:43:45,580 --> 00:43:48,160 I also heard someone say 107. 1083 00:43:48,160 --> 00:43:52,160 So why is it 57, and not 107? 1084 00:43:52,160 --> 00:43:53,930 Someone does it this way every time. 1085 00:43:53,930 --> 00:43:55,889 Do not add up all the heuristics along the way. 1086 00:43:55,889 --> 00:43:57,888 I will try to explain to you why you would never 1087 00:43:57,888 --> 00:43:58,910 want to do that. 1088 00:43:58,910 --> 00:44:01,000 The heuristic value at any given node 1089 00:44:01,000 --> 00:44:05,430 says, given that I'm here, how much work do I think 1090 00:44:05,430 --> 00:44:08,620 I have left to get to the end? 1091 00:44:08,620 --> 00:44:09,430 All right? 1092 00:44:09,430 --> 00:44:12,192 It's sort of like, let's guess the last few nodes in the path 1093 00:44:12,192 --> 00:44:13,400 that we haven't done out yet. 1094 00:44:13,400 --> 00:44:16,590 So you can see why it would be bad to add that 1095 00:44:16,590 --> 00:44:19,200 for every node in your list because then you're double 1096 00:44:19,200 --> 00:44:21,330 counting all of the last nodes. 1097 00:44:21,330 --> 00:44:24,730 So add the path so far to the very final heuristic. 1098 00:44:24,730 --> 00:44:29,050 That's 3 plus 4 plus the 50 that's with D is 57. 1099 00:44:29,050 --> 00:44:35,100 So our current winner, then, is 54, with F. Just the same 1100 00:44:35,100 --> 00:44:35,680 as last time. 1101 00:44:35,680 --> 00:44:40,235 F goes to H. And what's our total value at H? 1102 00:44:42,780 --> 00:44:45,880 20 plus, that's a 39, 59. 1103 00:44:45,880 --> 00:44:48,510 So who wins now? 1104 00:44:48,510 --> 00:44:50,960 D, with 57. 1105 00:44:50,960 --> 00:44:54,290 But we extended F, yes. 1106 00:44:54,290 --> 00:44:54,790 All right. 1107 00:44:54,790 --> 00:44:55,900 So D was 57. 1108 00:44:55,900 --> 00:44:56,400 All right. 1109 00:44:56,400 --> 00:44:59,420 So D was not one of the ones that I tricked myself with. 1110 00:44:59,420 --> 00:45:03,740 D only goes to I. What's our value at I? 1111 00:45:07,240 --> 00:45:11,310 I think our value is 57 because I has a heuristic of 0. 1112 00:45:11,310 --> 00:45:11,810 Yes. 1113 00:45:11,810 --> 00:45:12,990 I has a heuristic of 0. 1114 00:45:12,990 --> 00:45:16,550 Our value at I is 57. 1115 00:45:16,550 --> 00:45:17,430 OK? 1116 00:45:17,430 --> 00:45:20,870 And I extended D. Who's the winner now? 1117 00:45:20,870 --> 00:45:21,450 I? 1118 00:45:21,450 --> 00:45:21,950 OK. 1119 00:45:21,950 --> 00:45:23,510 So I is the winner. 1120 00:45:23,510 --> 00:45:29,210 With I as the winner, we extend I. I goes to C, D. Ha ha. 1121 00:45:29,210 --> 00:45:33,290 Good call, whoever back there figured out my secret error 1122 00:45:33,290 --> 00:45:33,980 before. 1123 00:45:33,980 --> 00:45:35,510 C, D, and G. 1124 00:45:35,510 --> 00:45:37,140 AUDIENCE: [CHATTER] 1125 00:45:37,140 --> 00:45:39,870 PROFESSOR: C, H, and G? 1126 00:45:39,870 --> 00:45:40,680 Oh, you're right. 1127 00:45:40,680 --> 00:45:42,690 We already went to D. Aha. 1128 00:45:42,690 --> 00:45:45,480 C, H, and G. You're correct. 1129 00:45:45,480 --> 00:45:46,230 Everyone see that? 1130 00:45:46,230 --> 00:45:49,280 C, H, and G. Absolutely right. 1131 00:45:49,280 --> 00:45:53,400 I goes to C, H, and G. So the path to C, H, and G 1132 00:45:53,400 --> 00:45:56,700 is a hard path. 1133 00:45:56,700 --> 00:45:58,500 To C, we got, what did we have? 1134 00:45:58,500 --> 00:46:01,480 57 plus 50 is 127. 1135 00:46:01,480 --> 00:46:04,472 Oh, and by the way, C, G, and H. We've 1136 00:46:04,472 --> 00:46:06,490 got to do it in lexicographic order. 1137 00:46:06,490 --> 00:46:10,580 So 127 to C. To G, we have 67. 1138 00:46:13,150 --> 00:46:17,320 And to H, we have 87. 1139 00:46:19,860 --> 00:46:21,310 So who wins now? 1140 00:46:24,630 --> 00:46:26,130 H. H, with 59. 1141 00:46:26,130 --> 00:46:28,750 That's right. 1142 00:46:28,750 --> 00:46:30,460 H, with 59. 1143 00:46:30,460 --> 00:46:31,960 And as we already know, cause it was 1144 00:46:31,960 --> 00:46:34,610 the winner last time, H, with 59, 1145 00:46:34,610 --> 00:46:41,635 goes to I, which has, I believe, 50. 1146 00:46:45,050 --> 00:46:46,620 Well, it's still gets added. 1147 00:46:46,620 --> 00:46:47,170 Remember? 1148 00:46:47,170 --> 00:46:49,253 We're only going to kill it when it gets extended. 1149 00:46:49,253 --> 00:46:50,745 So who's the shortest? 1150 00:46:50,745 --> 00:46:53,120 So you were a step ahead, whoever asked me that question. 1151 00:46:53,120 --> 00:46:55,840 Who's the shortest? 1152 00:46:55,840 --> 00:46:58,990 H also goes to E. Absolutely right. 1153 00:46:58,990 --> 00:47:02,350 H also goes to E. I was getting ahead of myself here. 1154 00:47:02,350 --> 00:47:04,900 H also goes to E with a length of extra 16. 1155 00:47:04,900 --> 00:47:11,600 So we've got 20 plus 16 is 36 plus 56 is 92. 1156 00:47:11,600 --> 00:47:12,100 All right. 1157 00:47:12,100 --> 00:47:14,060 That's good. 1158 00:47:14,060 --> 00:47:17,060 So who's the shortest? 1159 00:47:17,060 --> 00:47:17,810 I is the shortest. 1160 00:47:17,810 --> 00:47:19,200 Do we extend it? 1161 00:47:19,200 --> 00:47:19,700 No. 1162 00:47:19,700 --> 00:47:22,910 It's on the extended list. 1163 00:47:22,910 --> 00:47:23,460 All right. 1164 00:47:23,460 --> 00:47:25,710 Who's the shortest now? 1165 00:47:25,710 --> 00:47:29,036 It's hard to read, but the shortest is this 67 on the G. 1166 00:47:29,036 --> 00:47:29,800 So we're done. 1167 00:47:29,800 --> 00:47:30,940 We win. 1168 00:47:30,940 --> 00:47:33,840 Our path is SBDIG. 1169 00:47:33,840 --> 00:47:34,550 Yeah, for A*. 1170 00:47:34,550 --> 00:47:36,600 It gets the right answer, right? 1171 00:47:36,600 --> 00:47:38,390 No. 1172 00:47:38,390 --> 00:47:39,990 Unfortunately not. 1173 00:47:39,990 --> 00:47:41,670 So what happened here? 1174 00:47:41,670 --> 00:47:43,310 Why did we not get the right answer? 1175 00:47:43,310 --> 00:47:44,470 Be as specific as possible. 1176 00:47:48,184 --> 00:47:49,850 What are people saying about heuristics? 1177 00:47:49,850 --> 00:47:51,876 AUDIENCE: [CHATTER] 1178 00:47:51,876 --> 00:47:52,750 PROFESSOR: All right. 1179 00:47:52,750 --> 00:47:55,320 People are saying the heuristic must be consistent. 1180 00:47:55,320 --> 00:47:58,250 That is both correct and specific, so I applaud you. 1181 00:47:58,250 --> 00:48:00,210 Too easy to say the heuristic was inadmissible. 1182 00:48:00,210 --> 00:48:03,140 It actually was completely admissible everywhere. 1183 00:48:03,140 --> 00:48:06,771 So that leads us into our very last point for the day. 1184 00:48:06,771 --> 00:48:08,645 What the hell are these heuristic consistency 1185 00:48:08,645 --> 00:48:11,557 and admissibility things, and why do I care? 1186 00:48:11,557 --> 00:48:13,890 Well, the reason why you care is many fold, one of which 1187 00:48:13,890 --> 00:48:16,700 is that it's almost guaranteed to be on the quiz. 1188 00:48:16,700 --> 00:48:17,920 But what are they? 1189 00:48:17,920 --> 00:48:21,180 Admissibility is a check at every point to make sure 1190 00:48:21,180 --> 00:48:22,644 your heuristic at that point, which 1191 00:48:22,644 --> 00:48:24,560 is supposed to be an estimate of how much work 1192 00:48:24,560 --> 00:48:28,221 you have left to do, is always an underestimate or an accurate 1193 00:48:28,221 --> 00:48:28,720 estimate. 1194 00:48:28,720 --> 00:48:30,550 It can never be an overestimate. 1195 00:48:30,550 --> 00:48:31,160 Why not? 1196 00:48:31,160 --> 00:48:34,410 Well, as Patrick showed you with his mostly correct example 1197 00:48:34,410 --> 00:48:36,341 in lecture, if it's an overestimate, 1198 00:48:36,341 --> 00:48:37,840 it's never going to expand that node 1199 00:48:37,840 --> 00:48:39,870 cause it's going to think, you know, if you write one million 1200 00:48:39,870 --> 00:48:41,110 as a heuristic, it's going to think 1201 00:48:41,110 --> 00:48:43,210 it needs to do one million after it's done going that way. 1202 00:48:43,210 --> 00:48:44,970 It's not going to want to go that way. 1203 00:48:44,970 --> 00:48:46,670 All right? 1204 00:48:46,670 --> 00:48:48,620 So it's always got to be an underestimate 1205 00:48:48,620 --> 00:48:50,220 or an equal estimate. 1206 00:48:50,220 --> 00:48:52,410 But let's say that you, at the quiz, 1207 00:48:52,410 --> 00:48:54,100 and you forget Mark told me this. 1208 00:48:54,100 --> 00:48:55,360 You didn't bring any notes. 1209 00:48:55,360 --> 00:48:56,326 You're just having a brain freeze. 1210 00:48:56,326 --> 00:48:57,320 You're like, oh no. 1211 00:48:57,320 --> 00:48:58,420 Is it supposed to be an overestimate 1212 00:48:58,420 --> 00:48:59,253 or an underestimate? 1213 00:48:59,253 --> 00:49:00,378 I can't remember which one. 1214 00:49:00,378 --> 00:49:01,378 How can I figure it out? 1215 00:49:01,378 --> 00:49:02,420 How can I figure it out? 1216 00:49:02,420 --> 00:49:06,590 I propose you the following calm, soothing mantra slash 1217 00:49:06,590 --> 00:49:08,760 sutra that will help protect you. 1218 00:49:08,760 --> 00:49:11,659 Think to yourself of the following question. 1219 00:49:11,659 --> 00:49:13,950 We know that A* sometimes messes up with the heuristic. 1220 00:49:13,950 --> 00:49:17,170 Does branch and bound always get it right? 1221 00:49:17,170 --> 00:49:17,910 Yes. 1222 00:49:17,910 --> 00:49:19,740 What heuristic values does branch and bound 1223 00:49:19,740 --> 00:49:21,480 add everywhere? 1224 00:49:21,480 --> 00:49:22,190 0. 1225 00:49:22,190 --> 00:49:22,690 Right? 1226 00:49:22,690 --> 00:49:23,523 It has no heuristic. 1227 00:49:23,523 --> 00:49:25,400 It essentially adds 0. 1228 00:49:25,400 --> 00:49:28,280 Is 0 an overestimate or an underestimate? 1229 00:49:28,280 --> 00:49:29,160 An underestimate. 1230 00:49:29,160 --> 00:49:31,867 Therefore, since branch and bound always works, 1231 00:49:31,867 --> 00:49:33,825 the one you're looking for is an underestimate. 1232 00:49:33,825 --> 00:49:35,710 And I know from when I was taking the class, 1233 00:49:35,710 --> 00:49:37,867 I always had a moment where I had to spend, like, 1234 00:49:37,867 --> 00:49:39,450 two minutes convincing myself, OK, I'm 1235 00:49:39,450 --> 00:49:41,230 going for underestimate, not overestimate. 1236 00:49:41,230 --> 00:49:41,970 This will help. 1237 00:49:41,970 --> 00:49:44,030 It will take fewer than two minutes to do that. 1238 00:49:44,030 --> 00:49:45,720 So what is consistency? 1239 00:49:45,720 --> 00:49:47,950 Consistency is a little bit stronger of a claim. 1240 00:49:47,950 --> 00:49:50,130 When you claim that a graph is consistent, 1241 00:49:50,130 --> 00:49:53,640 what you're saying is, between any two nodes, 1242 00:49:53,640 --> 00:49:57,750 or to do it more simply, between any two adjacent nodes, 1243 00:49:57,750 --> 00:50:00,230 the distance between the heuristics 1244 00:50:00,230 --> 00:50:03,890 is less than the distance between the nodes. 1245 00:50:03,890 --> 00:50:07,400 In other words, admissibility is a sort 1246 00:50:07,400 --> 00:50:10,500 of, like, consistency between every node in G. 1247 00:50:10,500 --> 00:50:12,780 Whereas consistency is consistency between every node 1248 00:50:12,780 --> 00:50:14,390 and every other node. 1249 00:50:14,390 --> 00:50:15,430 All right? 1250 00:50:15,430 --> 00:50:17,680 Consistency is a stronger claim. 1251 00:50:17,680 --> 00:50:20,740 Any graph that's consistent is always admissible. 1252 00:50:20,740 --> 00:50:25,527 Any graph that is inadmissible is always inconsistent. 1253 00:50:25,527 --> 00:50:26,610 That's the contrapositive. 1254 00:50:26,610 --> 00:50:26,980 Question? 1255 00:50:26,980 --> 00:50:28,854 AUDIENCE: Less than or less than or equal to? 1256 00:50:28,854 --> 00:50:31,080 PROFESSOR: Equal to is still OK. 1257 00:50:31,080 --> 00:50:32,350 Equal to is always OK. 1258 00:50:32,350 --> 00:50:32,960 That's great. 1259 00:50:32,960 --> 00:50:33,959 It's a perfect estimate. 1260 00:50:33,959 --> 00:50:35,420 But never greater. 1261 00:50:35,420 --> 00:50:38,927 Now, if a graph is inconsistent, will you lose? 1262 00:50:38,927 --> 00:50:39,510 Will you lose? 1263 00:50:39,510 --> 00:50:42,830 Why is it called admissible, then, if it's sometimes not 1264 00:50:42,830 --> 00:50:45,245 admissible? 1265 00:50:45,245 --> 00:50:45,870 Why do we lose? 1266 00:50:45,870 --> 00:50:48,390 The answer is the extended list, and you see that here. 1267 00:50:48,390 --> 00:50:51,090 If a graph is admissible, you will always 1268 00:50:51,090 --> 00:50:55,410 get the right answer unless you use an extended 1269 00:50:55,410 --> 00:50:57,250 list because you're checking from every node 1270 00:50:57,250 --> 00:50:58,200 to the goal node. 1271 00:50:58,200 --> 00:51:00,120 And you're sure that your estimates are right. 1272 00:51:00,120 --> 00:51:02,075 But if estimates within nodes aren't correct, 1273 00:51:02,075 --> 00:51:03,700 you might go through them out of order, 1274 00:51:03,700 --> 00:51:05,270 and that violates your assumption 1275 00:51:05,270 --> 00:51:07,030 that you made when you decided to use 1276 00:51:07,030 --> 00:51:08,655 the extended list that you would always 1277 00:51:08,655 --> 00:51:10,980 go through the sub-graphs in order. 1278 00:51:10,980 --> 00:51:13,955 This graph is very expertly crafted to do that to 1279 00:51:13,955 --> 00:51:15,420 you cause I might as well be sort 1280 00:51:15,420 --> 00:51:18,327 of a bottleneck, goal node, and I has an inconsistency. 1281 00:51:18,327 --> 00:51:20,410 There's a few other inconsistencies in this graph, 1282 00:51:20,410 --> 00:51:21,860 but they don't do anything to you. 1283 00:51:21,860 --> 00:51:25,200 In fact, even inadmissibilities sometimes don't mess you up. 1284 00:51:25,200 --> 00:51:27,424 So you can't just say, blindly, it's inadmissible, 1285 00:51:27,424 --> 00:51:28,340 so it will never work. 1286 00:51:28,340 --> 00:51:29,142 It might work. 1287 00:51:29,142 --> 00:51:30,600 It turns out the only inconsistency 1288 00:51:30,600 --> 00:51:33,630 that matters here is not the inconsistency between, say, 1289 00:51:33,630 --> 00:51:35,590 S and F. That doesn't turn out to matter. 1290 00:51:35,590 --> 00:51:38,560 It's the inconsistency between some of these nodes, 1291 00:51:38,560 --> 00:51:41,570 including I and H, specifically. 1292 00:51:41,570 --> 00:51:45,340 So have a good weekend. 1293 00:51:45,340 --> 00:51:47,090 Come in on Monday and Tuesday to tutorial. 1294 00:51:47,090 --> 00:51:49,739 Ask about the queue method, or other methods. 1295 00:51:49,739 --> 00:51:51,780 Ask about anything that's niggling in your brain. 1296 00:51:51,780 --> 00:51:53,780 But hopefully, you guys have got this. 1297 00:51:53,780 --> 00:51:55,780 You're going to do fine.