Sei sulla pagina 1di 6

AI Midterm Solution

December 11, 2006


1. (18 Points) Search Consider the problem of moving k knights from k starting squares s1 , s2 , . . . , sk to k goal squares g1 , g2 , . . . , gk , on an unbounded chessboard, in the smallest number of actions. Each action consists of moving up to k knights simultaneously, subject to the rule that no two knights can land on the same square at the same time. The legal moves of a knight are marked in Figure 1.

Figure 1: Legal moves of a knight on the chess board. (a) (6 Points) Dene the maximum branching factor b in this state space as a function of k . (b) (6 Points) Suppose hi is an admissible heuristic for the problem of moving knight i to goal gi by itself. Is the following heuristic function admissible ? Please justify your answer briey.
k

hi
i=1

(c) (6 Points) Which of the following is a better heuristic function? Please justify your answer. min{h1 , h2 , . . . , hk } max{h1 , h2 , . . . , hk } Answer (a) b = 9k . Each knight may move in 8 dierent directions or stay, and k knights can move simultaneously. The maximum branching factor would be 9k . You would get 3 points if only 8 directions are considered (8k ). (b) hi is not an admissible heuristic function. Assume there are 2 knights and each knight needs only one step to go from the starting square to the goal square (no overlapping occured on the path). Then h1 (s) = h2 (s) = 1, and 2 i=1 hi = 2. Obviously, the original problem only need 1 step to reach goal since the knights can move simultaneously. Therefore, the heuristic function proposed is not admissible. You will get 3 points for giving the right answer and another 3 points for giving a reasonable justication.
k i=1

(c) max{h1 , h2 , . . . , hk } is a better heuristic function. Since max{h1 , h2 , . . . , hk } and min{h1 , h2 , . . . , hk } are both admissible heuristic function, and max{h1 , h2 , . . . , hk } min{h1 , h2 , . . . , hk }. max{h1 , h2 , . . . , hk } is a better heuristic function. You would get 3 points for giving the right answer and another 3 points for giving a reasonable justication.

2. (18 Points) Constraint Satisfaction Consider the standard 9 9 Sudoku puzzle. (a) (6 Points) Please formulate it as a constraint satisfaction problem by dening the variables, values, and constraints. (b) (5 Points) Use an example to explain how one may improve the basic backtracking search. (c) (4 Points) Please argue for or against solving the Sudoku puzzle using local search. Answer (a) A 3 3 Sudoku problem can be formulated as: Variables(2 points ): {Xij |i, j N, 1 i, j 9, cell (i, j ) is empty at start} Domain(2 points ): Xij {1, 2, . . . , 9} Constraints(2 points ): For all integers i, j, k, l [1, 9], If i = k , then Xij = Xkj . If j = k , then Xij = Xik . j i l If i = k or j = l, and 3 = k 3 and 3 = 3 , then Xij = Xkl . (b) There are many ways to improve basic backtracking. For example, by MRV(minimum remaining values) heuristic, assume we have two variables, x8 and x9 , to choose. There are three possible values for x9 while only one possible value for x8 . Moreover, unfortunately, the legal value for x8 will cause failure immediately. By MRV heuristic, we should rst choose x8 rather than x9 . The dierence is shown in Figure 2:

Figure 2: Basic backtracking and backtracking with MRV heuristic You will get 5 points only if your example shows whats the dierence before and after applying your method to the basic backtracking algorithm. (c) To against: The standard Sudoku problem has large state space and only one solution, thus basic local search strategy will fall into suboptimal solutions easily. The correct answer is arguing against using local search. You can still get some points if your reason to use local search is reasonable. 3. (18 Points) Game Search Suppose there are two friends, Peter and Edward, living in dierent cities on a tree-structured map, as shown in Figure 3. The two friends take turns moving to a neighboring city on the map. However, Edward wants to avoid Peter. The problem then becomes a two-player pursuit-evasion game. Initially, Peter is at node b and Edward is at node d. If Peter moves rst, a partially constructed game tree is shown in Figure 4, where each node is marked with the current positions of Peter and Edward. The game ends when the players are on the same node; a simplied denition of the terminal payo to the pursuer is the negative of the total time taken. Internal nodes are circles, and terminal nodes are squares. Dotted circles are nodes with unknown values. (a) (3 Points) Given that the cost of every move is 1, mark the values of the terminal nodes. (b) (7 Points) For each internal node, write the strongest fact you can infer about its value, e.g. a specic number, inequalities like 12, or ?. 2

