Создание экспертной системы продукционного типа, страница 3

                    write("Please input: "), nl,

                    write("mark: "), readln(Mark),nl,

                    write("model: "), readln(Model),nl,

                    write("class: "), readln(Cl), nl,

                    write("body type: "), readln(BT), nl,

                    write("number of doors: "), readint(Nd), nl,

                    write("wheel drive: "), readln(WD), nl,

                    write("power: "), readreal(Pw), nl,

                    write("transmission: "), readln(TM), nl,

                    write("petrol cunsumption: "), readreal(PC), nl,

                    write("price: "), readreal(Pr),

                    assertz(vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr)),

                    save("d:/iis/cars.txt"), fail.

doaction(10):-write("Good bye! \n"). %, save("d:/iis/cars.txt").

doaction1(1):-

                    cheap(Mark, Model, 100000),

                    vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr),

                    write("class: ", Cl), nl,

                    write("body type: ", BT), nl,

                    write("number of doors: ", Nd), nl,

                    write("wheel drive: ", WD), nl,

                    write("power: ", Pw), nl,

                    write("transmission: ", TM), nl,

                    write("petrol cunsumption: ", PC), nl,

                    write("price: ", Pr), nl, fail.

doaction1(2):-

                    economic(Mark, Model),

                    vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr),

                    write("class: ", Cl), nl,

                    write("body type: ", BT), nl,

                    write("number of doors: ", Nd), nl,

                    write("wheel drive: ", WD), nl,

                    write("power: ", Pw), nl,

                    write("transmission: ", TM), nl,

                    write("petrol cunsumption: ", PC), nl,

                    write("price: ", Pr), nl, fail.

goal

consult("G:/IIC/Saharova/cars.txt"),

%save("d:/iis/cars.txt").

dialog.
База знаний в cars.txt

vehicle("daewoo","matiz","a","hatchback",5,"fwd",51,"at",5.6,8900)

vehicle("daewoo","matiz","a","hatchback",5,"fwd",63,"mt",6.5,9500)

vehicle("kamaz","oka","a","hatchback",3,"fwd",30,"mt",5.5,5500)

vehicle("chevrolet","aveo","b","sedan",4,"fwd",84,"at",8.6,12000)

vehicle("lada","kalina","b","sedan",4,"fwd",98,"mt",8.3,9000)

vehicle("honda","civic","c","sedan",4,"fwd",201,"at",12,22500)

vehicle("mitsubishi","lancer","c","sedan",4,"fwd",122,"mt",10.3,18000)

vehicle("volvo","s60","d","sedan",4,"awd",140,"mt",11.5,25000)

vehicle("toyota","allion","c","sedan",4,"awd",122,"at",9.8,18000)

vehicle("toyota","allion","c","sedan",4,"fwd",122,"at",9.8,18000)

vehicle("kamaz","oka","a","hatchback",3,"fwd",43,"mt",6.1,5500)

vehicle("honda","civic","c","hatchback",3,"fwd",201,"at",12,20500)

vehicle("honda","civic","c","hatchback",5,"fwd",201,"at",12,23500)

vehicle("volvo","s60","d","sedan",4,"awd",195,"at",19.5,39500)

economicpc(1,14)

economicpc(2,9)

economicpc(3,7)

naturewd("yes","awd")

naturewd("no","fwd")

boot_bodytype("yes","hatchback")

boot_bodytype("no","sedan")

extrans("yes","mt")

extrans("no","at")

peopledoors(2,3)

peopledoors(3,4)

peopledoors(4,5)

peopledoors(4,4)

peopledoors(1,3)

power("yes",120)

power("no",80)

mark("toyota","japan")

mark("mitsubishi","japan")

mark("lada","russia")

mark("kamaz","russia")

mark("deawoo","uzbekistan")

mark("honda","japan")

mark("chevrolet","usa")

mark("usa","reliable in service")

country("uzbekistan","balance functional-price")

country("russia","cheap services")

country("japan","hight tech car")

classofcars("a","rather compact and economic then comfort of driver")

classofcars("b","'driver's car' comfort for driver")

classofcars("c","'driver's car' comfort for driver, has most features then B class")

classofcars("d","bussines class, most fits for bussines people")

bodytype("sedan","boot isn't spacious")

bodytype("hatchback","boot is very spacious")

weeldrive("awd","hight cross-country ability")

weeldrive("fwd","general cross-country ability")

cross_country("hight cross-country ability","increased petrol cunsumption")

cross_country("general cross-country ability","decreased petrol cunsumption")

transmission("mt","manual gearbox")

transmission("at","automatical gearbox")

gearbox("manual gearbox","demand experience of driver")

gearbox("automatical gearbox","fits for beginner driver")
Результаты тестировния:

Исходное меню программы:

1.  Выберем пункт 1 для просмотра базы данных:


2.  Найдем заданный автомобиль:

3.  Под этим пунктом система помогает подобрать автомобиль на основе предварительных вопросов:

4.  Вывод знаний

Вывод: Была спроектирована и реализована в программной среде Visual Prolog 5.2 экспертная система помогающая осуществить выбор автомобиля, а также выдающая некоторую дополнительную информацию, позволяющая пользователю самостоятельно выбрать автомобиль на основе выданных экспертной системой знаний. Было проведено успешное тестирование созданной экспертной системы.