Docsity

Artificial Intelligence: Search, CSPs, and MDPs, Study notes of Artificial Intelligence

Toggle sidebar
bg1
CS 188 Introduction to
Fall 2011 Artificial Intelligence Midterm Exam
INSTRUCTIONS
•You have 3 hours.
•The exam is closed book, closed notes except a one-page crib sheet.
•Please use non-programmable calculators only.
•Mark your answers ON THE EXAM ITSELF. If you are not sure of your answer you may wish to provide a
brief explanation. All short answer sections can be successfully answered in a few sentences at most.
Last Name
First Name
SID
Login
All the work on this
exam is my own.
(please sign)
For staff use only
Q. 1 Q. 2 Q. 3 Q. 4 Q. 5 Q. 6 Q. 7 Q. 8 Total
/12 /12 /13 /7 /7 /11 /12 /6 /80
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Artificial Intelligence: Search, CSPs, and MDPs and more Study notes Artificial Intelligence in PDF only on Docsity!

CS 188 Introduction to

Fall 2011 Artificial Intelligence Midterm Exam

INSTRUCTIONS

  • You have 3 hours.
  • The exam is closed book, closed notes except a one-page crib sheet.
  • Please use non-programmable calculators only.
  • Mark your answers ON THE EXAM ITSELF. If you are not sure of your answer you may wish to provide a brief explanation. All short answer sections can be successfully answered in a few sentences at most.

Last Name

First Name

SID

Login

All the work on this exam is my own. (please sign)

For staff use only

Q. 1 Q. 2 Q. 3 Q. 4 Q. 5 Q. 6 Q. 7 Q. 8 Total

THIS PAGE INTENTIONALLY LEFT BLANK

For the following question parts, all edges in the graphs discussed have cost 1.

(f ) (3 pt) Suppose that you are designing a heuristic h for the graph on the right. You are told that h(F ) = 0.5, but given no other information. What ranges of values are possible for h(D) if the following conditions must hold? Your answer should be a range, e.g. 2 ≤ h(D) < 10. You may assume that h is nonnegative.

i. h must be admissible

ii. h must be admissible and consistent

S

A D

B

C

E

F

G

h=0.

(g) (3 pt) Now suppose that h(F) = 0.5, h(E) = 1.1, and all other heuris- tic values except h(B) are fixed to zero (as shown on the right). For each of the following parts, indicate the range of values for h(B) that yield an admissible heuristic AND result in the given expansion order- ing when using A* graph search. If the given ordering is impossible with an admissible heuristic, write none. Break ties alphabetically. Again, you may assume that h is nonnegative.

i. B expanded before E expanded before F

ii. E expanded before B expanded before F

S h=

D h=

A h=

B h=?

C h=

E

F

G h=

h=1.

h=0.

NAME: 5

  1. (12 points) Formulation: Holiday Shopping You are programming a holiday shopping robot that will drive from store to store in order to buy all the gifts on your shopping list. You have a set of N gifts G = {g 1 , g 2 ,... gN } that must be purchased. There are M stores, S = {s 1 , s 2 ,... sM } each of which stocks a known inventory of items: we write gk ∈ si if store si stocks gift gk. Shops may cover more than one gift on your list and will never be out of the items they stock. Your home is the store s 1 , which stocks no items. The actions you will consider are travel-and-buy actions in which the robot travels from its current location si to another store sj in the fastest possible way and buys whatever items remaining on the shopping list that are sold at sj. The time to travel-and-buy from si to sj is t(si, sj ). You may assume all travel-and-buy actions represent shortest paths, so there is no faster way to get between si and sj via some other store. The robot begins at your home with no gifts purchased. You want it to buy all the items in as short a time as possible and return home. For this planning problem, you use a state space where each state is a pair (s, u) where s is the current location and u is the set of unpurchased gifts on your list (so g ∈ u indicates that gift g has not yet been purchased).

(a) (1 pt) How large is the state space in terms of the quantities defined above?

(b) (4 pt) For each of the following heuristics, which apply to states (s, u), circle whether it is admissible, consistent, neither, or both. Assume that the minimum of an empty set is zero.

(neither / admissible / consistent / both) The shortest time from the current location to any other store: mins′ 6 =s t(s, s′)

(neither / admissible / consistent / both) The time to get home from the current location: t(s, s 1 )

(neither / admissible / consistent / both) The shortest time to get to any store selling any unpurchased gift: ming∈u(mins′:g∈s′^ t(s, s′))

(neither / admissible / consistent / both) The shortest time to get home from any store selling any unpurchased gift: ming∈u(mins′:g∈s′ t(s′, s 1 ))

