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.

7. Knowledge Specification Language 86<br />

Rulesets<br />

The ruleset is the construct which governs the running of the forward<br />

chaining engine. Defining the ruleset determines which rules will be<br />

considered for firing (i.e. the initial rule agenda), in what order they will be<br />

considered, when the forward chaining will terminate etc.<br />

Recall that each cycle of the forward chaining engine fires one rule, that rule<br />

being the first rule found whose conditions are satisfied (or the rule with the<br />

highest score out of all rules whose conditions are satisfied, if conflict<br />

resolution is being used). The search for the rule to fire always starts at the<br />

beginning of the list of rules in the current rule agenda. Rules may be<br />

removed, added or re-ordered after each cycle.<br />

A <strong>flex</strong> program is run by starting the forward-chaining engine, using the<br />

KSL directive invoke ruleset; normally this will be as part of an<br />

action, which can then be run from the Prolog command line as a normal<br />

Prolog query.<br />

Within a ruleset you can specify:<br />

• The initial rule agenda (this is mandatory).<br />

• The initiation directives to be performed prior to starting the engine.<br />

• The conditions which can terminate the engine.<br />

• The rule selection algorithm to be used.<br />

• The rule agenda update algorithm to be used.<br />

• The procedure to be used when a rule misfires.<br />

Any combination of the above specifications may be included in the<br />

definition of a ruleset. The only specification which is mandatory is the initial<br />

rule agenda; all other specifications are optional.<br />

The most general format of a ruleset is as follows.<br />

ruleset Name<br />

contains rule(s) ;<br />

initiate by doing directive(s) ;<br />

terminate when conditions(s) ;<br />

select rule using rule_selection ;<br />

update ruleset agenda_update ;<br />

when a rule misfires do directive(s) .<br />

Specifying The Initial Rule Agenda<br />

The simplest declaration of a ruleset is just to state which rules are to be<br />

used, using the KSL keyword<br />

<strong>flex</strong> toolkit

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

Saved successfully!

Ooh no, something went wrong!