Professional Documents
Culture Documents
10
10
13
6
9
10
The evaluation function f(n) = d(n) + W(n), where d(n) is the cost of arriving at node n and
W(n) is the number of misplaced tiles, is used in conjunction with the A * algorithm to search
from the start node (left) to the goal node (right):
Start
Goal
3
4
8 3
2 1 4
7 6 5
2 8 3
1 6 4
7 5
2 8 3
1 4
7 6 5
2 8 3
7 1 4
6 5
Goal
5
2 8 3 Start
1 6 4
7
5
2 8 3
1
4
7 6 5
2
3
1 8 4
7 6 5
2 8 3
1 4
7 6 5
2 3
1 8 4
7 6 5
2 3
1 8 4
7 6 5
1 2 3
8 4
7 6 5
1 2 3
8
4
7 6 5
2 8 3
1 6 4
7 5
1 2 3
7 8 4
6 5
Use this evaluation function to search backward from the goal node to the start node. Where
would the backward search meet the forward search?
Exercise 1.5 (General Search)
Each of the following search trees has a distinctive structure and order of expansion which
can be produced by a particular search procedure. For each tree write the name of the
search procedure which can generate it. The possible names are: breadth first search, depth
first search and A (with non-zero g and h). Where applicable, the nodes are labelled with
the order in which they are expanded.
(b)
(c)
B
13
E
12
D
27
H
12
I
5
J
29
G
19
F
16
K
33
L
0
M
2
N
0
P
12
(a) For each iteration of algorithm A, show the lists OPEN and CLOSED. OPEN must be
ordered.
(b) How many nodes are expanded until the solution is found? How many are generated?
(c) If DFS is used, how many nodes are expanded until the solution is found? How many
are generated? (Expansion is performed from left to right)
Exercise 1.7 (Hill Climbing)
The diagram below depicts the cost of travelling between cities.
5
A
3
7
4
S
4
(a) Draw the search tree generated by the Hill-climbing procedure to reach the goal G
starting from S. Use the function f = cheapest road. What is the path? What is its cost?
(b) Draw the search tree generated by the GraphSearch procedure to reach the goal G
starting from S, using the following estimate of the cost from each node to the goal as a
heuristic function:
S
10
Indicate clearly the values of g, h, and f at each node. Also, indicate the order of expansion
of the nodes. What is the generated path? What is its cost?
Exercise 1.8
The game nim is played as follows: Two players alternate in removing one, two or three
coins from a stack initially containing 5 coins. The player who picks up the last coin loses.
Show by drawing the game graph, that the player who has the second move can always win.
Can you think of a simple characterisation of the winning strategy?
Exercise 1.9 ()
Consider a game tree with branching factor 2 and depth 5. Assume that it is turn to play,
and that the evaluation function at the leaf nodes is in increasing order from left to right,
such that its value for the leftmost node is 1, and for the rightmost node is 16 (the leaf nodes
are MAX nodes).
Conduct an search of this game tree, starting from leftmost-node-first. In your tree,
clearly indicate the propagation of the and values, the performed cut-offs and the
inspected leaf nodes.
Upon completion of the search, state the final backed-up value of the root node and the
recommended move (Left or Right). Also state the number of and cut-offs performed,
and the number of leaf nodes generated.
Exercise 1.10
Consider the following game tree, where MAX plays in the square positions and MIN plays
in the circles.
-2
(a) Conduct an search of this game tree, starting from leftmost-node to determine which
move should MAX make. Draw the resulting game tree so that only the visited nodes
appear in your diagram, i.e. without the nodes that are cut off. Indicate clearly the backed
up values of each node, the updates performed on the backed up values, the cut-offs and
the cut-offs you have performed.
Question 1 1996 Exam. History and Agent Structure
(Total 12 marks)
(a)
Name two influential figures in the field of AI who attended the Dartmouth College
workshop in the summer of 1956.
(2 marks)
(b)
Choose a domain that you are familiar with and write a PAGE (percept, action, goal,
environment) description of an agent for the environment.
(4 marks)
(c)
Characterise the environment as being (i) accessible or not, (ii) deterministic or not.
Explain your answers briefly.
(4 marks)
(d)
(2 marks)
(Total 10 marks)
(a)
What is the difference between a performance measure and a utility function?(4 marks)
(b)
While driving a motor car, which of the following is the best policy? (Explain your answer
in terms of cost and computational effort.)
(4 marks)
(i)
(ii)
(iii) Look in your mirrors and use your indicator only if you observe a car that can
observe you.
What kind of reasoning did you need to arrive at this driving policy?
(c)
(1 mark)
(1 mark)
Name two Artificial Intelligence researchers and describe their contribution to AI (in no
more than two lines for each) .
(4 marks)
(b)
Consider the following grid environment, where S is the start state and G is the goal state.
The arrows show possible movements between states, and there is a wall blocking some
transitions. For the purposes of a hill-climbing search algorithm, the goal state G has value
0.
(i) What is the estimated value of the start state using the Manhattan distance to the goal as
the metric?
(ii) What is the estimated value of the start state using the shortest distance to the goal as the
metric?
(iii) Why does this start state cause a problem for a hill-climbing algorithm using the
Manhattan distance as the metric?
(4 marks)
Question 3 1995 Exam Robbie's World.
(Total 10 marks)
Robbie the robot works in the kitchen. It can move from one location to another; it also can carry food from
one location to another. There are three locations: the table, the stove and the refrigerator. Right now,
Robbie is near the table, the soup is on the stove, and the orange juice is in the refrigerator. We would like
to have both the soup and the orange juice on the table.
This question involves describing a problem formulation for this cooking domain.
(a)
(b)
Give the operators. (These should be descriptions of the actions in terms of which state
will be reached by carrying out the action in a particular state.) (4 marks)
(c)
(1 mark)
(d)
(1 mark)
(e)
One heuristic for estimating the path cost is the cost of an exact solution to a relaxed
problem (one with less restrictions on the operators). Describe such a relaxed problem and
such a heuristic. Is this heuristic for the path cost of the full problem admissible?
(1 mark)
(3 marks)
Question 3. 1996 Exam. Search
(a)
(Total 20 marks)
A farmer is trying to cross a river with a fox, a chicken and a sack of grain. She has a
rowboat that he can use to carry at most one item at a time (plus herself) across the river.
Only the farmer can row the boat so she has to be with the boat in each of its trips across
the river. The farmer's problem is that she can't leave the fox alone with the chicken, or the
chicken alone with the sack of grain, at any time. For this question, you are to design a
state-space search approach to this problem.
(i) Design and describe an appropriate representation for a state in this search problem.
Show the initial state under your representation.
(2 marks)
(ii) Under your chosen representation, what is a goal state for the search problem?
(1 marks)
(iii) Give the operators in terms of the legal successors that will be reached by carrying out
the operator in the initial state.
(3 marks)
(iv) In general, what conditions need to be checked when generating the legal successors
of a state?
(2 marks)
(b)
Recall the 8-puzzle, which was described in lectures. (Take the goal state to be the one
where the blank is in the centre, the 1 in the top left, and the numbers increasing
clockwise around the square.) Here is an initial state of that puzzle:
1
8
7
2
5
6
4
(2 marks)
(ii) Draw the search graph starting from the above initial state, and finishing when the
goal state is selected for expansion.
For each node in your diagram, indicate the value f of that node. Also indicate on your
graph the order in which nodes are selected for expansion using a circled number. For
example, the initial state above will be labelled with f = 7 and is the first node selected, so
it will have a circled 1 next to it.
Ensure that your graph is a proper search graph (in particular, it should not contain
duplicate nodes, although it may contain multiple paths to a node).(10 marks)
Question 4 1995 Exam
(Total 15 marks)
Consider a hypothetical game with branching factor 2. It is MAX's turn to play. She is able to
evaluate a position 4 steps in advance. The following is a list of the value of the positions at the
bottom of the game tree, if they ever need to be evaluated.
node# 1
e(n)
9 10 11 12 13 14 15 16
13 8 14 11 5
2 20 6
0 13 8 10 16 15
(a)
Draw a game tree, as evaluated by MAX using the procedure, starting at the left-most
node first, so that only the expanded nodes appear in your diagram (i.e. without the nodes
that are cut off). Indicate clearly the backed-up value of each node and the updates
performed on the backup values.
(11 marks)
(b)
(1 mark)
(c)
(1 mark)
(d)
What is the best move for MAX and what is its backed-up value?
(2 marks)
Consider a hypothetical game with branching factor 2. It is MAX's turn to play. She is able to
evaluate a position 3 steps in advance. The following is a list of the value of the positions at the
bottom of the game tree, in case they ever need to be evaluated.
node# 1
e(n)
8 12 20 30 10 5 25 2
(a) Draw a game tree, as evaluated by MAX using the procedure starting at the left-most
node first, so that only the expanded nodes appear in your diagram (i.e. draw your diagram
without the nodes that are cut off).
(b) Clearly indicate the backed-up value of each node and the updates performed on these
values, the cut-offs and the cut-offs.
(a)
What is the best move for MAX and what is its backed-up value?
(d) Show formally that the solution facts follows from your description of the situation and
the axioms for PutOn.
[(x)person(x) [(y)mother(y,x)]]
(old(dog(Fido))
dog(Fido)old(Fido)
x [maththeory(x) x]
s[aristotlesaid(s) true(s)]
vdbutcher(b) dog(d)owns(b,d)
Exercise 2.7
Consider the following statements:
(1)
(2)
(3)
(4)
(2)
(3)
(4)
(2)
Students who are bright and work hard have high grades.
(3)
(4)
(5)
(6)
(a) Represent these sentences as predicate calculus formulas. Do not include studentas a
predicate, as it complicates the solution.
(b) Convert these FOPC sentences into Conjunctive Normal Form clauses.
(c) Use resolution to prove that Mary is a successful student. Indicate clearly the
substitutions you make.
Question 1 (1997 Exam). Short Answers
(c) Resolution in First-Order Predicate Calculus is a sound and complete inference procedure.
What does this mean in terms of a knowledge base?
(4 marks)
Question 5 (1995 Exam).
(b)
(Total 10 marks)
(Total 20 marks)
(2)
(3)
(4)
(a)
Using only the predicates read, literate, dolphin and intelligent, represent
these sentences in FOPC sentences.
(6 marks)
(b)
(c)
Use resolution to prove that sentence (4) follows from sentences (1), (2) and (3). Indicate
clearly the substitutions you make.
(8 marks)
(6 marks)
(a)
(1)
(2)
(3)
A dragon is green if at least one of its parents is green and is pink otherwise.
(4)
Using only the predicates dragon, happy, fly, child, greenand pink, represent
these sentences in First Order Predicate Calculus (FOPC) sentences.(8 marks)
(b)
Convert these FOPC sentences into Conjunctive Normal Form (CNF) clauses. (8 marks)
(c)
Before performing resolution, this needs to be converted to CNF. The result of this
operation (where variable names are subscripted since we need different variables in each
clause) give the following clauses:
(1) prereq(csc2030,csc3091)
(2) passed(x1,y1)vprereq(z1,y1)vpassed(x1,z1)
(3) graduated(x2)vpassed(x2,csc3091)
(4) graduated(sally)
Use resolution to prove that Sally must have passed csc2030. At each step of the refutation,
indicate the clause used for that step by writing down its number, and indicate clearly the
substitutions you make.
(10 marks)
Exercise Set 3
Exercise Set 3
Ls = lightswitch
Ls4
Room 4
Door 4
Ls3
Room 3
Door 3
Corridor
Ls2
Room 2
Box3
Room 1
Box4
Door 2
Box2
Ls1
Door 1
Box1
Suppose that:
There is a predicate at giving Shakey's current location, at(Shakey,x)where x is a
box, a light switch, a door.
There is a predicate in(x,roomX)where x is a box, a light switch, or a door.
Shakey can move to somewhere that is in the same room. To allow Shakey to plan a
route from room to room, we will say that the door between two rooms is in both of
them.
There are constants for
the rooms (room1,room2,room3,room4),
the doors (door1,door2,door3,door4),
the boxes (box1,box2,box3,box4),
the floor,
the initial and final locations of box2 (box2start,box2end).
There is a predicate on, and that it is a precondition of Shakey moving from the
current location to another location that Shakey is on the floor.
Because Shakey is short, Shakey can only turn a light switch on or off if Shakey is on
top of a box that is at the light switch's location.
In this exercise, we will look at planning in Shakey's world.
(a) Describe Shakey's six actions in situation calculus notation.
(b) Translate them into the STRIPS language.
(c) Construct a plan for Shakey to get box2 into room2 from the starting configuration in the
following figure.
Exercise Set 3
(d) Suppose Shakey has n boxes in a room and needs to move them all into another room.
What is the complexity of the planning process in terms of n?
Exercise 3.3 (R&N 14.3)
After your yearly check-up, the doctor has bad news and good news. The bad news is that
you tested positive for a serious disease, and that the test if 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 don't 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?
Exercise 3.4 (R&N 14.12)
Three prisoners, A, B and C, are locked in their cells. It is common knowledge that one of
them will be executed the next day and the others pardoned. Only the governor knows
which one will be executed. Prisoner A asks the guard a favour: "Please ask the governor
who will be executed, and then take a message to one of my friends B and C to let him know
that he will be pardoned in the morning.' The guard agrees, and comes back later and tells
A that he gave the pardon message to B. What are A's chances of being executed, given this
information?
Exercise 3.7
Exercise Set 3
Suppose that a patient turns up with a cough. This cough can either be a symptom of bronchitis
or lung cancer. Factors which the doctor may take into account include the results of an x-ray (if
it is cancer, the x-ray will be positive 95% of the time, and if there is no cancer the x-ray will
always be negative), and whether or not the patient is a smoker or not (twice as many smokers
as non-smoker will have cancer). Model this diagnosis problem in a Belief network with
Boolean variables for smoker,cancer,+veXray,bronchitis, and cough.
Exercise Set 3
Exercise 3.9: Robot Cleaner Problem (taken from Dean, Allen and Aloimones "Artificial
Intelligence: Theory and Practice")
Suppose we have a cleaner robot that roams the top three floors of a university building
collecting trash and looking for recyclable materials. The robot is trying to learn which offices
have recycling bins. For a given office it might know the following information: the status of its
occupants; the floor that the office is located on; the department that its occupants are
associated with; the size of the office. The possible values of these attributes are as follows.
Attribute
Status
floor
department
size
Values
{academic,general,student}
{three,four,five)
{ee,cs}
{large,medium,small}
status
academic
general
academic
student
general
academic
student
general
floor
three
three
four
four
five
five
three
four
dept
ee
ee
cs
ee
cs
cs
ee
cs
size
large
small
medium
large
medium
large
small
medium
recycling bin?
no
no
yes
yes
no
yes
yes
no
(a) Develop a decision tree, D1, for the problem starting with the attributes size and
department. How useful is this for generalizing to new examples? For instance, what does
it tell us about medium-sized offices housing ee students?
(b) Develop a two-node decision tree, D2, for the problem (i.e. a decision tree that only uses 2 of
the 3 attributes) with the attributes status and department. Show the decision tree with
the examples at the leaves after the first attribute has been chosen, and then again after the
second attribute has been chosen. Finally, re-draw the decision tree with just the class names
at the leaves.
(c) Describe a test example for which both D1 and D2 give the correct classification. Can you
find a second test example for which one of the decision trees gives the correct classification
and one gives the wrong classification? Use the following format to describe your test
examples.
Test room
status
floor
dept
size
recycling bin?
Exercise Set 3
Exercise Set 3
(Total 30 marks)
A copier in an office building is not working and the robot is given the goal of fixing it. Suppose that the
only reasons for the copier not working are that (1) its paper storage tray is empty, (2) its replaceable
cartridge is spent, i.e. in need of replacement, or (3) it experienced some momentary hardware or software
problem and needs to be reset . The standard practice for fixing the copier is to fill the paper tray if it is
empty, replace the cartridge if necessary, and then reset the machine. To fill the paper tray, the tray must
be empty, the robot must be at the copier, and the robot must have some paper. To replace the cartridge, the
cartridge must be spent, the robot must be at the copier, and the robot must have a replacement cartridge.
To reset the machine, the paper tray must not be empty, and the cartridge must not be spent.
The vocabulary you will use includes the predicates emptyTray,atCopier,hasPaper,
spentCartridge, hasCartridge, and working.The actions are fill, replace, and
reset .
(a)
Describe the domain, in situation calculus notation, including the frame rules and the
goal, as well as the results of all 4 actions.
(10 marks)
(b)
Describe the domain using STRIPS operators, one for each action. (8 marks)
(c)
Suppose that the robot comes to repair the copier and finds that it is not working because
the tray is empty, but the cartridge is fine. Construct a plan to achieve the goal using these
STRIPS operators and a partial order planner. Show the causal and temporal links in the
final plan. Be sure to include the preconditions and effects in your diagram. For each
temporal link, describe the clobbering situation (causal link and clobberer) that it is
avoiding. Then redraw the plan, showing only the final execution partial order. Here is an
outline of the plan you will draw.
(8 marks)
Start
fill
replace
reset
Finish
(d)
Explain, in no more than 4 lines, the relative advantages and disadvantages of using
situation calculus and STRIPS for describing planning problems?
(4 marks)
Exercise Set 3
(Total 24 marks)
Consider the design of a robot that can service bicycles. Among the many different tasks the robot
needs to be able to carry out is servicing the chain. This mainly involves having to clean and oil the
chain, which may require it to be removed from the bike.
The following STRIPS planning operators are used for removing and re-attaching chains to and from
bikes:
OP(ACTION:remove(Y,X)
PRECOND:bike(X),chain(Y),attached(Y,X)
EFFECT:attached(Y,X),unattached(Y)
)
OP(ACTION:attach(Y,X)
PRECOND:bike(X),chain(Y),unattached(Y)
EFFECT:attached(Y,X),unattached(Y)
)
Further operators are required for clean and oil. There are a number of conditions these operators
must satisfy.
1.
2.
3.
4.
(a)
(b)
remove(c,b)
clean(c)
oil(c)
attach(c,b)
Finish
Exercise Set 3
(ii)
(c)
At some stage you will run into a problem that prevents you from constructing a
complete plan - what is this problem and what do you need to do to remove it? (Just
describe briefly, in a couple of lines, what is needed to fix the problem).(4 marks)
Give a definition of the Frame Problem and describe briefly (in a few lines) how the STRIPS
planning system handles this problem.
(4 marks)
(Total 24 marks)
Suppose we have a group of 8 people who can be described by three attributes, height, hair colour and
eye colour. The possible values of these attributes are as follows.
Attribute
Height
Hair
Eye
Values
{tall,short}
{dark,red,fair)
{blue,brown}
Class
+
Height
short
tall
tall
short
tall
tall
tall
short
Hair
fair
fair
red
dark
dark
fair
dark
fair
Eyes
blue
brown
blue
blue
blue
blue
brown
brown
(d)
Develop a two-node decision tree, D, for the problem (i.e. a decision tree that only uses 2 of the
3 attributes). Choose the attributes carefully, since if you choose the wrong attribute as one of
the two attributes, you wont be able to develop a two-node decision tree. Show the decision tree
with the examples at the leaves after the first attribute has been chosen, and then again after the
second attribute has been chosen. Finally, re-draw the decision tree with just the class names at
the leaves.
(18 marks)
(e)
Describe TWO new test examples, such that for one example, D gives the correct classification,
while for the second example, it gives the wrong. Use the following format to describe your test
examples. Note that Y1 should not be exactly the same as any of the X1 to X8original data items.
(6 marks)
Exercise Set 3
Test
Examples
Y1
Y2
Class
Height
Hair
Eyes
D
correct?
YES
NO