b P

d E f

Figure 3: A sample map.


bd

cd

ad

ce

cf

cc

ae

af

ac

de

be

df

bf

dd

dd

Figure 4: A partially constructed game tree. (c) (5 Points) Consider the cost to get to each node, and estimate the cost required to end the game without expanding the tree. Bound the values of the dotted nodes using the shortestpath lengths on the map. Mark the inequalities on each dotted node. (d) (3 Points) If the game tree is evaluated from left to right, which nodes would not need to be expanded further? Answer (a) (b) (c) The answer are shown in Fig 5. You can get one point for giving the right answer to each node. (d) bf, af and ac should not be expanded further. You can get full points for giving all answer nodes, and the score is decrease by 1 point for each extra/missing node. 4. (14 Points) Propositional Logic

(a) (6 Points) Which of the following are logically entailed by the sentence (AB )(C D E )? (A B C ) (B C D E ) (A B ) (D E ) (b) (4 Points) Convert the two sentences into CNF. (c) (4 Points) Describe briey the idea of using DPLL to speed up your proof in part a. Answer: (a) (A B C ) (B C D E ) is entailed by the sentence (A B ) (C D E ). Correct answer with method description, 6 points. Correct answer without method description 3 points. Wrong answer with method description, partial points. You need to give the reason, such as using DPLL, truth table, etc., for both two sentences. 3

Figure 5: solution of game search (b) (A B C ) (B C D E ) (A B C ) ((B C D) E ) (A B C ) (B C D E ) This is CNF. (A B ) (D E ) is CNF. Each one of sentences is 2 points. Wrong answer with method description you can get partial points.

(c) Since DPLL takes as input a sentence in CNF, it can improve the search by taking advantage of CNF. DPLL give literals truth values to reduce the search space. The idea is that A clause is true if any literal is true, even the other literals do not yet have truth values. If a sentence has a model, then it has a model with the pure symbols assigned so as to make literals true, because doing so can never make a clause false. Assign all unit clause before branching on the remainder. As the result, DPLL can speed up the proof. If you write the usage of DPLL, you can get 2 points. 5. (10 Points) First Order Logic Given the following predicates and functions: Cat(x): x is a cat. Dog(x): x is a dog. Happy(x): x is happy. Loves(x,y ): x loves y Mother(x)= the mother of x Father(x)= the father of x Translate the following sentences into rst order logic: (a) (4 Points) Every cat loves its mother or father. (b) (4 Points) Every dog whose mother loves it is happy. (c) (2 Points) Find the most general unier for the following pair of FOL sentences. xLoves(Kate,x) xLoves(x,Mother(x)) Answer: (a) x Cat(x) Loves(x,Mother(x))Loves(x,Father(x)) You can get partial points if your answer is not correct.

(b) x dog(x)Loves(Mother(x),x) Happy(x) You can write x dog(x) (Loves(Mother(x),x) Happy(x)), too. You can get partial points if your answer is not correct. (c) Notice that it is fail to nd the most general unier in the original question. Do the standardizing apart such that y Loves(y ,Mother(y )). (1 point) The most general unier is {x/M other(Kate), y/Kate}. (1 point) 6. (15 Points) Bayesian Network The Surprise Candy Company makes candy in two avors: 70% are strawberry avor and 30% are stinky tofu avor. Each new piece of candy starts out with a round shape, as it moves along the production line, a machine randomly selects a certain percentage to be trimmed into a square; then, each piece is wrapped in a wrapper whose color is chosen randomly to be red or brown. Lets assume 80% of the strawberry candies are round, and 80% have a red wrapper, while 90% of the stinky tofu candies are square and 90% have a brown wrapper. All candies are sold individually in sealed, identical, black boxes. (a) (5 Points) Draw the simplest network that can correctly represent P (Flavor , Wrapper , Shape ). (b) (3 Points) Suppose that a customer just bought a Surprise candy at the store, but has not yet opened the box. What is the probability the candy has a red wrapper? (c) (3 Points) The customer discovered that the candy in the box is round with a red wrapper. Estimate the probability that its avor is strawberry. (d) (4 Points) Describe two dierent statements that assert Wrapper and Shape of the Surprise candy are independent. Answer (a) A Bayesian Network for P (F lavor, W rapper, Shape) is as Figure 6:

