0% found this document useful (0 votes)
60 views

COS351-D Artificial Intelligence Techniques Tutorial Letter 101

Uploaded by

tondi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

COS351-D Artificial Intelligence Techniques Tutorial Letter 101

Uploaded by

tondi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

COS351-D/101/2004

COS351-D

ARTIFICIAL INTELLIGENCE TECHNIQUES

TUTORIAL LETTER 101

SCHOOL OF COMPUTING
2

CONTENTS OF THIS TUTORIAL LETTER

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2. How to make enquiries and get help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3. Syllabus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4. Additional literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

5. Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Assignment 01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Assignment 02 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Assignment 03 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 COS351-D/101

1. Introduction

Our aim in this module is to introduce you to a selection of important artificial intelligence (AI) concepts
and techniques, including reactive machines, search algorithms, knowledge representation and reasoning,
and planning. This module draws on many skills you have acquired, and theory you have mastered thus far
in your studies, notably logic, data structures, and programming. It also paves the way to our Honours level
modules in Artificial Intelligence.

We hope that you will enjoy this module!

2. How to make enquiries and get help

Tutorial letter COSALL-F/301/2004 contains important information regarding administrative matters. If


you have any questions about the content of the module, you can phone any of the members of the COS351
team. Their names will be announced in tutorial letter COSALL-F/301. You can also contact us by e-mail.
Just send a message to [email protected].

We also have an electronic newsgroup, where you can post messages to fellow students, and
respond to other students' messages. Consult tutorial letter COSALL-F/301 for more information.

You can also write to us. Address your letter to:

The Lecturer: COS351-D


Department of Computer Science and Information Systems
University of South Africa
P.O. Box 392
Pretoria
0003.

For administrative enquiries, consult the brochure UNISA: Services and Procedures, or write to:

The Registrar (Academic)


University of South Africa
P.O. Box 392
Pretoria
0003.
4

3. Syllabus

You need to acquire a textbook for this module. The prescribed textbook is:

Nils J. Nilsson. Artificial Intelligence: A New Synthesis. Morgan Kaufmann Publishers, 1998.

Upon registration, you should have received this tutorial letter, COS351-D/101/2004, and the study guide,
tutorial letter COS351-D/501/2004. During the year, you will also receive a number of tutorial letters that
discuss important ideas and provide solutions to the assignment problems. These tutorial letters should be
regarded as part of the examinable syllabus.

The module can be divided into three parts, with an assignment set on each part. The details of the syllabus
are described in Tutorial letter 501. Broadly speaking the three parts are as follows:

Part 1: Chapters 1, 2, 3, 5, 7 and 8.


Part 2: Chapters 9, 11 and 12.
Part 3: Chapters 13 to 17.

4. Additional literature

The Unisa library has hundreds of books on artificial intelligence. Here is a small selection that you may
find useful. You are welcome to search the library catalogue to find many more titles on various aspects
of, and approaches to AI. Please note that the library usually has only one copy of a book, so these books
won't always be readily available. Only limited waiting lists will be kept for these titles.

Boden, M.A. Artificial Intelligence. Academic Press, 1996.

Dean, T. Artificial Intelligence: Theory and practice. Benjamin/Cummings, 1995.

Ginsberg, M.L. Essentials of Artificial Intelligence. Morgan Kaufmann, 1994.

Pratt, I. Artificial Intelligence. MacMillan Press, 1994.

Russell, S.J and Norvig, P. Artificial Intelligence: A modern approach. Prentice Hall, 1995.

Shinghal, R. Formal Concepts In Artificial Intelligence: Fundamentals. Chapman & Hall Computing,
1992.
5 COS351-D/101

5. Assignments

There are three assignments, each assignment counting 50 credits. Full credits are awarded for the timeous
submission of satisfactory assignments, and half the credits for the submission of unsatisfactory attempts,
or assignments that are received more than two weeks late. To gain admission to the exam you need at least
100 credits. This means you need to submit at least two of the three assignments. However, we recommend
that you submit all three, though.

NB: You are encouraged to form study groups, but please note that you have to submit your own
attempt. The credits for identical assignments will be divided amongst the submissions.

We don't award marks for the assignments that you submit. Assignments are not mini-exams, and we don't
treat them as such. Use this opportunity to get a better understanding of the material covered in an
assignment, by asking questions, and pointing out to us which parts of the assignment you found difficult.
Remember, you won't lose any marks by doing so. A satisfactory assignment is one in which you put in a
serious effort to answer all the questions.

You are welcome to submit assignments electronically, via SOL. Assignments must reach us by the due
dates. If you need more time, please contact us.

Assignment 01

Content: Chapters 1, 2, 3, 5, 7 and 8 of the prescribed book

Due date: 15 April 2004

Credits: 50

Questions 1 to 4 and 6 to 7 refer to exercises from the prescribed book.

1. Exercise 2.6 on page 35.

