You are on page 1of 9

COS3751/201/1/2015

Tutorial Letter 201/1/2015

Techniques of Artificial Intelligence


COS3751

Semester 1

School of Computing

IMPORTANT INFORMATION

This tutorial letter contains model solutions for assignment 01

BAR CODE

university
Learn without limits. of south africa
ASSIGNMENT 01
Solution
Total Marks: 100
UNIQUE ASSIGNMENT NUMBER: 578638
Study material: Chapters 1 through 4. You may skip sections 4.2 and 4.5.

Question 1: 10 Marks

(1.1) Draw a diagram that shows an overview of an agent design. (6)

Sensors
Agent

? Environment

Actuators

Diagram like above which shows agent Xwith sensors X, percepts Xenvironment X,
actions X, and actuators X

(1.2) Explain the difference between a Deterministic and Stochastic environment. (4)
In a deterministic environment the next state is completely Xdetermined by the current
state and the agent’s action X. In a stochastic environment one cannot completely
Xdetermine the next state based solely on the current environment and on the agent’s
actions X.

Question 2: 10 Marks

(2.1) Explain the difference between an uninformed and informed search. When would one (3)
choose one over the other?
In an uninformed search we have no additional information about the possible out-
comes of a sequence of actions (other than we will ultimately win or lose)X. In an
informed search, the agent has the ability to make a search choice based on addi-
tional information around the choice they are making, and wether the choice will lead
to a better outcome soonerX. We will most certainly always choose an informed
search over an uninformed search. We will by lack of information be forced to choose
the uninformed (no guesses are available to help guide our search).X

2
COS3751/201

(2.2) Explain the concept of a search space. (1)


The set of state spaces that will be searched for a solution X.

(2.3) Explain what is meant by expanding. (1)


Removing a node from the frontier, placing it’s children on the frontier, and adding it to
the closed list.X(only half if not fully explained).

(2.4) What is the purpose of the explored set? (1)


Avoids infinite loops since it holds the list of nodes that have already been explored.
X
(2.5) List and explain the measures used to determine problem solving performance. (4)

1. Completeness: Will the algorithm find a solution if it exists? X


2. Optimality: Will the algorithm find the best solution (optimal path cost among all
solutions)? X
3. Time complexity: How long does the algorithm take to find a solution? X
4. Space complexity: How much memory is needed to perfrom the search for a
solution? X

Question 3: 12 Marks

Five people need to walk from this side to the other side of a bridge at night. The bridge is not
in a very good condition and will hold at most 3 people at a time. They discover that they only
have one torch. This means that after one,two,or three people have crossed the bridge, somebody
(one, two, or three people) will have to come back with the torch so that the next persons can cross
safely. Each of the five people (Anna, Brett, Charles, David, and Ernest) take a different time to
cross the bridge. Whenever 3 people cross they can only go as fast as the slowest person in the
group. Since the torch has limited battery life they need to figure out which is the fastest way to get
all 5 of them across the bridge. The times each take to get across are:
1. Anna: 5 Minutes
2. Barry: 7 Minutes
3. Charles: 1 minute
4. David: 2 minutes
5. Ernest: 9 minutes

(3.1) Define a state representation for the problem. (3)


We can use: < P, t >XP is the set of people on the left side of the bridge (start) X,
and t = {Left, Right} Xis the side of the bridge the torch is on. (we don’t need to track
the other side of the bridge since we know who is on that side by virtue of them not
being on this side).

3
(3.2) How big is the search space for the problem? (2)
We must first recognise that this search will generate loops – if we ignore this fact then
the search space becomes infinitely large (we could potentially go down a branch in
the tree which will lead to loops, rendering no results). Secondly, we need to recognise
that certain moves are inherently useless: moving three people across and bringing
them all back is pointless (moving three across and bringing 2 back is not necessarily
pointless). Finally, it is possible to move 2 across and bring 1 back, or to move 3 across
and bring 2 back. Both of these result in 4 on this side, however, the number of states
resulting from each move is different. If we detect already visited states we will find
that the first is a subset of the second (so we don’t count them again).
Lastly, we should also keep the rules of the game in mind: left with 3, there is no way
to take 2 across, bring 1 back and take 2 across again any faster than just taking 3
across. We can thus safely consider states which have just 2 or 3 people to move
across the penultimate state (we just take them all across).
Generating child states (nodes) for each node is thus done by choosing some ele-
n n!

ments from a set representing the people on one side. So, using k = k!(n−k)! we can
generate the combinations (and count the number of nodes each parent node would
generate).
Starting at the root node, we will either send 3 or 2 people across. We thus remain
with
 2 5or 3 people on this side. The number of nodes 5generated by this move is
5

2
+ 3 = 20 (we also can choose to send 1 across, or 1 = 5). Thus on level 1 we
generate 25 nodes. Continuing in this fashion we arrive at no more than 476X2 nodes
for the search space (detecting loops, and already visited states).

(3.3) Using your state representation, define the start state for the problem. (1)
< {Anna, Barry, Charles, David, Ernest}, Left >X

(3.4) Define the goal state for the problem based on your state representation. (2)
< {}, Right >XX

(3.5) Define all the operators and functions for this problem. (2)
move(X , Y , Z )X, with X , Y , Z ∈ {Anna, Barry, Charles, David, Ernest, } X(X 6= Y , X 6=
Z , X 6= ∅, Y = Z ⇔ Y = ∅)

