Assignment 1 - Department of Computer Science

Transcription

Assignment 1 - Department of Computer Science
Department of Computer Science
Applications of AI CS345/CSM45
Assignment 1, 2005
This exercise is to obtain practice in writing a simple CLIPS expert system. Your task
is to implement an expert system to determine the cost of insuring a car. The overall
cost is determined by a collection of rules dealing with type and age of car, age of
the insured, place of residence etc.
You are advised to look at some of the example code which comes with CLIPS to see
how to format your program.
Information on different cars should be stored using a template with slots
make, model, eng_size, group
(e.g. Honda, Civic, 1600, 3; Ford, Ka, 1100, 1). The group reflects the cost of
insurance and is a number in the range 1 to 6. So cars such as Ford Ka might be
group 1 and a Porsche group 6.
First set up a deffacts statement defining different sorts of cars which the
company will insure. You should have about 20 different types of car spread
throughout the groups. The same model of car with different engine size may be in
different groups. A collection of occupations which the insurance company will
cover should be stored as a deffacts and include lecturer, teacher and
student.
The stages in determining the overall insurance cost are as follows:
1. Begin by displaying a welcome banner and then asking if the user wishes to
obtain a car insurance quotation. The program should halt if the answer is no.
2. Determine the personal details consisting of name, occupation, sex and age.
This should be stored in a deftemplate fact. If the occupation is not covered,
then the program should be halted with an appropriate message.
3. Obtain the details of the car to be insured which consist of: make, model,
engine size in cc, age of car in years and current value in pounds. This
information should be saved as an appropriate fact.
Note: If this type of car is not in the car database, then the program is halted with
a suitable message.
4. Determine whether the insured wants third party or comprehensive cover.
5. Further insurance details are requested and saved. These are: whether an
immobiliser is installed, whether the car is parked in a garage overnight, whether
the insured has a driving conviction.
6. If the insured has a driving conviction within the last three years, then the type
of conviction speeding, careless or dangerous is requested to be entered.
Assume there is only one conviction. If there are no driving convictions then
request the number of years of no-claims bonus the insured has acquired. This is
then converted to a percentage discount and stored as a fact. The values are:
0 years 0%; 1 yr 10%; 2 yrs 15%; 3 yrs 30%; 4 yrs 45% and all others 60%.
Now the data has been obtained, the actual insurance cost is determined by means
of a set of rules which are applied in the following order (this must be adhered to as
different order of evaluation can lead to different results):
Calculate the basic cost which depends on the value and group. This is obtained by
multiplying the value by the following constants:
group 1 0.1; group 2 0.11; group 3 0.12; group 4 0.13; group 5 0.15; group 6 0.2.
If the car is over 7 years old then this calculated value is multiplied by 1.05.
If the insurance is third party, then the calculation is further multiplied by 0.3. The
final basic cost figure should be stored.
1. Determine security discounts. If the car has an immobiliser or is parked in a
garage overnight, then there is a reduction of 5%. It is still 5% if the insured has
both!
2. Determine the occupation discount. If a teacher or lecturer then there is 3%
discount. If a student, there is a surcharge of an extra £100.
3. Calculate the age discount. If the insured is older than 54, there is a discount of
10% as they are more careful drivers. If under 21, there is an additional surcharge
of 20%. If less than 26 and ≥ 21, an additional surcharge of 10%.
4. Calculate the conviction surcharge. If the insured has a speeding conviction, then
no extra charge, if careless driving a 10% increase and dangerous driving 20%
increase.
5. Finally the no claims discount is applied using the discounts given earlier. If the
insured is female there is an additional reduction of £50.
This completes the calculations. A summary should now be printed out indicating
the steps in the calculation leading to the final insurance cost. It is therefore
necessary to store the intermediate values as well as the current cost so far.
Requirements
A file of fully commented CLIPS code that can be loaded and executed without
error, and achieve the assignment demands. This is to be printed as hard copy, and
also emailed to me as a text file ([email protected]). Please use your user
number to name the file so that they are not confused. Ensure you have your name
commented in the file. Indicate in the hard copy whether there are any problems
with your program.
A printout of interaction with the working system, showing how it deals with a
sample of possible interactions. (use 'dribble' to obtain copies of interactive sessions).
The deadline for this exercise is Friday 18th March.

Documents pareils