2. Exercise 3.2 on page 55.

3. Exercise 5.1 on page 80.

4. Exercise 7.3 on page 126.


6

5. Implement a depth-first search algorithm to solve the Missionaries and Cannibals problem
described in the previous problem. Write your implementation in C++, Java, or Pascal, and submit
your program listing as well as a listing of the output produced by your program. Supply full
documentation which explains all the data structures and functions in your implementation.

Hint: Start by deciding how to represent a state and a move. Remember to include descriptions in
your documentation.

6. Exercise 8.2 on page 137.

7. Exercise 8.5 on page 137.

Assignment 02

Content: Chapters 9, 11 and 12 of the prescribed book

Due date: 15 June 2004

Credits: 50

Questions 1, 3 and 4 refer to exercises from the prescribed book.

1. Read Exercise 9.1 on page 160.

Nilsson recommends a successor function that generates a successor node by placing a queen in any
legal position on the board. Nilsson then eliminates some successors because they are symmetric
to other nodes. This is fine for a 4x4 board but we need a better approach when we deal with larger
sized boards. A better approach is to consider successors to the start node where we are allowed to
place a queen only in the first column. So, for a nxn board, we have n successors (we do not take
symmetry into consideration). I n t h e F o u r - Q u e e n s p r o b l e m w i t h a 4 x 4 b o a r d ,
th e re a re 4 d iffe re n t s u c c e s s o rs to th e s ta rt n o d e : o n e in w h ic h th e firs t
q u e e n is p la c e d in c o lu m n o n e ro w o n e , o n e in w h ic h s h e is p la c e d in
c o lu m n o n e ro w tw o , a n d s o o n , u p to c o lu m n o n e ro w 4 . In th e n e x t
le v e l o f th e s e a rc h g ra p h (a t d e p th 2 ), w e o n ly c o n s id e r n o d e s w e re a
q u e e n is p la c e d s o m e w h e re in th e s e c o n d c o lu m n . In n o d e s a t d e p th 3 ,
w e o n ly h a v e n o d e s w h e re a q u e e n is p la c e d in th e th ird c o lu m n , e tc .
(Y o u m a y w a n t to re a d th e fir s t tw o p a ra g ra p h s o f S e c tio n 1 1 .2 in
Nilsson: h e r e t h e y d i s c u s s t h e s a m e a p p r o a c h t o s o l v e t h e E i g h t - Q u e e n s
7 COS351-D/101

p r o b l e m .)

i) Draw a full search tree for this approach to solve the Four-Queens problem.

ii) Invent a suitable heuristic function for this problem based on the successor function
described above.

iii) Is your heuristic function admissible? Why?

2. Implement the A* search problem for the N–Queens problem in C++, Java or Pascal. Submit your
program listing, as well as the output from running the program on both the Four-Queens and the
Eight-Queens problem. Supply full documentation which explains all the data structures and
functions in your implementation.

S u g g e s tio n s to s o lv e th is p ro b le m : (W e b a s e o u r s u g g e s tio n s o n a C + +
i m p l e m e n t a t i o n .)

The representation of a state

W e h a v e t o d e c i d e w h a t a node ( r e p r e s e n t i n g a s t a t e ) l o o k s l i k e . A n y
s p e c ific n o d e te lls u s h o w m a n y q u e e n s h a v e b e e n p la c e d o n th e b o a rd
i n a s t a t e , a n d a l s o where t h e y h a v e b e e n p l a c e d . S o , w e r e p r e s e n t t h e
a p p e a ra n c e o f th e e n tire b o a rd u p to th e p la c e m e n t o f th e la s t q u e e n .
W e d e f i n e a NodeType c l a s s b e l o w t o r e p r e s e n t a n o d e .

T h e b o a r d c a n b e r e p r e s e n t e d b y a one- d i m e n s i o n a l a r r a y , a n d w e u s e
a vector. ( N o t e t h a t u s i n g a t w o - d i m e n s i o n a l a r r a y i s s p a c e i n e f f i c i e n t . )
T o re p re s e n t a q u e e n p la c e d in c o lu m n i, w e s im p ly re c o rd th e ro w
n u m b e r in w h ic h th e q u e e n is p la c e d in e n try i. C o n s id e r th e s o lu tio n
t o t h e E i g h t - Q u e e n s p r o b l e m i n f i g u r e 1 1 . 1 o n p a g e 1 8 2 i n Nilsson.
A s s u m e th a t th e c o lu m n s a n d th e ro w s a re n u m b e re d fro m 0 to 7 . T h e
v e c t o r board r e p r e s e n t i n g t h i s s o l u t i o n a p p e a r s a s f o l l o w s :
boards[0]=0 board[1]=6 board[2]=4 board[3]=7
board[4]=1 board[5]=3 board[6]=5 board[7]=2

