Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
42
Добавлен:
04.01.2020
Размер:
158.31 Кб
Скачать

Министерство образования и науки Российской Федерации

ФЕДЕРАЛЬНОЕ ГОСУДАРСТВЕННОЕ БЮДЖЕТНОЕ ОБРАЗОВАТЕЛЬНОЕ УЧРЕЖДЕНИЕ ВЫСШЕГО ПРОФЕССИОНАЛЬНОГО ОБРАЗОВАНИЯ

Новосибирский Государственный Технический Университет

Кафедра экономической информатики

Лабораторная работа № 3

по дисциплине "Интеллектуальные информационные системы"

на тему «Выбор подходящего тура»

Факультет: Бизнеса

Группа: ФБИ- 11

Выполнили: Шарук К.Е.

Косенко В.С.

Преподаватели: Бакаев М.А.

Новосибирск

2014

Цель работы:

Освоение основ проектирования ИС. Реализация структуры прототипа ИС в среде CLIPS.

Этапы выполнения работы:

  1. Цель создания ИС является выбор подходящего тура по введенным требованиям.

  2. Входной информацией является тип страны, стоимость поездки и уровень отеля. Сначала запрашивается цена тура (low или high), климат предполагаемой страны (cold и hot) и количество звезд желаемого отеля.

Краткое описание предметной области и цели ИС.

Предметная область: Фирма по подбору туров

Цель ИС: подобрать подходящий тур, основываясь на ответах клиента.

Текст программы:

;;;*************

;;;* CLASSES *(1)

;;;*************

(defclass Hotel

(is-a USER)

(slot hname)

(slot htelnumber)

(slot hstars)

)

;;;***********

;;;* FACTS *

;;;***********

(deffacts turi

(tur Shvecia high cold 4)

(tur Shvecia high cold 5)

(tur Laplandia low cold 3)

(tur Laplandia low cold 4)

(tur Turcia low hot 4)

(tur Turcia low hot 3)

(tur Tailand low hot 4)

(tur Tailand low hot 5)

(tur Goa high hot 5)

(tur Krim low hot 3)

)

;;;***************

;;;* FUNCTIONS *(4)

;;;***************

(deffunction add-hotel()

(printout t crlf "Input hotel name: ")

(bind ?hn (read))

(printout t crlf "Input telephone number: ")

(bind ?htn (read))

(printout t crlf "Input stars quantity: ")

(bind ?hs (read))

(make-instance ?hn of Hotel

(hname ?hn)

(htelnumber ?htn)

(hstars ?hs)

)

)

(deffunction price()

(printout t crlf "Input price (high or low): ")

(bind ?i (read))

(assert(req ?i))

)

(deffunction temp()

(printout t crlf "Cold or hot:" crlf)

(bind ?j (read))

(assert (req ?j))

)

(deffunction star()

(printout t crlf "3, 4 or 5:" crlf)

(bind ?str (read))

(switch ?str

(case 3 then

(bind ?k 3)

(assert (req ?k))

(undefrule not-three)

)

(case 4 then

(bind ?k 4)

(assert (req ?k))

(undefrule not-four)

)

(case 5 then

(bind ?k 5)

(assert (req ?k))

(undefrule not-five)

)

(default

(printout t crlf "ERROR")

)

)

)

;;;***********

;;;* RULES *(9)

;;;***********

(defrule input

(initial-fact)

=>

(printout t "Do you want to add new hotel into the base?(y/n):")

(bind ?ans (read))

(if (eq ?ans y) then

(add-hotel)

)

(price)

(temp)

(star)

)

(defrule price

(declare (salience 5))

(req ?i)

?low <- (tur ? low ? ?)

=>

(if (eq ?i high) then

(retract ?low)

)

)

(defrule temp-hot

(declare (salience 4))

(req ?j)

?fls <- (tur ? ? cold ?)

=>

(if(eq ?j hot) then

(retract ?fls)

)

)

(defrule temp-cold

(declare (salience 4))

(req ?j)

?fls <- (tur ? ? hot ?)

=>

(if(eq ?j cold) then

(retract ?fls)

)

)

(defrule not-three

(req ?k)

?thr <- (tur ? ? ? 3)

=>

(if (neq ?k 3) then

(retract ?thr)

)

)

(defrule not-four

(req ?k)

?fr <- (tur ? ? ? 4)

=>

(if (neq ?k 4) then

(retract ?fr)

)

)

(defrule not-five

(req ?k)

?fv <- (tur ? ? ? 5)

=>

(if (neq ?k 5) then

(retract ?fv)

)

)

(defrule clearing

(declare (salience -1))

?req <- (req ?)

=>

(retract ?req)

)

(defrule result

(declare (salience -2))

(initial-fact)

=>

(retract 0)

(printout t "Turi: " crlf)

(facts)

(save-facts "required_turi.txt")

)

;;;**************

;;;* HANDLERS *(7)

;;;**************

(defmessage-handler Hotel print-hotel()

(printout t ?self:hname crlf)

(printout t ?self:htelnumber crlf)

(printout t ?self:hstars crlf)

)

(defmessage-handler Hotel pick-hname()

(printout t ?self:hname crlf)

)

(defmessage-handler Hotel pick-htelnumber()

(printout t ?self:htelnumber crlf)

)

(defmessage-handler Hotel pick-hstars()

(printout t ?self:hstars crlf)

)

(defmessage-handler Hotel hname-put(?value)

(bind ?self:hname ?value)

)

(defmessage-handler Hotel htelnumber-put(?value)

(bind ?self:htelnumber ?value)

)

(defmessage-handler Hotel hstars-put(?value)

(bind ?self:hstars ?value)

)

Пример поиска тура и добавления отеля.

  1. Поиск тура в теплую страну по соответствующим запросам.

  1. Поиск тура в холодную страну по соответствующим запросам.