Пример 9.9. Правила determine-low-output и determine-point-surface-state


(defrule determine-low-output ""

(working-state engine unsatisfactory)

(not (symptom engine low-output | not-low-output))

(not (repair ?))

=>

(if (yes-or-no-p "Is the output of the engine low (yes/no)? ")

then

(assert (symptom engine low-output))

else

(assert (symptom engine not-low-output)))

)

(defrule determine-point-surface-state ""

(or (and (working-state engine does-not-start)

(spark-state engine irregular-spark))

(symptom engine low-output))

(not (repair ?))

=>

(bind ?response (ask-question "What is the surface state of the

points (normal /burned /contaminated)?"

normal burned contaminated))

(if (eq ?response burned)

then

(assert (repair "Replace the points."))

else

(if (eq ?response contaminated)

then

(assert (repair "Clean the points."))))

)

 

Правило determine-low-output определяет, имеет ли место низкая мощность двигателя или нет. Правило determine-point-surface-state адекватно реаги­рует на условия, заданные в правилах 7 и 12. Обратите внимание на исполь­зование условных элементов or и and, которые обеспечивают одинаковое поведение правила в двух абсолютно разных ситуациях. Кроме того, прави­ло determine-point-surface-state отличается от приведенных ранее тем, что непосредственно использует функцию ask-question, вместо yes-or-no-p, т. к. в данный момент пользователю задается вопрос, подразумевающий три варианта ответа.

Реализация оставшихся диагностических правил (8—11) также не должна вызвать у вас затруднений.

Пример 9.10. Оставшиеся диагностические правила

(defrule determine-conductivity-test ""

(working-state engine does-not-start)

(spark-state engine does-not-spark)

(charge-state battery charged)

(not (repair ?))

=>

(if (yes-or-no-p "Is the conductivity test for the ignition coil positive(yes/no)? ")

then

(assert (repair "Repair the distributor lead wire."))

else

(assert (repair "Replace the ignition coil.")))

)

(defrule determine-sluggishness ""

(working-state engine unsatisfactory)

(not (repair ?))

=>

(if (yes-or-no-p "Is the engine sluggish (yes/no)? ") then

(assert (repair "Clean the fuel line."))) ) (defrule determine-misfiring ""

(working-state engine unsatisfactory) (not (repair ?))

(if (yes-or-no-p "Does the engine misfire (yes/no)? ")

then

(assert (repair "Point gap adjustment."))

(assert (spark-state engine irregular-spark)))

)

(defrule determine-knocking ""

(working-state engine unsatisfactory)

(not (repair ?))

=>

(if (yes-or-no-p "Does the engine knock (yes/no)? ")

then

(assert (repair "Timing adjustment.")))

)

Последние штрихи

Внимательно взглянув на список правил, мы увидим, что некоторые прави­ла (2, 3 и 13) остались до сих пор не реализованными.

В качестве реализации правила 13 мы будем использовать правило no-repairs, приведенное в примере 9.11.



Дата добавления: 2021-12-14; просмотров: 222;


Поиск по сайту:

Воспользовавшись поиском можно найти нужную информацию на сайте.

Поделитесь с друзьями:

Считаете данную информацию полезной, тогда расскажите друзьям в соц. сетях.
Poznayka.org - Познайка.Орг - 2016-2024 год. Материал предоставляется для ознакомительных и учебных целей.
Генерация страницы за: 0.009 сек.