You are on page 1of 15

18 February 2016/R2

Name:

Group:

Pages:

Exam in Introduction to Artificial Intelligence


Time: 3 hours. This exam is worth 90 points. Each point represents two minutes of time. Use the
point totals as a guide for budgeting your time. Use all your 180 minutes.
Read exercises carefully. Be sure you understand exactly what is required. To assure fairness among
you, questions are not allowed.
Write each exercise on a separate paper! At the end of the exam, order the exercises.
The exam is closed-book, closed-notes, closed-phones, closed-friends, open-mind. Write clearly; unreadable = wrong! If we observe any attempt of deception, the whole exam will be evaluated to
0.
Available Points
Achieved Points

Exercise 1
25

Exercise 2
20

Exercise 3
20

Exercise 4
25

Sum
90

1. Search. Consider the route-finding problem of computing the cheapest path from Buffalo to Utica.
For the straight-line distance heuristic, draw the search tree after expansion of each node until the
termination of the algorithm for: (Trasati urmatorii algoritmi cu starea initiala Buffalo si finala Utica.)

(a) Uniform cost search (label all nodes with their g values). What is the solution found by the
algorithm? Assume no cycles. (Afisati arborele, valoarea g pentru fiecare nod si solutia pentru
algoritmul de cautare cu cost uniform).
Solution: Step 0:
Buffalo (g=0)
Step 1:
Buffalo

Batavia (g=20)
Step 2:

Lockport (g=15)

Olean (g=30)

(5)

Buffalo

Batavia (g=20)

Lockport

Olean (g=30)

Step 3:
Buffalo

Rochester (g=50)

Batavia

Lockport

Syracuse (g=35)

Ithaca (g=60)

Olean (g=30)

Step 4:
Buffalo

Rochester (g=50)

Batavia

Lockport

Olean (g=30)

Syracuse (g=35)

Ithaca (g=60)

Binghamton (g=90)

Step 5:
Buffalo

Rochester (g=50)

Ithaca (g=40)

Batavia

Lockport

Olean (g=30)

Syracuse

Ithaca (g=60)

Binghamton (g=90)

Utica (g=100)

The algorithm stops when the goal is reached.


Solution: Buffalo, Batavia, Syracuse, Utica.
(b) Assume that the uniform cost algorithm found a path with g=100 and the frontier contains the
nodes Rochester (g=50), Ithaca (g=40), Binghamton (g=90). Does the algorithm continue, hoping
to identify a better path? (Presupunand ca este gasita o cale cu g=100 iar frontiera contine nodurile
Rochester (g=50), Ithaca (g=40), Binghamton (g=90), algoritmul se va opri sau va continua in
speranta gasirii unui drum mai bun?)
Solution: It stops because uniform cost search is optimal.
No better path will be found, as the following expansion illustrates:

(2)

Step 6:

Buffalo

Rochester (g=50)

Batavia

Lockport

Olean (g=30)

Syracuse

Ithaca (g=60)

Binghamton (g=90)

Ithaca (g=40)

Utica (g=100)

Binghamton (g=70)

Step 7:

Buffalo

Rochester (g=50)

Oswego
(g=100)

Batavia

Lockport

Olean (g=30)

Syracuse

Ithaca (g=60)

Binghamton (g=90)

Ithaca
(g=40)

Binghamton (g=70)

Step 8:

Utica
(g=100)

Buffalo

Rochester

Oswego
(g=100)

Batavia

Lockport

Olean

Syracuse

Ithaca

Binghamton (g=90)

Syracuse
(g=95)

Binghamton (g=90)

Utica
(g=100)

Ithaca

Binghamton (g=70)

Step 9:

Buffalo

Rochester

Oswego
(g=100)

Batavia

Lockport

Olean

Syracuse

Ithaca

Binghamton (g=90)

Syracuse
(g=95)

Binghamton
(g=90)

Utica
(g=100)

Ithaca

Binghamton

Olean
(g=130)

Step 10:

Oneonta
(g=110)

Buffalo

Rochester

Oswego
(g=100)

Batavia

Lockport

Olean

Syracuse

Ithaca

Binghamton (g=90)

Syracuse
(g=95)

Binghamton
(g=90)

Utica
(g=100)

Ithaca

Olean
(g=150)

Binghamton

Olean
(g=130)

Oneonta
(g=130)

Oneonta
(g=110)

Step 11:

Buffalo

Rochester

Oswego
(g=100)

Batavia

