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.

3. Forward Chaining 36<br />

The basic cycle of chosing a rule and then firing that rule remains, but with<br />

some elaborations.<br />

1. In the simple model, the engine fires the first rule whose if part is satisfiable. A<br />

more sophisticated approach is to go through all the currently available rules,<br />

and check which ones are satisfiable. This forms a conflict set. Some algorithm<br />

is then used to select a rule to fire from this conflict set (this is called conflict<br />

resolution).<br />

2. In the simple model, the engine terminates only when no more rules can be<br />

selected. In the extended model the user can specify an alternative criterion (a<br />

Prolog call) for early termination. The engine will terminate as soon as the call<br />

succeeds, regardless of whether there are more rules which could be fired.<br />

3. The extended model also allows for the handling of the misfiring of rules. A rule<br />

is said to misfire if its conditions are satisfied but its actions fail for some reason.<br />

A recovery corresponds to the specified misfire program succeeding, in which<br />

case the cycle completes and the engine carries on. Otherwise an error<br />

condition is raised.<br />

4. The final extension to the simple model concerns the rule agenda, from which<br />

rule selections are made during each and every cycle of the engine. This agenda<br />

can be updated at the end of each cycle according to which rule was fired<br />

during that cycle. For example, removing that rule from the agenda means that<br />

rules can only be fired at most once during that particular forward chaining<br />

session. Other possibilities include re-ordering the list of rules thus making it<br />

more likely that certain rules will be fired next time.<br />

Ruleset<br />

Rules are grouped together into rulesets, and forward chaining is started<br />

using the KSL keywords invoke ruleset. This provides a construct for<br />

forming rules into stratified rule-bases and governing the forward-chaining<br />

engine in terms of rule selection method and agenda updating.<br />

For example, to move a piece in a game we might have a ruleset called<br />

make_move containing rules for possible moves.<br />

ruleset make_move<br />

contains corner_move, edge_move, centre_move .<br />

action move ;<br />

invoke ruleset make_move .<br />

<strong>flex</strong> toolkit

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

Saved successfully!

Ooh no, something went wrong!