Sei sulla pagina 1di 9

Name:

X.500 ID:

Midterm 1 Answer Key


100 points CSci 4511, Thursday March 3, 2011 Closed book, notes, laptop, cell phone, calculator. 1 page of notes

Unless the question specifically asks for more detail, you may use short answers.
1. 4 points State the solution path and cost found by breadth-first search (not uniform cost search). S A D G Cost: 3 Costs in breadth-first search is the number of steps i think some students confused solution path with what nodes will it search
20
D

S
10
A

1
B

1
C

8
E

5
F

12

4 3
H

G
2. 4 points In what sense is IDA* preferable to A*?

Uses less memory Several people mentioned that its interruptible. i dont think thats what Korff, the guy who invented it, had in mind when he made it, but it was obviously a big deal in the chess problem so that answer was also worth full credit

3. 6 points Name one reason why you would use depth-first search. Name a reason why you would not. Pro: Uses less memory, good choice for short, fat problems Con: Not optimal, gets caught on loops, does not work on problems with infinite depth, wrong choice for tall skinny problems A lot of people brought up variable assignment problems. If you said it finds answers faster than BFS in the best case and the same as BFS in the worst, you got full credit. If you said it works better than BFS for those problems but dont say why, you lost points. If you said it works on problems where the solution depth is know (not it works better, just it works), you lost a lot of points

4. 4 points You are at a node where g(n)=10 and h(n)=10. This node is on the optimal path. What is the actual cost (C*) of the path through that node to the solution? If this is a trick question, say why.

We have no idea what the actual cost is. All we know is that its at least 20, but since h(n) can be an underestimate and g(n) is perfect, f(n) can also be an underestimate

5. 1 point each Are these heuristics admissible (T/F)? Note: C(n, goal) is the true cost from the node to the goal. a. h1(n)=0 T b. h2(n)=g(n) c. h3(n)= random(0, C(n, goal)) d. h4(n)=2C(n, goal) e. h5(n)=C(n, goal) F T F T

Most people got this with the exception of 5b, g(n). As you get closer to the solution, g grows and h shrinks. If you used g(n) as your heuristic, h(n) gets bigger as you get closer to the goal, which is the wrong direction. Suppose youre on a path C*=20. If youre at the start of the path, you might have g(n)=5, h(n)=15. Near the end of the path, g(n)=15, h(n)=5. If you used h(n)=g(n) then near the end of the path the remaining cost is 5youre your estimate is 15, 3 times the actual cost and clearly not admissible. And what happens with that inadmissible heuristic? Youd have f(n)=g(n)+h(n) = 15+15 = 30 which is > C*, so the solution would be below where it should be and a non-optimal solution might be found first. It also has the effect of pushing A* away from the goal, not towards it

6. 4 points The open list contains 101 nodes. One is the goal, f(goal)=45. Of the remaining 100 nodes, 10 have the cost f(n)=10, 10 have f(n)=20, 10 have f(n)=30, etc. all the way to 10 nodes with f(n)=100. Of these, only 8 nodes are on the optimal path. Including the goal node, how many of these 101 nodes will A* expand? Why?

The 10 10s + 10 20s + 10 30s + 10 40s + the goal itself = 41 A* always expands all nodes f(n)<C*. Needed to guarantee it finds the lowest cost solution. A* never expands nodes where f(n)>C* so none of the other 60 will be evaluated. Most students got this question right but a few complained that the question was hard to understand. As i mentioned the first day of class, i only want people to fail for not understanding the material, not for not understanding the question. For this reason, i decided to throw this question out and just give everyone the 4 points

7. 4 points Is it possible for A* and uniform cost search to find solutions with different costs? Assume A* has an admissible heuristic. Explain.

No. Both are optimal and the optimal answer is the one with the lowest cost. If UCS found an answer 10 but A* found one at 9, UCS's answer wouldn't be optimal, and since we know UCS is optimal we know it wouldnt have found that answer, it would have found the 9 one The two algorithms might find different solutions (when more than one exists) but theyll both be optimal and therefore, by the definition of optimality, be the same cost

8. 8 points h1(n) is an admissible heuristic. h2(n) = h1(n). Both are admissible but h1 is better. Why?

A* must search all nodes ahead of C*. When h(n) is smaller, it makes f(n) smaller which might put that node ahead of C*, causing A* to have to search more nodes and therefore be slower to find the answer Many people said h1 dominates h2, which is true but thats just a definition it doesnt tell us why dominating is better than not dominating. Many people said higher estimates are better, which is true, but it doesnt tell us why. You had to explain that lower estimates potentially slow A* down by making it do more work