Lockport

Olean

Syracuse

Ithaca

Binghamton

Syracuse
(g=95)

Ithaca
Oneonta
Binghamton
(g=120)
(g=130)

Utica
(g=100)

Ithaca

Olean
(g=150)

Bingha
mton
Olean
(g=130)

Step 12:

Oneonta
(g=110)

Oneonta
(g=130)

Buffalo

Rochester

Oswego
(g=100)

Batavia

Lockport

Olean

Syracuse

Ithaca

Binghamton

Syracuse

Ithaca
Oneonta
Binghamton
(g=120)
(g=130)

Utica
(g=160)

Olean
(g=150)

Utica
(g=100)

Ithaca

Bingha
mton
Olean
(g=130)

Oneonta
(g=130)

Oneonta
(g=110)

(c) Greedy best-first search (label all nodes with their h values). What is the solution found by the
algorithm? (Afisati arborele, valoarea h pentru fiecare nod si solutia pentru algoritmul de cautare
greedy best first).
Solution: Step 0:
Buffalo (h=85)
Step 1:
Buffalo

Batavia (h=75)

Lockport (h=90)

Olean (h=100)

Step 2:
Buffalo

Rochester (h=55)
Step 3:

Batavia

Lockport (h=90)

Syracuse (h=65)

Ithaca (h=90)

Olean (h=100)

(5)

Buffalo

Rochester

Batavia

Lockport (h=90)

Syracuse (h=65)

Ithaca (h=90)

Olean (h=100)

Oswego (h=30)
Step 4:
Buffalo

Rochester

Batavia

Lockport (h=90)

Syracuse (h=65)

Ithaca (h=90)

Olean (h=100)

Oswego

Utica
Solution: Buffalo, Batavia, Rochester, Oswego, Utica
(d) A* search (label all nodes with their f values). What is the solution (list of visited cities) found
by the algorithm? (Afisati arborele, valoarea f pentru fiecare nod si solutia pentru algoritmul de
cautare A*).
Solution:
Buffalo (f=85)
Step 1:
Buffalo

Batavia (f=95)
Step 2:

Lockport (f=105)

Olean (f=130)

(5)

Buffalo

Rochester (f=105)

Batavia

Lockport (f=105)

Syracuse (f=100)

Ithaca (f=150)

Olean (f=130)

Step 3:
Buffalo

Rochester (f=105)

Batavia

Lockport (f=105)

Syracuse

Ithaca (f=150)

Ithaca (f=160)

Olean (f=130)

Utica (f=100)

Solution: Buffalo, Batavia, Syracuse, Utica.


(e) If f (s), g(s) and h(s) are all admissible heuristics then which of the following are also guaranteed
to be admissible heuristics: (Daca f (s), g(s) si h(s) sunt euristici admisibile, care din urmatoarele
euristici sunt de asemenea admisibile?)
f (s) + g(s) + h(s)

f (s)/6 + g(s)/3 + h(s)/2

min(f (s), g(s), h(s))

max(f (s), g(s), h(s))

f (s)/3 + g(s)/3 + h(s)/3


f (s) g(s) h(s)

min(f (s), g(s) + h(s))


max(f (s), g(s) + h(s))

Solution: Taken from MIT FINAL 2014.


"In order to guarantee that a function of admissible heuristics is still admissible, the expression
must be less than or equal to the max of the heuristics. Sums and products do not satisfy these,
so bubbles 1, 6, and 8 all immediately fail. Bubbles 3, 4, and 7 all work because the max of
admissible heuristics is still admissible, as is the min of an admissible heuristic and anything
else. Bubble 5 is the average of the heuristics, so it must be less than the max, and is thus
admissible. Lastly, bubble 2 is a weighted average, and is thus also less than the max, and is
thus admissible."
2. Satisfiability. Our department offers the following forth year classes: JAVA, CPP, ARC, HAR, KBS.
The chief of department decided that: i) there should be at least one programming class, ii) at least one
class on computer architecture, iii) at least one class on artificial intelligence, and iv) there should be
no more than one class on each topic. In addition, CPP and ARC are designed to be given together,
so it does not make sense to include one without the other. JAVA and CPP are programming classes,
ARC and HAR are on computer architecture, and KBS is on artificial intelligence. (Oferta de cursuri

(8)

pentru anul 4 include JAVA, CPP, ARC, HAR, KBS. Constrangerile pe orar sunt: i) cel putin un curs
de programare, ii) cel putin un curs de IA, iii) nu mai mult de un curs din acelasi domeniu. CPP si
ARC trebuie predate impreuna. JAVA si CPP sunt cursuri de programare, ARC si HAR de arhitectura
calculatoarelor, iar KBS de IA.)
(a) Encode the above search problem in propositional logic. Use the first letter of the class. (Translatati
in logica propozitionala. Utilizati ca notatie prima litera din numele cursului).

