CS325 Artificial Intelligence - Spring 2013 Midterm Solution Guide
CS325 Artificial Intelligence - Spring 2013 Midterm Solution Guide
Instructions
Total points: 50 (25% of course grade, subject to change)
1. Use your own empty sheets to write your answers. I left a lot of free space on this
handout so you can use it for scribbling.
2. On the top of your sheets, write your name and name of students sitting next to
you.
3. You don’t need to repeat the questions on your answer sheets.
4. There are some formulas at the end on page 11. They are referenced from questions
that need them.
(nF) shows popularity of question – n students chose it.
I. Verbal Questions
(10 points) Pick and answer ANY 5 of the following 12 questions.
1. (9F)How do you get started if you wanted make an intelligent agent to solve a
problem? What are the first things you need for building an agent?
Answer: Must define PEAS: Performance, Environment, Actuators, and Sensors.
2. (10F)List some environmental properties that are important for intelligent agents.
Describe the properties of the environment for the Mars Rover.
Answer: Fully/partially observable, discrete/continuous, single/multi agent, stochas-
tic/deterministic, adversarial, dynamic/static. Mars rover: partially observable (be-
cause sensors are limited), single agent, continuous, stochastic (e.g., weather events),
dynamic (slips?), non-adversarial.
3. (18F)Compare breadth-first, depth-first, cheapest-first and A* algorithm strategies
and benefits.
Answer: Breadth-first: siblings first, then go deeper. Complete only if breadth, b, is
finite. Non-optimal if cost not unitary. Time and space complexity are both O(bd ).
Depth-first: go to deeper nodes first, then go to next branch. Complete only if
depth, d, is finite and there are no loops. Non-optimal as in breadth-first. Space
complexity is O(bd), which is smaller than breadth-first.
Cheapest-first: Like breadth first, but minimizes cost of path taken so far. Complete
and optimal if b is finite.
A*: Adds heuristic function in addition to cost. Complete and optimal if heuristic
is admissable.
1
4. (8F)What is the difference between conditional and joint probabilities between two
random variables?
Answer: Conditional probability, P (A|B), is the probability of A when we know
that B happened. Joint probability, P (A, B), is the probability of both events
happening. Only if the two are independent, A⊥B, then P (A, B) = P (A)P (B).
5. (10F)What type of questions can you answer with a Bayes Net?
Answer: When many factors contribute in probabilitic fashion to an outcome. We
can both make predictions about the outcome and diagnose causes.
11. (2F)What’s the difference between Markov Decision Processes (MDPs) and Rein-
forcement Learning (RL)?
Answer: MDPs can find the way to known reward locations in a fully observable
environment. In contrast, RL can operate in a partially-observable environment to
discover reward locations.
12. (1F)What is the dilemma between exploration and exploitation for an RL agent?
Answer: In a partially-observable environment, the RL agent needs to explore to
find the rewards, however it should also know when to stop exploring and pursuing
the rewards. Otherwise, it may waste its resources during unnecessary exploration.
2
(a) Size of state space
Answer: Agent’s possible location (3) × possible dirt configurations (23 ) =
3 × 23 = 24 states.
(b) Inital configuration and goal test
Answer: Choose one of the 24 states as described above as initial state. Goal
states are the ones without any dirt in any of the locations, irrespective of
where the agent is located.
(c) Transition function
Answer: Agent can move left or right, which affects its location. Agent can
suck dirt, which affects existence of dirt.
(d) Adequate tree-search algorithm and its complexity for width n and depth d
Answer: Without any costs defined, we can use breadth-first search with time
and space complexity of O(nd ).
(a) P (A, B)
Answer: Probability of both A and B happening.
(b) P (A|B, C)
Answer: Probability of A given that we know B and C to be true or false.
(c) A⊥B|C
Answer: A is independent of B conditional on knowing outcome of C.
(d) P (A|B, C) = P (A|B)
Answer: A is independent of C conditional on knowing outcome of B. We do
not know if A is independent of C in general.
(e) P (A, B, C) = P (A|B, C)P (B|C)P (C)
(explain this and also draw it as a Bayes Net)
A
Answer: C is independent; B depends on C; and, A
depends on both B and C.
B C
3. (4F)(HW3 – 10 points) Briefly describe what each of the following means. Explain
whether it is an unsupervised or supervised learning scheme, its advantantages and
disadvantages, and indicate whether it employs a hill climbing (or gradient descent)
method, which is subject to local minima.
3
(d) Support Vector Machines (SVM)
Answer: Supervised learning algorithm with transformation such that it con-
verges faster. While still suffering from local minima, it performs much better
than MLPs.
(e) Genetic/Evolutionary Algorithms
Answer: Supervised learning algorithm with no gradient descent. It can find
global minimum, but takes longer to find solution.
4. (20F)(HW4 – 10 points) Select and write one set of true/false values for the vari-
ables A, B, C, D and then answer whether the following logic sentences are true or
false. Also indicate if the sentence is valid, satisfiable or unsatisfiable.
Answer: For A = t, B = t, C = t, D = t;
(a) (A ∧ B) ∨ (¬C ∨ ¬D)
Answer: True, satisfiable.
(b) A ⇒ B
Answer: True, satisfiable.
(c) A ∧ C ⇒ B ∨ D
Answer: True, satisfiable.
(d) (¬B ⇒ ¬A) ⇔ (¬A ∨ B)
Answer: True, valid.
(e) (B ⇒ ¬A) ⇔ (¬C ∧ D)
Answer: True, satisfiable.
4
III. Problem Solving Questions
(20 points) Pick and choose questions that add up to 20 points. You are allowed +10
bonus points if you do more, which will count only WITHIN the points of this exam.
That is, you cannot get more than 50 points from this exam.
LaVist 1
N
a
Shep (N)
Dr
0.5
1
ui
1
0.5
) 0 0.5
d
l (N .5
0.5 il .5
0.5 Clairmont
M 0
0.
liff n Ma
arc
5
o
Bri u st son
5 Mil
0.5
o .
Cl
1 H 0 0. l (N
5
ift
)
on
H
ay
0.
go
2 0.3
od
0.
5 (N
1
1 )
N Decatur 0.5 0.5
Figure 1: A road map of the Emory vicinity. Numbers show approximate distance in
miles. See Question 1 for details.
1. (19F)(HW1 – 10 points) Starting from the Clairmont Rd. and North Druid Hills
intersection on map in Figure 1, manually simulate the FIRST THREE ITERA-
TIONS of the uniform-cost (cheapest-first) algorithm to target one of the following
destinations:
Write down what you add and remove from the frontier at each step and how you
select which intersection to choose next.
Answer: Traverse the map and manipulate the frontier:
5
Legend
0.6 0.5 0.2
S: Getting sick from the
F H R flu.
P (G) R H G: Getting the flu virus.
0.8 T T R: Rare form of the flu
T G 0.3 F T virus.
0.7 T F
P (T ) F H: Getting the flu shot.
0.9 F F
0.5 T
T: Using Tamiflu antiviral
0 F S medicine.
P (S) T G F: Availability of Tamiflu.
0.6 T T
0.9 F T
0.2 T F
0 F F
Figure 2: A fake flu Bayes net for catching the flu. See text for details.
2. (16F)(HW2 – 10 points) Based on the Bayes net in Figure 2, solve the probability
formula (by explaining each step) described by the following verbal question:
”What’s the probability of getting sick from with the rare form of the flu
if you knew that Tamiflu was not available?”
Answer: I also gave points for a second interpretation for the verbal question:
(a) P (S|¬F, R), which is the probability of getting sick given that we know it’s
the rare form and Tamiflu was unavailable.
i. Eliminate F completely because P (T |¬F ) is impossible:
P (S|¬F, R) = P (S|¬T, R) .
iii. Use the chain rule and enumeration over possible states of G:
X
P (S|¬T, R) = P (S|¬T, g)P (g|R)
g
= 0.9 × 0.75 = 0.675 .
6
ii. Enumerate the full joint probability:
X
P (S, R|¬T ) = P (S, R, ¬T, h, g)
g,h
X
= P (S|¬T, g)P (g|R, h)P (h)P (R)
g,h
7
Uses
Shopper Milk Bread Beer Soda Water Eggs Price
coupons?
S0 0 0 1 1 0 0 $10 1
S1 1 0 0 1 1 1 $42 0
S2 1 1 1 0 1 1 $12 1
S3 0 1 1 1 1 0 $35 0
S4 0 1 0 0 1 1 $5 1
3. (5F)(HW3 – 10 points) Simulate the k-Means clustering algorithm (see page 11)
for two iterations to find two clusters (k = 2) in the data of Table 1. Do not use
the “Shopper,” “Price,” or “Uses coupons?” columns, and start with initial cluster
centers of respectively all zeros and all ones.
Answer:
C1 = (1, 1, 1, 1, 1, 1) C2 = (0, 0, 0, 0, 0, 0)
S1 S0
(a) Iteration 1:
S2 S4 (either into C1 or C2 )
S3
C1 = ( 32 , 23 , 32 , 32 , 1, 23 ) C2 = (0, 21 , 12 , 12 , 12 , 12 )
S1 (2.3) S0 (2.5)
(b) Iteration 2:
S2 (2) S4 (2.5)
S3 (2)
(a) Start with a weight vector, w = [3.0, 6.5, 8.0, 1.0, 5.0, 7.0, −3.0] and threshold,
T = 9.3. Evaluate any three rows in table and report the weighted sum of
the inputs and the perceptron output, and compare it to the expected output.
Look into the weights and discuss which column(s) were most influencial in
the perceptron’s right and wrong decisions.
Answer:
Example, evaluate:
Multiply by weights Guess
S0 · w = 0 + 0 + 8 + 1 + 0 + 0 − 30 = −21 > 9.3? 0 Wrong
S1 · w = 3 + 0 + 0 + 1 + 5 + 7 − 126 = −110 > 9.3? 0 Correct
S2 · w = 3 + 6.5 + 8 + 0 + 5 + 7 − 36 = −6.5 > 9.3? 0 Wrong
Price column is the most influential by far. Other weights need to be trained
more to overcome it.
(b) Then, choose one row from the table and use its values to update the perceptron
weight vector. Use a training rate parameter of α = 0.5 to update the weights.
What changed?
Answer: Use S0 inputs, only non-zero inputs will cause a change:
Weight update Change?
w2 = 8 + 0.5 × (1 − 0) × 1 = 8.5 increase
w3 = 1 + 0.5 × (1 − 0) × 1 = 1.5 increase
w6 = −3 + 0.5 × (1 − 0) × 10 = 2 increase
Large increase in price column as expected from 4a.
8
i. ∀a, b Loves(a, b) ∧ Loves(b, a) ⇒ Happy(a) ∧ Happy(b)
ii. ∀a, b, c Loves(a, b) ∧ Loves(b, c) ∧ ¬(a = c) ⇒ Unrequited(a, b) ∧ Sad(a)
iii. ∃a Happy(a)
iv. ∃a Sad(a)
5. (13F)(HW4 – 10 points) To the knowledge base (KB) given in Table 2, add THREE
of the following sentences and then answer if the query “Unrequited(John, N ancy)?”
is true, false, or unknown. Explain your logic. Make sure that the KB is consistent;
that is, it includes no contradicting knowledge.
According to ii.
Loves(M ary, John)∧Loves(John, N ancy)∧¬(M ary = N ancy) ⇒ Unrequited(M ary, John)∧Sad(M ary)
iii. and iv. are also satisfied because Sad(M ary) and Happy(M ary). Although
unintuitive, the KB is consistent because it doesn’t say same person cannot be
both happy and sad.
(b) Other selections can lead to satisfying iii. or iv. but not both. As long as it
was unknown, I accepted it as consistent.
9
Game objective: Rules:
Swap the places of left arrow tiles
with right arrow tiles. →
I.
Board:
→ → → ← ← ←
→ ←
II.
Figure 3: A simple tile-moving game. You need to reach the objective by only using the
two rules. First rule says a tile can move in the direction of the arrow if its immediate
neighbor is a blank. The second rule says a tile can jump in its arrow direction over a tile
that points the reverse direction if the next tile is blank. Game credits: Machinarium.
6. (4F)(HW4 – 10 points) Consider the tile-moving game in Figure 3. Write the action
schema for the game in classical planning (see page 11). Define the game board, the
tiles, and then write the two rules. Would a depth-first or breadth-first algorithm
work better for this task? Is it more advantageous to start from the initial state or
the goal state? Based on your answer to these questions, manually simulate the first
three steps of the solution by drawing the states from the initial board condition to
match and execute the rules by implementing the graph search.
Answer: Action schemas don’t use first-order logic, just simple parameterization of
variables in propositional logic. Define some predicates:
10
Appendix
1. k-Means clustering algorithm
2. Perceptron equations
y = fW (I)
N
X
sum = Ii Wi
i=1
(
1, if sum ≥ T
y=
0, if sum < T
The perceptron update rule for sample k and input j:
(a) Action
(b) Precondition
(c) Effect
Example:
Action(Fly(p, f rom, to),
Pre: At(p, f rom) ∧ P lane(p) ∧ Airport(f rom) ∧ Airport(to)
Eff: ¬At(p, f rom) ∧ At(p, to))
11