(neither / admissible / consistent / both) The total time to get each unpurchased gift individually:∑ g∈u(mins′:g∈s′^ t(s, s

(neither / admissible / consistent / both) The number of unpurchased gifts times the shortest store-to-store time: |u|(minsi,sj 6 =si t(si, sj ))

NAME: 7

  1. (13 points) CSPs: Trapped Pacman Pacman is trapped! He is surrounded by mysterious corridors, each of which leads to either a pit (P), a ghost (G), or an exit (E). In order to escape, he needs to figure out which corridors, if any, lead to an exit and freedom, rather than the certain doom of a pit or a ghost. The one sign of what lies behind the corridors is the wind: a pit produces a strong breeze (S) and an exit produces a weak breeze (W), while a ghost doesn’t produce any breeze at all. Unfortuantely, Pacman cannot measure the the strength of the breeze at a specific corridor. Instead, he can stand between two adjacent corridors and feel the max of the two breezes. For example, if he stands between a pit and an exit he will sense a strong (S) breeze, while if he stands between an exit and a ghost, he will sense a weak (W) breeze. The measurements for all intersections are shown in the figure below. Also, while the total number of exits might be zero, one, or more, Pacman knows that two neighboring squares will not both be exits.

s

W

S w

S

s

Pacman models this problem using variables Xi for each corridor i and domains P, G, and E.

(a) (3 pt) State the binary and/or unary constraints for this CSP (either implicitly or explicitly).

(b) (4 pt) Cross out the values from the domains of the variables that will be deleted in enforcing arc consistency. X 1 P G E X 2 P G E X 3 P G E X 4 P G E X 5 P G E X 6 P G E

(c) (1 pt) According to MRV, which variable or variables could the solver assign first?

(d) (1 pt) Assume that Pacman knows that X 6 = G. List all the solutions of this CSP or write none if no solutions exist.

The CSP described above has a circular structure with 6 variables. Now consider a CSP forming a circular structure that has n variables (n > 2), as shown below. Also assume that the domain of each variable has cardinality d.

1

2

3

n

(e) (2 pt) Explain precisely how to solve this general class of circle-structured CSPs efficiently (i.e. in time linear in the number of variables), using methods covered in class. Your answer should be at most two sentences.

(f ) (2 pt) If standard backtracking search were run on a circle-structured graph, enforcing arc consistency at every step, what, if anything, can be said about the worst-case backtracking behavior (e.g. number of times the search could backtrack)?

  1. (7 points) MDPs: Bonus level!

(^1 2 3 4 )

Pacman is in a bonus level! With no ghosts around, he can eat as many dots as he wants. He is in the 5 × 1 grid shown. The cells are numbered from left to right as 1,... , 5. In cells 1 through 4, the actions available to him are to move Right (R) or to Fly (F) out of the bonus level. The action Right deterministically lands Pacman in the cell to the right (and he eats the dot there), while the Fly action deterministically lands him in a terminal state and ends the game. From cell 5, Fly is the only action. Eating a dot gives a reward of 10, while flying out gives a reward of 20. Pacman starts in the leftmost cell (cell 1). We write this as an MDP where the state is the cell that Pacman is in. The discount is γ. Consider the following 3 policies: π 0 (s) = F for all s π 1 (s) = R if s ≤ 3 , F otherwise π 2 (s) = R if s ≤ 4 , F otherwise (a) (4 pt) Assume γ = 1.0. What is:

i. V π^0 (1)?

ii. V π^1 (1)?

iii. V π^2 (1)?

iv. V ∗(1)?

(b) (3 pt) Now consider an arbitrary value for γ. i. Does there exist a value for γ such that π 0 is strictly better than both π 1 and π 2? If yes, give a value for γ. If no, write none.

ii. Does there exist a value for γ such that π 1 is strictly better than both π 0 and π 2? If yes, give a value for γ. If no, write none.

iii. Does there exist a value for γ such that π 2 is strictly better than both π 0 and π 1? If yes, give a value for γ. If no, write none.

NAME: 11

  1. (11 points) MDPs and RL: Return to Blackjack Armed with the power of Q-learning, you return to the CS188 casino! In this question, you will play a simplified version of blackjack where the deck is infinite and the dealer always has a fixed count of 15. The deck contains cards 2 through 10, J, Q, K, and A, each of which is equally likely to appear when a card is drawn. Each number card is worth the number of points shown on it, the cards J, Q, and K are worth 10 points, and A is worth 11. At each turn, you may either hit or stay. If you choose to hit, you receive no immediate reward and are dealt an additional card. If you stay, you receive a reward of 0 if your current point total is exactly 15, + if it is higher than 15 but not higher than 21, and −10 otherwise (i.e. lower than 15 or larger than 21). After taking the stay action, the game enters a terminal state end and ends. A total of 22 or higher is refered to as a bust; from a bust, you can only choose the action stay. As your state space you take the set { 0 , 2 ,... , 21 , bust, end} indicating point totals, “bust” if your point total exceeds 21, and “end” for the end of the game.

(a) (3 pt) Suppose you have performed k iterations of value iteration. Compute Vk+1(12) given the partial table below for Vk(s). Give your answer in terms of the discount γ as a variable. Note: do not worry about whether the listed Vk values could actually result from this MDP!

s Vk(s) 13 2 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 bust − 10 end 0

Vk+1(12) =

You suspect that the cards do not actually appear with equal probability and decide to use Q-learning instead of value iteration.

(b) (4 pt) Given the partial table of initial Q-values below, fill in the partial table of Q-values on the right after the following episode occurred. Assume a learning rate of 0.5 and a discount factor of 1. The initial portion of the episode has been omitted. Leave blank any values which Q-learning does not update.

Initial values s a Q(s, a) 19 hit − 2 19 stay 5 20 hit − 4 20 stay 7 21 hit − 6 21 stay 8 bust stay − 8

Episode s a r s a r s a r 19 hit 0 21 hit 0 bust stay − 10

Updated values

s a Q(s, a)

19 hit

19 stay

20 hit

20 stay

21 hit

21 stay

bust stay

NAME: 13

  1. (12 points) Mumps Outbreak There has been an outbreak of mumps at UC Berkeley. You feel fine, but you’re worried that you might already be infected and therefore won’t be healthy enough to take your CS 188 midterm. You decide to use Bayes nets to analyze the probability that you’ve contracted the mumps. You first think about the following two factors: - You think you have immunity from the mumps (+i) due to being vaccinated recently, but the vaccine is not completely effective, so you might not be immune (−i). - Your roommate didn’t feel well yesterday, and though you aren’t sure yet, you suspect they might have the mumps (+r).

Denote these random variables by I and R. Let the random variable M take the value +m if you have the mumps, and −m if you do not. You write down the following Bayes net to describe your chances of being sick:

I P(I)

  • i 0. ˗i 0.

R P(R)

  • r 0. ˗r 0.

I R M P(M|I,R) +i +r +m 0 +i +r ˗m 1. +i ˗r +m 0 +i ˗r ˗m 1. ˗i +r +m 0. ˗i +r ˗m 0. ˗i ˗r +m 0. ˗i ˗r ˗m 0.

I

M

R

(a) (2 pt) Fill in the following table with the joint distribution over I, M , and R, P (I, M, R).

I R M P (I, R, M )

+i +r +m 0

+i +r −m

+i −r +m 0

+i −r −m

−i +r +m 0.

−i +r −m 0.

−i −r +m 0.

−i −r −m 0.

(b) (2 pt) What is the marginal probability P (+m) that you have the mumps?

(c) (3 pt) Assuming you do have the mumps, you’re concerned that your roommate may have the disease as well. What is the probability P (+r | + m) that your roommate has the mumps given that you have the mumps? Note that you still don’t know whether or not you have immunity.

You’re still not sure if you have enough information about your chances of having the mumps, so you decide to include two new variables in the Bayes net. Your roommate went to a frat party over the weekend, and there’s some chance another person at the party had the mumps (+f ). Furthermore, both you and your roommate were vaccinated at a clinic that reported a vaccine mix-up. Whether or not you got the right vaccine (+v or −v) has ramifications for both your immunity (I) and the probability that your roommate has since contracted the disease (R). Accounting for these, you draw the modified Bayes net shown on the right.

I

M

R

V F

(d) (5 pt) Circle all of the following statements which are guaranteed to be true for this Bayes net:

(i) V ⊥⊥ M | I, R

(ii) V ⊥⊥ M | R

(iii) M ⊥⊥ F | R

(iv) V ⊥⊥ F

(v) V ⊥⊥ F | M

(vi) V ⊥⊥ F | I

While your sampling method has worked fairly well in many cases, for rare cases (like species that can’t sense sound) your results are less accurate as rejection sampling rejects almost all of the data. You decide to use likelihood weighting instead. The conditional probabilities of the Bayes net are listed below.

C M N D P( D | C , M , N )

+c +m +n +d 0. +c +m +n −d 0. +c +m −n +d 0. +c +m −n −d 0. +c −m +n +d 0. +c −m +n −d 0. +c −m −n +d 0. +c −m −n −d 0. −c +m +n +d 0. −c +m +n −d 0. −c +m −n +d 0. −c +m −n −d 0. −c −m +n +d 0. −c −m +n −d 0. −c −m −n +d 0. −c −m −n −d 0.

S M P( M | S )

+s +m 0. +s −m 0. −s +m 0. −s −m 0.

S N P( N | S )

+s +n 0. +s −n 0. −s +n 0. −s −n 0.

S P( S )

+s 0. −s 0.

C P( C )

+c 0. −c 0.

You now wish to compute the probability that a species that has no sound-sensing (−s) or dancing (−d) nonetheless has music (+m), using likelihood weighting. I.e., you want P (+m | −s, −d).

(b) (2 pt) You draw the samples below, using likelihood weighting. For each of these samples, indicate its weight.

S C M N D weight

−s +c +m +n −d box filler

−s +c −m −n −d

−s −c −m +n −d

−s +c +m +n −d

(c) (2 pt) Compute the answer to your query, P (+m | −s, −d), using likelihood weighting with these samples.