(5)

Solution: The constraint that there should be at least one class in each topic is expressed as
(J C) (H A) K
The constraint that no more than one class from each area is included is formalised as
(J C) (H A)
The constraint that CPP and ARC should be given together is expressed as
CA
(b) Convert to CNF. (Convertiti in CNF).

(5)

Solution:
The first sentence is in CNF.
Applying de Morgan rule on the second constraint we get:
(J C) (H A)
C A is the same with (C A) (A C) which becomes
(C A) (A C)
(c) Chief of department suggested to apply the Davis Putnam SAT solving algorithm. Help the chief
of department to take a consistent decision, by tracing the algorithm. For each recursive call, state
pure symbols and unit clauses. State the solution returned. Which are the classes that should
appear in the fourth year? Assume the order of symbols: J, C, H, A, K. (Trasati algoritmul DavisPutnam. Pentru fiecare apel recursiv, indicati literalii puri si clauzele unitate. Aratati solutia si
numele cursurilor care vor figura in orar. Ordinea simbolurilor este J, C, H, A, K.)
Solution: The clauses are:
J C
H A
K
J C
H A
C A
A C
First call: There are no pure symbols. There is a unit clause, hence K = 1.
The current model: K = 1

(10)

The resulted clauses are:


J C
H A
J C
H A
C A
A C
Second recursive call: there are no pure symbols and no unit clauses. We call the algorithm
with the first variable in the specifeid order, that is J.
The current model: K = 1, J = 1.
The resulted clauses are: H A
C
H A
C A
A C
Third recursive call: there are no pure symbols. There is a unit clause C. Hence we assign
false to C.
The current model becomes: K = 1, J = 1, C = 0.
The resulted clauses are: H A
H A
A
Forth recursive call: there are no pure symbols. There is a unit clause A. Hence we assign
false to A.
The current model becomes: K = 1, J = 1, C = 0, A = 0.
The resulted clauses are:
H
Fifth recursive call: we assign true to H and call the algorithm with the empty list of clauses
and symbols.
The model is: K = 1, J = 1, C = 0, A = 0, H = 1.
The classes are: KBS, JAVA and HAR.
3. Searching with observations. Consider an agent which is trying to escape from a labyrinth with 8
rooms: room1 to room8 . The agent cannot see where it is, but it can feel the walls. Its percepts are
subsets of {WN, WW, WE, WS, Ex} which stand for Wall to the North, Wall to the West, Wall to
the East, Wall to the South, and Exit. The actions available to the agent are moving North, West,
East and South. The actions of moving North and South are deterministic and move the agent one room
to the North or one room to the South if there exists such a room, otherwise leave the agent where it
is. The actions of moving West and East are non-deterministic: they move the agent to some room to
the West or to the East, not necessarily to the next one. (Agentul doreste sa iasa din labirintul din
figura. Perceptele sale sunt submultimi ale multimii {WN, WW, WE, WS, Ex}, unde elementele sunt
prescurtari pentru perete la nord, vest, est, sud, respectiv iesire. Actiunile posibile sunt deplasarea la

nord, vest, est, sud. Deplasarile la nord si sud sunt deterministe, agentul ajungand cu o casuta mai
la nord, respectiv sud daca labirintul permite. Daca nu, agentul ramane pe pozitia curenta. Actiunile
West si East sunt nedeterministe: agentul se deplaseaza la vest, respectiv est, dar nu neaparat in casut
a vecina.)
North
room1 room2 room3 room4
West

East
room5 room6 room7 room8
South

(a) Formalise the percepts for each state P ercepts(roomi ), and the Results(roomi , action). You
can use index i for compact representation of similar pairs of states and actions. For instance
P ercept(room1 ) = {W N, W W } and Results(roomi , N orth) = {roomi } f or i {1, 2, 3, 4}. (Formalizati perceptele pentru fiecare stare P ercepts(roomi ) si Results(roomi , action).)

(2)