F o r o u r c o n v e n i e n c e , w e a l s o s t o r e a n o d e ’ s g a n d f^ v a l u e s , a n d w e
h a v e a m e m b e r f u n c t i o n t o c a l c u l a t e t h e v a l u e o f ¡.
8

H e r e i s t h e d e f i n i t i o n o f t h e c l a s s NodeType t h a t r e p r e s e n t s a n o d e ( o r a
s ta te ):
9 COS351-D/101

class NodeType {
public:
NodeType ();
void SetQueen (int row);
int GetQueen (int column) const;
int GetG () const {return g;};
// g = the number of queens that has been placed
double CalcF ();
bool operator<(const NodeType & right) const;
private:
double CalcH ();
vector <int> board;
int g;
double f;
};

SetQueen i s a m u t a t o r t h a t p u t s a q u e e n i n r o w n u m b e r row i n t h e n e x t
a v a i l a b l e c o l u m n . GetQueen i s a n i n s p e c t o r t h a t r e t u r n s t h e r o w n u m b e r
i n w h i c h t h e q u e e n i n c o l u m n n u m b e r column h a s b e e n p l a c e d . GetG i s a n
in s p e c to r th a t re tu rn s th e g v a lu e o f th e n o d e . T h e g d a ta m e m b e r v a lu e
is e q u a l to th e n u m b e r o f q u e e n s th a t h a v e b e e n p la c e d . T h e d a ta
m e m b e r f i s a c t u a l l y f^ .

N o te th a t y o u m a y a d d o n e o r tw o m e m b e r fu n c tio n s if n e c e s s a ry .

The representation of the list OPEN

U s u a lly th e b e s t c h o ic e fo r th is lis t is a q u e u e d a ta s tru c tu re . H o w e v e r,


t h e S T L list c o n t a i n e r i s e v e n b e t t e r b e c a u s e w e c a n e a s i l y s o r t t h e
c o n te n ts a n d re m o v e a n o d e fro m th e fro n t.

The construction of a cost and a heuristic function

L e t th e c o s t fo r e a c h a c tio n (i.e . p la c in g a q u e e n ) b e o n e . S o g (n ) is
e q u a l to th e d e p th o f th e n o d e n in s e a rc h tre e fo r a ll n o d e s n .

I n i t i a l l y i t i s a g o o d i d e a t o s i m p l y s e t ¡( n ) = 0 f o r a l l n o d e s n , u n t i l y o u
h a v e d e b u g g e d y o u r p ro g ra m . T h e n y o u c a n s e le c t a m o re e ffic ie n t
h e u ris tic fu n c tio n .
10

The algorithm

We use the A* algorithm on page 144-145 with a few simplifications:


• We do not need a CLOSED list because all goal nodes have the same total cost in this
problem. This characteristic of our problem means that we do not have to redirect pointers
in step 7. In fact, it also means that we do not have to stick to a heuristic that is admissible!
• In step 6 we do not need to check for successors that are ancestors of node n because this
is impossible in our case.

3. Exercise 9.3 on page 161.

4. Exercise 11.4 on page 193.

5. Consider the following game (see next page) in which the static scores (in parentheses at the tip
nodes) are all from the first player’s point of view. Assume that the first player is the maximizing
player.

i) What move should the first player choose?

ii) What nodes would not need to be examined using the alpha-beta algorithm - assuming that
nodes are examined in left-to-right order?
11 COS351-D/101

Assignment 03

Content: Chapters 13 to 17 of the prescribed book

Due date: 31 July 2004

Credits: 50

Questions 3 to 6 and 8 to 10 refer to exercises from the textbook:

1. Exercise 14.3 on page 238.

2. Discuss the difference between the set of support, ancestry-filtered and linear-input resolution
refutations.

3. Exercise 15.4(3) and exercise 15.4(5)


12

4. Exercise 15.6 on page 251 but ONLY invent a predicate calculus expression that can be used to
define when a cell is available.

5. Exercise 16.2 on page 265.

6. Exercise 16.3(3) on page 266.

7. You are a detective on the trial of the mysterious Mister X, who is responsible for the grusome
murder of the loyal mayor. It has taken you months to assemble the following information:
- Mister X is either the chauffeur of Lord Smith, the gardener of Lady Jones, or the butler of
Sir Cromwell.
- Mister X must have been in town the night before the murder was committed.
- Anyone with an alibi could not have committed the murder.
- The night before the murder all chauffeurs were out of town.
- All gardeners have an alibi.

i) Represent your knowledge in predicate logic using the predicates Murderer, Has_Alibi and In_town
(each with one argument), the function symbols Gardener, Chauffeur and Butler (each with one
argument), and the constants Smith, Jones, Cromwell and MrX. You will also need the equality
predicate.

ii) Use resolution refutation to prove that the butler of Sir Cromwell is the murderer.

8. Exercise 16.7 on page 267.

9. Exercise 17.1 on page 298.

10. Exercise 17.3 on page 299.

©
UNISA

You might also like