(3.6) Write down the sequence of moves that leads to the optimal solution for this problem. (2)
move(B,C,E), move(C,∅,∅), move(A,C,D) Xor move(A,C,D), move(C,∅,∅), move(B,C,E)X

Question 4: 10 Marks

Uninformed Search:

(4.1) Clearly explain what an uninformed search is. When would one choose to use an (2)
uninformed search over a well known better type of search?
Uninformed search provides a brute force search of the search space X. When there

4
COS3751/201

is no way to determine if an action is better than another one X.

(4.2) What is the space complexity of the Breadth First Search (BFS) algorithm with a (3)
branching factor of β at depth δ? Is this a problem? If so, explain why. If not, ex-
plain why not.
O(β δ )X. This is an exponential growth X– space/complexity gets large quickly.X

(4.3) Explain how Depth Limited Search (DLS) alleviates the space complexity problems (3)
with Depth First Search (DFS). Is this enough or does it introduce new problems?
Explain.
It limits the depth (l) to which the DFS can searchXNoX. If l < d (d the location of
the shallowest goal) then the search will be incomplete.X

(4.4) Is Iterative Deepening Search (IDS) an absolute solution to the problems encountered (2)
with DFS? Clearly explain when would it not be a good solution?
NoX. If the goal is in the last node of the treeX

Question 5: 8 Marks

Consider the search tree in figure 1.

B C

D E F G

H I J K L M N O

Figure 1: Search Tree (IDS)

(5.1) Show the order in which the nodes will be expanded (from limit 0 to limit 4) given that (6)
IDS is used. Assume the goal node is O, and that nodes are expanded from left to
right.

1. Limit 0: (No expansion – A is generated but not expanded) X

2. Limit 1: A X

5
3. Limit 2: A B C X

4. Limit 3: A B D E C F G X2

5. Limit 4: A B D H I E J K C F L M G N O X

-1 if nodes are right, but limits are wrong.

(5.2) Has this search performed better than a regular DFS in terms of space complexity? (2)
Explain your answer.
NoX. To find the solution we had to generate the entire search tree that the DFS
would have generated in any case.X

Question 6: 12 Marks

Consider the graph in figure 2. Suppose we start at A and have to find a route to E. Using UCS,

11

B 20

15

D C

14 22 24 4

G E F

12 9

Figure 2: Search Graph (Uniform Cost Search (UCS))

answer the following questions.

(6.1) List the order of the nodes as they would be added to the frontier (including path cost). (8)
A(0)X, B(11)X, C(20)X, D(26)X, E(44)X, F(24)X, H(33)X, G(40)X.

(6.2) Write down the path to the goal. (1)


A,C,EX

6
COS3751/201

(6.3) Is there a better (shorter) path to the goal? Explain your answer. (3)
NoX. UCS always picks the smallest path cost from the frontier – thus when the goal
node is reached it will be the smallestX. Any shorter path to the goal will replace
existing longer pathsX

Question 7: 10 Marks

Informed Search:

(7.1) Explain what a heuristic function is. (3)


A heuristic function estimatesXthe cost from the currentXto the goalX.

(7.2) Explain what an admissible heuristic is. Explain why this is an important characteristic (2)
of a heuristic.
It never over-estimatesXthe cost to the goal.X

(7.3) Greedy best-first search is not optimal but is often efficient. Explain what is meant by (5)
this statement. Provide an example to support your argument.
It will find a solution quicklyX, but not necessarily the best solutionX. Any example
that shows how a search finds a quick solution that is not optimalX3

Question 8: 20 Marks

Consider figure 3 and table 1 and answer the questions that follow. The table provides the esti-
mated distances from each node to H.

Node Estimated distance to H


A 10
B 12
C 4
D 5
E 4
F 7
G 4
H 0
I 4
K 2
L 1
M 1
N 6

Table 1: Distance Table

(8.1) List the nodes in the order in which they are expanded (not generated). (10)

7
A

7 3

B 8 D

10 7 6

F C I 4 2

10 8 3 L

G 5 4 K

5 3 2 5

H M E

Figure 3: A* Search

AX2 , DX, KX, LX, MX, CX, H X2 (correct orderX)

(8.2) Write down the content of the frontier at the time the search terminates. (6)
< N, M, K , D, A(6, 10, 16) >X2 , < E, K , D, A(4, 12, 16) >X, < I, D, A(4, 10, 14) >X, <
B, A(7, 12, 19) >X, < G, C, A(4, 16, 20) >X

(8.3) Is the heuristic being applied consistent? Explain your answer. (2)
NoX. ĥ(A) > ĝ(D) + ĥ(D), n = A, n0 = D X

(8.4) Notice that there is no route exiting N. Why does A* not get stuck when it reaches N? (2)
Explain your answer.
The search does not try to find a route exiting N since it simply selects the next node
with the smallest f̂ Xit won’t get stuck at N X

Question 9: 8 Marks

Beyond classical search:

8
COS3751/201

(9.1) Explain the concept of a local maxima. (2)


An answer that seems to be the best from a set of answers that are in close proximity
in the search spaceX2 .

(9.2) Why is this a problem in searching for solutions, and what actions can an agent take (2)
to overcome this problem?
The answer may not be the bestX, a random restart, or random walk could find a
better solutionX.

(9.3) Would it be possible to use a genetic algorithm to search for a solution to the game of (4)
tick-tack-toe? Explain your answer by providing suitable examples.
YesX. A GE can use mutation to find a suitable set of solutions close to the answer
X2 . If we rely on the GE algorithm we may end up going in circlesX.

You might also like