Solution:
P ercept(room1 ) = {W N, W W }
P ercept(room2 ) = {W N }
P ercept(room3 ) = {W N }
P ercept(room4 ) = {W N, W E}
P ercept(room5 ) = {W S, W W }
P ercept(room6 ) = {W S}
P ercept(room7 ) = {W S}
P ercept(room8 ) = {W S, W E, Ex}
Results(roomi , N orth) = {roomi } f or i {1, 2, 3, 4}
Results(roomi , N orth) = {roomi4 } f or i {5, 6, 7, 8}
Results(roomi , South) = {roomi+4 } f or i {1, 2, 3, 4}
Results(roomi , South) = {roomi } f or i {5, 6, 7, 8}
Results(roomi , W est) = {roomi } f or i {1, 5}
Results(roomi , W est) = {roomi1 } f or i {2, 6}
Results(roomi , W est) = {roomi1 , roomi2 } f or i {3, 7}
Results(roomi , W est) = {roomi1 , roomi2 , roomi3 } f or i {4, 8}
Results(roomi , East) = {roomi } f or i {4, 8}
Results(roomi , East) = {roomi+1 } f or i {3, 7}
Results(roomi , East) = {roomi+1 , roomi+2 } f or i {2, 6}
Results(roomi , East) = {roomi+1 , roomi+2 , roomi+3 } f or i {1, 5}

(b) The agent starts in total ignorance of where it is. Define its initial belief state b0 . (Agentul este
initial total ignorant legat de pozitia in care se afla. Definiti starea initiala de credinte.)

(2)

Solution: b0 = {room1 , room2 , room3 , room4 , room5 , room6 , room7 , room8 }


(c) Define updated belief state b1 = U pdate(b0 , {W N }}. (Definiti starea de credinte actualizate b1 =
U pdate(b0 , {W N }}.)

(2)

Solution: b1 = U pdate(b0 , {W N }} = {room2 , room3 }


(d) Define Results(b1 , East). (Definiti Results(b1 , East).)

(6)

Solution: b1 = P redict(b1 , East) = {room3 , room4 }


Possible percepts for b1 are:
2 = P ercept(room3 ) = {W N }
and
3 = P ercept(room4 ) = {W N, W E}
Hence
b2 = U pdate(b1 , 2 ) = {s b1 : 2 = P ercept(s)} = {room3 }
b3 = U pdate(b1 , 3 ) = {s b1 : 3 = P ercept(s)} = {room4 }
Therefore:
Results(b1 , East) = {b2 , b3 } = {{room3 }, {room4 }}
(e) Draw two solution subtrees of the AND-OR search tree for this problem, starting in belief state b1 ,
with the goal to be in room8 . (Desenati doua solutii sub forma de subarbori din arborele de cautare
AND-OR pentru aceasta problema. Starea initiala este b1 , iar telul room8 .)
Solution: One solution is given the sequence of actions: 1. East 2. East or South 3. South
b1
[r2 , r3 ]

b2
[r3 ]

b3
[r4 ]

b3
[r4 ]

b4
[r8 ]

South
b4
[r8 ]
The second solution could be: going South first and then East.
4. Partial Order Planning.

(8)

(a) Explain how partial order planning works in English and pseudocode. Dont forget to explain
issues such as: open condition, clobberer, operators on partial plans. (Explicati cum functioneaza
planificarea cu ordonare partiala in limbaj natural si pseudocod. Explicati notiunile: conditie
deschisa, suprascriere de literali, operatori pe planuri partiale.)

(10)