Show each step taken to solve the following map using the following heuristics. Heuristic Values S 25 A 20 B 25 C 10 D 20 E 10 G 0

9. Show the search process for A* (10 points) Expanded Node Open List

Closed List

S
A B C D Goal

S=25 A=25, B=30


B=30 C=30, D=35 D=35, E=40 Goal=35, E=40

S
S, A S, A, B S, A, B, C S, A, B, C, D

This is a much easier version of the problem in the sample test. Since i showed the answer and expected format in the sample exam, i expected people to get this right. i believe it is easier for you if you keep your list of open nodes sorted so that you can tell who to pop but no points were lost if you didnt do that. There was one unexpectedly common error when you pop the goal off the top of the open list, the search is over. You do not keep searching the list. In the above example, node E is on the open list but is never evaluated/expanded/popped. 10. Show the search process for Greedy Best-First Search (10 points) Expanded Node Open List Closed List

S
A B C E Goal

S=25 A=20, B=25


B=25 C=10, D=20 E=10, D=20 Goal=0, D=20

S
S, A S, A, B S, A, B, C S, A, B, C, E

Alternate Answer: The book explicitly states that in situations like this, the agent will loop between S and A forever. Although that's not my understanding of how a real implementation would work and not what i showed in the sample midterm key, it is what the book says and is therefore worth full points

11. 4 points In first choice hill climbing, we settle for the first good option rather than select the best one. Why? Designed for continuous/infinite spaces where enumerating all options is impossible Many people said it saved memory. While technically true, thats not why FCHC was invented nor why it does what it does. Imagine a super huge problem like the million queen problem. Branching factor is 1 million but if each choice took a byte, thats less than one

MB, which it then immediately frees upon making a choice. Memory is rarely a problem for any local search algorithm (its one of the defining characteristics of local algorithms) Many people said it saved time. Again, while technically true, thats not why people invented the algorithm. Replace bytes with microseconds above (after all, its just a compare operation) and youll see that its not normally a huge number. It can get big and it can make an impact but normally it isnt a big deal Either way, neither the savings in time nor memory justify the loss of optimality. We could save just as much memory and time by flipping coins and doing a random walk The purpose of FCHC is to work in continuous spaces where it is physically impossible to enumerate all possible values. If you didnt mention this or, worst case, didnt mention the super gigantic state spaces issue in a its faster answer, you did not get full credit

12. 8 points A* is an even balance of caution and speed. Suppose you wanted to make A* go a little faster and were willing to sacrifice a little optimality. Is there any way to modify the cost formula to make that happen? If so, how? (show a formula). If not, are you sure you studied for this exam? Weight the heuristic more than the actual cost. For example: f(n) = g(n) + 1.5*h(n) You could do this by bumping up h or knocking down g This used to be considered a really hard problem but almost everyone got it right. You guys rock Several people added boundaries (i.e., weight must be less than 1). This isnt actually necessary. Speed is based on the order of nodes in the open list and thats based on the ratio of conservatism (g) to optimism (h)

13. 8 points You create an algorithm A1 that always tries to find the best solution. Someone copies your algorithm, adds some randomness to it and calls it A2. Is there any chance their A2 algorithm could be better than your A1 algorithm? In what way? Randomness lets it get out of local maxima, plateaus and ridges The answer needed to be something consistent. Saying it might get lucky once doesnt make A2 a better algorithm

14. 12 points (3 each) You have a search space that is a tree with a solution depth d of 4, maximum depth m of 8 and branching factor b of 2. For both breadth-first and depth-first, state how many nodes will be searched in both the best and worst cases. You do not need to simplify the numbers (i.e., you can say 5! rather than 120). You do need to show a mathematical expression or explanation. BFS Best Case bd = 24 = 16 Worst Case bd+1-1 = 25-1 = 31 bm - bm-d -1 = 28 - 24 - 1= 256 16 1 = 239 4 down & left 4 times DFS

