24.11.2014 Views

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11. Example – Robbie Goes Shopping 162<br />

rule pack_frozen_item<br />

if the shopping includes an Item<br />

and the Item`s condition is frozen<br />

then pack_item( Item ) .<br />

rule pack_large_bottle<br />

if the shopping includes an Item<br />

and the Item`s container is a bottle<br />

and the Item`s size is large<br />

then pack_item( Item ) .<br />

rule pack_other_large_item<br />

if the shopping includes an Item<br />

and the Item`s size is large<br />

then pack_item( Item ) .<br />

rule pack_medium_item<br />

if the shopping includes an Item<br />

and the Item`s size is medium<br />

then pack_item( Item ) .<br />

rule pack_small_item<br />

if the shopping includes an Item<br />

and the Item`s size is small<br />

then pack_item( Item ) .<br />

The initial rule agenda should be structured to reflect the order in which the<br />

rules are meant to be fired (i.e. check for frozen items first, then large bottles<br />

etc.).<br />

We note that if the conditions of a rule are not satisfied, they will not<br />

become satisfied at any later stage. In this case the most efficient way to<br />

update the rule agenda is to remove any unsatisfied rules.<br />

The ruleset which governs this use of the forward chaining rules is defined in<br />

the following way. The order and contents of the initial rule agenda is<br />

determined in the ruleset, by the part indicated by the KSL keyword<br />

contains.<br />

ruleset packing_rules<br />

contains<br />

pack_frozen_item,<br />

pack_large_bottle,<br />

pack_other_large_item,<br />

pack_medium_item,<br />

pack_small_item ;<br />

select rule using first come first served ;<br />

update ruleset by removing any unsatisfied rules .<br />

Packing The Items<br />

<strong>flex</strong> toolkit<br />

We do not know in advance how many carrier bags will be needed when<br />

packing the groceries. So, each carrier bag must be generated as and when

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!