Selasa, 22 Desember 2009

Final Project Expert System

So, our final project expert system has done.

We often find students of senior high school feel confuse about university’s majors that they will take. According to our survey, 3 of 5 students of senior high school in the third grade still don’t decide what kind of major that they will choose. It is because they are lack of information about kind of majors, what subject that they will learn in those majors, and which universities that provide those majors. From that problem, we make a simple expert system by using prolog that helps them identifying the subject that they will learn if they choose a certain major. And more information in which universities that provide the majors.

Here is the link of our report:

http://www.4shared.com/file/179094754/a1e42b66/Report_FP_matdis_Irine_Rizqi_B.html

Source code:

http://www.4shared.com/file/179101122/f2d925c0/aaaaaaaaaaaaaa.html

Senin, 14 Desember 2009

Testing

Development of our simple EXPERT SYSTEM
1. Firstly, we made a notepad that contain of the facts, or we can say it as characteristic of each major. We still develop it in a simple way. We divided the characteristic into 3 parts (major in senior high school, faculty, major in university). Then we save it in .pl type.




















2. Then we opened SWI Prolog and consult the notepad. We entered an example instruction like this: jurusan(ipa,_,A). Press enter, and ';' for the next result. It will show the possibility of major if we choose IPA as favourite subject.

our next development will show another characteristic to specify the suitable major ^_^

Selasa, 08 Desember 2009

Summary for chapter 6

Introduction

Most conventional programming languages have a looping facility that enables a set of instructions to be executed repeatedly either a fixed number of times or until a given condition is met.

Prolog has no looping facilities, similar effects can be obtained that enable a sequence of goals to be evaluated repeatedly. This can be done in a variety of ways, using backtracking, recursion, built-in predicates, or a combination of these.

Looping a Fixed Number of Times

Many programming languages provide 'for loops' which enable a set of instructions to be executed a fixed number of times. No such facility is available in Prolog (directly), but a similar effect can be obtained using recursion.

Looping Until a Condition Is Satisfied

Many languages have an 'until loop' which enables a set of instructions to be executed repeatedly until a given condition is met. Again, no such facility is available directly in Prolog, but a similar effect can be obtained in several ways.

Recursion
The first example below shows the use of recursion to read terms entered by the user from the keyboard and output them to the screen, until end is encountered.

go:-loop(start). /* start is a dummy value used to get
the looping process started.*/
loop(end).
loop(X):-X\=end,write('Type end to end'),read(Word),
write('Input was '),write(Word),nl,loop(Word).

?- go.
Type end to end: university.
Input was university
Type end to end: of.
Input was of
Type end to end: portsmouth.
Input was portsmouth
Type end to end: end
Input was end
Yes

Using the 'repeat' Predicate
Although it can often be used to great effect, recursion is not always the easiest
way to provide the types of looping required in Prolog programs. Another method
that is often used is based on the built-in predicate repeat.
The goal repeat does not
repeat anything; it merely succeeds whenever it is called. The great value of repeat
is that it also succeeds (as many times as necessary) on backtracking. The effect of
this, as for any other goal succeeding, is to change the order of evaluating goals
from 'right to left' (i.e. backtracking) back to 'left-to-right'.

Backtracking with Failure

As the name implies, the predicate fail always fails, whether on 'standard' evaluation left-to-right or on backtracking. Advantage can be taken of this, combined with Prolog's automatic backtracking, to search through the database to find all the clauses with a specified property.

Finding Multiple Solutions
Backtracking with failure can also be used to find all the ways of satisfying a goal. Suppose that a predicate findroute(Town1,Town2,Route) finds a route Route between two towns Town1 and Town2. The details of this predicate are irrelevant here. It may be assumed that Town1 and Town2 are atoms and that Route is a list.

Looping Exercise Page 97

(1) Define a predicate to output the values of the squares of the integers from N1 to N2 inclusive and test it with N1 = 6 and N2 = 12.

pertama kita buat perintah seperti di bwah ini di notepad, kemudian disimpan dengan tipe .pl












kemudian kita mengetikkan perintah outsquare(6,12). Lalu tekan enter








(2) Define and test a predicate to read in a series of characters input by the user and
output all of those before the first new line or ? character.
pertama-tama buat rule seperti notepade berikut. Kemudian save dengan tipe .pl








Kemudian dari swi prolog consult rule tadi. Lalu kita masukkan perintah go.









(3) Using the person clauses given in Section 6.3.1, find the professions of all
those over 40.
pertama-tama buat rule seperti berikut, dan simpan dengan tipe .pl

lalu dari swi prolog kita consult file tadi. kemudian kita ketikkan perintah find.