Reminder: Depth is the number of moves you have to make. So if you start at the root and go down 4 times, the tree has 5 levels that take 4 actions to reach. The root node is level 0. In a binary tree, the first move takes you to the first level where the tree has split once so there are bd = 21 = 2 nodes. A second move takes you to level two which contains bd = 22 = 4 nodes, etc. To understand the answers, we should do a refresher on the relevant math. If youre at level 4, there are bd = 24 = 16 leaves at the bottom (as leaves are) and 1 + 2 + 4 + 8 = 15 = 24-1 = bd-1 nodes in all the levels above it and therefore 15 + 16 = 31 = 25-1 = bd+1-1 nodes in the entire tree So in a tree with a uniform branching factor and depth, there are non-leaf nodes bd-1 bd leaf nodes d+1 b -1 nodes in the entire tree Note that this assumes you count the root node. If you do not, decrease the non-leaf nodes by 1, leaving you with bd-1/ bd/ bd+1-1. Many people said BFS best and worst case are the same. They are not. The worst case is b times worse (minus 1). Breadth-first search examines every node in every level above the level where the answer is. In this problem, that means BFS must look at the first 3 levels, which has bd-1 = 15 nodes. In the best case, the answer is the left-most node so BFS only has to search one more node. That means, in the best case, BFS searches Best Case: bd-1+1 = bd = 16 nodes If the answer is the right-most node, it has to look through all the leaf nodes until it finds the right one, plus it looked all the nodes in the levels above it. That means, in the worst case, BFS searches Worst Case: bd-1 + bd = 15 + 16 = 31 = bd+1-1 nodes

In the past weve said that, in some cases, depth-first search is faster than breadth-first search in the best case and the same in the worst case. This is not one of those situations. Thats because the depth of the tree (m) is larger than the depth of the solution (d), so it repeatedly overshoots. If it has to go to the bottom of every branch of a tree of depth 8, it has to look at bm+1-1 = 2 9-1 = 511 nodes in the entire tree In this case, it doesnt have to look at all of the branches it can skip the ones under the solution (i.e., levels 5-8) and the ones to the right of it. In the best case, if the solution is the left-most node, thats just 4 nodes. In the worst case, if the solution is all the way to the right, it searches everything except the nodes under the solution node. And how many is that? Think of the solution node as the root of a tree thats m-d = 8-4 = 4 levels tall. Lets call this depth remaining d, or r for short. We know that tree is br+1-1 = 25-1 = 31 nodes in the subtree under the solution We dont have to search those 31 nodes. Almost. We still have to search the one root node since thats where our answer is. So the number of nodes we have to search is Worst Case: (bm+1-1) - (br+1-1) + 1 = 511 - 31 + 1 = 481 nodes Many of you will hopefully notice that you did not get the correct answer but still got full or substantial partial credit. We ignored it if you missed the -1/+1 constants, we overlooked many instances of misunderstanding what depth is (the number of actions, not levels) and did not take points off if you didnt subtract the pruned subtree in DFS worst case. Were cool that way. This question was not an attempt to test your math skills, we just wanted to see if you got the basic idea about how performance differs between different algorithms and situations.

15. 9 points Show where alpha-beta prunes in the following tree and the backed-up minimax values after pruning. As always, assume minimax works left to right.

2 B A

3
L1 A: 2 < 3 B: 2 < 3

12
L2

8
L3

2
L4

4
L5

0
L6

15
L7

5
L8

2
L9

Most people got this right (which is surprising; this is one of the more confusing/difficult items in the class) but the people who did not are probably wondering why, so lets explain it in a little more depth. We have to check leaf node L1 you always have to check the first node since you have nothing to compare it to. The first node will, at first, be the value everything will be compared to, so we have to expand all its leaf nodes. L1 is 3 and Min gets to choose. Min is hoping for even less so it has to keep checking. If finds L2=12, its too high so it ignores it and checks L3=8. Of those options, Min chooses 3 and thats now our benchmark. If we choose branch 1, the best we can do is 3. If we choose the middle branch, Mins first choice is L4=2. Min is hoping for even less, so it would keep checking. But we wont in the best case (for us), the value of branch 2 is 2, in the worst case, its less than 2. To make it more clear, if L5=100, Min wont choose it and branch 2 will be worth 2. If L5=0, Min would pick that and the value of branch 2 will be 0. Either way, the first branch gets us a guaranteed 3, better than both the best and worst case scenario for branch 2, so it would be silly of us to waste time evaluating the rest of that branch. For the sake of time, it should be pruned.

If we choose the third branch, Mins first choice is L7=15. Thats way better than the 3 wed get from the first branch so maybe branch 3 is a better option. We wont know for sure until we see what Mins other options are. L8=9. Huh. Not as good as 15 but better than 3 so branch 3 is still our best option. Finally, we check Mins last option, which is L9=2. Doh! Thats the one Min would pick, that jerk, and that means branch 3, in the worst case, is worth 2, less than the guaranteed minimum for branch 1. The possible maximum value is higher in branch 3 (15 vs. 12) but wed only get that if our opponent Min makes a mistake. Thats a pretty optimistic hope and minimax is not optimistic its purpose is not to maximize the best possible score, its to minimize our risk by looking for the best possible outcome in the worst possible situation.

Potrebbero piacerti anche