Solution: Part of these issues were discussed during lecture on Classsical Planning. Part of
them are briefly introduced in section 10.4.4 AIMA, 3rd edition.
Partial ordered plans are created by a search through the space of partial plans. Partial plans
always have a Start step which has the initial state description as its effect, and a F inish
step which has the goal description as its precondition. Partial plans have a list of temporal
constraints ai aj stating that action ai should precede action aj . The algorithm uses a
list of causal links from outcome of one step to precondition of another. It gradually moves
from incomplete/vague plans to complete, correct plans and backtracks if an open condition is
unachievable or if a conflict (flaw) is unresolvable. At every step, the algorithm make the least
commitment possible to fix the flaw.
An open condition is a precondition of a step not yet causally linked.
A plan is complete if every precondition is achieved.
A precondition is achieved if it is the effect of an earlier step and no possibly intervening step
undoes it.
A clobberer is a potentially intervening step that destroys the condition achieved by a causal
link. It should be either moved before the first step or after the second.
Operators on partial plans are:
add a link from an existing action to an open condition
add a step to fulfill an open condition
order one step wrt another to remove possible conflicts
Gradually move from incomplete/vague plans to complete, correct plans. Backtrack if an open
condition is unachievable or if a conflict is unresolvable.
(b) Solve the following blocks world problem below using partial order planning. Trace the search
from the initial empty plan to a complete solution. State the current steps, links, orderings, open
conditions, and clobberers at each step. The actions are: (Rezolvati utilizand planificare cu ordonare
partiala. Trasati cautarea de la planul initial gol la solutia completa. Aratati pasii, legaturile,
relatiile de ordine, conditiile deschise, suprascrierile de literali.)
Actions
M ove(b; x; y):
Precond: On(b, x) Clear(b) Clear(y)
Effect:
On(b, y) Clear(x) On(b, x) Clear(y)
M ovetotable(b; x):
Precond: On(b, x) Clear(b)
Effect:
On(b, T able) Clear(x) On(b, x)
The initial state is: On(B, A) On(A, T able) On(C, T able) Clear(B) Clear(C).
The goal is:
On(C, B) On(B, T able).
Solution: Steps = {Start, F inish} where the effect of Start is: On(B, A) On(A, T able)
On(C, T able) Clear(B) Clear(C),
and the F inish step has On(C, B) On(B, T able) as its precondition.

(15)

Steps
= {Start, F inish}
Links
= {}
Orderings
= {}
Open conditions = On(C, B), On(B, T able) (for the Finish step).
Suppose you choose the first open condition as a selected subgoal. An action which would make
it true is M ove(C; x; B). You add it as a step to the partial plan, and a link from it to F inish:
Steps
Links
Orderings
Open conditions

=
=
=
=

{Start, M ove(C, x, B), F inishg}


{M ove(C, x, B) On(C,B) F inish}
{Start M ove(C, x, B), M ove(C, x, B) F inish}
On(B, T able) (for the Finish step),
On(C, x), Clear(C), Clear(B) (for the M ove(C, x, B) step).

There are no clobberers.


Suppose you choose the first open condition as a selected subgoal. An action which would make
it true is M ovetotable(B, y). You add it as a step to the partial plan, and a link from it to
F inish:
{Start, M ove(C, x, B), M ovetotable(B, y), F inish}
{M ove(C, x, B) On(C,B) F inish,
M ovetotable(B, y) On(B,T able) F inish}
Orderings
= {Start M ove(C, x, B), M ove(C, x, B) F inish,
Start M ovetotable(B, y), M ovetotable(B, y) F inish}
Open conditions = On(C, x), Clear(C), Clear(B) (for the M ove(C, x, B) step),
On(B, y), Clear(B) (for the M ovetotable(B, y) step).
There is also clobbering: M ove(C, x, B) destroys a precondition for M ovetotable(B, y) (Clear(B)).
Since you cannot put M ovetotable(B, y) after F inish, you put it before M ove(C, x, B):
Steps
Links

=
=

{Start M ove(C, x, B), M ove(C, x, B) F inish, Start M ovetotable(B, y),


M ovetotable(B, y) F inish, M ovetotable(B, y) M ove(C, x, B)}
Now you can deal with the open conditions by adding a link from Start to all of them: On(C, x)
with x = T able, Clear(C), Clear(B), On(B, y) with y = A is made true by Start.
The resulting complete plan is as follows:
Steps
= {Start, M ove(C, T able, B), M ovetotable(B, A), F inish}
Links
= {M ove(C, T able, B) On(C,B) F inish,
M ovetotable(B, A) On(B,T able) F inish,
Start On(C,x),Clear(C),Clear(B) M ove(C, T able, B),
Start On(B,y),Clear)B) M ovetotable(B, A)}
Orderings
= {Start M ove(C, x, B), M ove(C, x, B) F inish,
Start M ovetotable(B, y),
M ovetotable(B, y) F inish, M ovetable(B, y) M ove(C, x, B)}
Open conditions = On(C, x), Clear(C), Clear(B) (for the M ove(C, x, B) step),
On(B, y), Clear(B) (for the M ovetotable(B, y) step).
Orderings

Anonymous Questionaire
Write on an anonymous paper your opinion regarding:
1. What did you like at this course?

2. Identify what you found easiest and most difficult about this course (or during learning) and why.
3. Identify what you found easiest and most difficult during laboratory work and why.
4. What are the changes that would most improve the course?
5. What would you say to students considering taking the course?