Figure 6: A Bayesian Network for P (F lavor, W rapper, Shape)

(b) P (W rapper = red) = 0.59 you can get some points if your answer is wrong but the equations are correct (c) Since Wrapper and Shape are conditionally independent giving Flavor, we have: P (F lavor|W rapper = red, Shape = round) =red,Shape=round|F lavor )P (F lavor ) = P (W rapper P (W rapper =red,Shape=round)
|F lavor )P (Shape=round|F lavor )P (F lavor ) = P (W rapper=red P (W rapper =red,Shape=round) = (0.8 0.8 0.7, 0.3 0.1 0.3) (0.993, 0.007) P (F lavor = strawberry |W rapper = red, Shape = round) 0.993 you can get at least 2 points if you correctly give the Bayes rule.

(d) The answer should be statements like: (1) P (W rapper, Shape|F lavor) = P (W rapper|F lavor) P (Shape|F lavor) (2) P (W rapper|Shape, F lavor) = P (W rapper|F lavor) (3) P (Shape|W rapper, F lavor) = P (Shape|F lavor) 5

You will get 2 points if your statements do not include Flavor as the evidence. 7. (20 Points) Short-Answer Questions

(a) (4 Points) Please argue for or against the statement that A computer that can pass the Turing Test is intelligent. (b) (4 Points) Please argue for or against the statement that There exist task environment (PEAS) in which all pure reex agents behave irrationally. (c) (4 Points) After you annual checkup, the doctor has bad news and good news. The bad news is that you tested positive for a serious disease, and that the test is 99% accurate (i.e. the probability of testing positive given that you have the disease is 0.99, as is the probability of testing negative given that you dont have the disease). The good news is that this is a rare disease, striking only one in 10,000 people. Why is it good news that the disease is rare? What are the chances that you actually have the disease? (d) (4 Points) Describe a search space in which iterative deepening performs much worse than depth-rst search. (e) (4 Points) Describe the characteristics of complex domains in which IDA has diculties. Answer (a) against : People can response like a computer to cheat a test. People may be tired after doing several tests; however, computers wont be tired. (Any reasonable answer is accepted) If you only write against, you can get 2 points. (b) for : It exists an environment that the agent can not fully observable, so it is impossible for all pure reex agent behave rationally. All reasonable answers are accepted. If you only write for, you can get 2 points. (c) From the problem given, we can know that P (T est = positive|Disease = yes) = 0.99 P (T est = negtive|Disease = yes) = 0.01 P (T est = positive|Disease = no) = 0.01 P (T est = negtive|Disease = no) = 0.99 1 P (Disease = yes) = 10000 So, P (T est = positive Disease = yes) = P (T est = positive|Disease = yes)P (Disease = yes) 99 1 = 10 = 0.99 10000 6 P (T est = positive Disease = no) = P (T est = positive|Disease = no)P (Disease = no) 9999 = 0.01 10000 = 9999 106 99 Since 106 is much smaller than 9999 106 , the probability you get the disease is related small when the testing result is positive. Moreover, the chances that you actually have the disease is P (Disease = yes|T est = positive) |Disease=yes)P (Disease=yes) = P (T est=positive P (test=positive) = =
P (T est=positive|Disease=yes)P (Disease=yes) P (T est=positive|Disease=yes)P (Disease=yes)+P (T est=positive|Disease=no)P (Disease=no)
99 106 99 106 + 9999 106

1 102

(d) When the branching factor is big (1 point) the goal is deep in the search tree (2 points ) the goal is in the left of tree (suppose we search from left to right) (1 point) iterative deepening performs much worse than depth-rst search. (e) 1. IDA suers from the diculties with real valued costs. 2. IDA is subject to the potentially exponential increase in complexity associated with searching on graphs, because it cannot check for repeated states other than those on the current path. Both answers are accepted. Either one is 4 points.

Potrebbero piacerti anche