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 89<br />

satisfied with the highest score.<br />

ruleset example_set6<br />

contains all rules ;<br />

select rule using conflict resolution .<br />

Note that there is a high cost to using conflict resolution since every rule<br />

must be tested before the highest score is known.<br />

An adaptation of conflict resolution is to set a threshold value, so that the<br />

first rule whose conditions are satisfied and whose score is greater than the<br />

threshold value will be fired. This reduces the search somewhat.<br />

ruleset example_set7<br />

contains all rules ;<br />

select rule using conflict resolution<br />

with threshold 7 .<br />

The rules are selected using the conflict resolution scoring system with a<br />

threshold value (in this example the threshold value is 7).<br />

Finally, the <strong>flex</strong> programmer may specify a routine which makes a rule<br />

selection from the current agenda.<br />

ruleset example_set8<br />

contains all rules ;<br />

select rule using my_selector .<br />

Here <strong>flex</strong> will look for a program called my_selector/3 which should be<br />

defined with three arguments:<br />

my_selector( RuleAgenda, RuleConditions, Actions )<br />

where at the time of the call RuleAgenda will be instantiated to a list of the<br />

names of the rules currently in the rule agenda, and RuleConditions and<br />

Actions are variables which my_selector should bind to the conditions<br />

and actions respectively of the required rule. For more information see the<br />

description of the predicates new_rule/5, isa_rule/5 and<br />

forward_chain/5 in the "<strong>flex</strong> Predicates" chapter of this manual.<br />

Updating The Rule Agenda<br />

Each time a rule is fired, there is the option of updating the rule agenda for<br />

the next cycle of the forward chaining engine. The default is to leave the set<br />

of rules exactly as it is, so that the rules are always considered in the same<br />

order every time. Other options may be specified using the KSL keywords<br />

update ruleset<br />

The options are as follows.<br />

Each time a rule is fired it can be removed from the ruleset. This effectively<br />

<strong>flex</strong> toolkit

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

Saved successfully!

Ooh no, something went wrong!