You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
3. Forward Chaining 38<br />
First Come First Served<br />
<strong>flex</strong> toolkit<br />
The first come first served selection algorithm simply chooses the<br />
first rule in the agenda whose conditions (the if part) are all satisfied. This<br />
means that the order of rules in the agenda (actually represented as a list of<br />
rule names) is very important. The major benefit of this simple scheme is<br />
efficiency: firstly, during the cycle not all of the rules in the agenda are<br />
considered, and secondly, no stacks or heaps need be set up to store<br />
temporary sets of satisfiable rules.<br />
For example, if the agenda contained 1000 rules we might strike lucky and<br />
find that rule 5 can be fired.<br />
The major drawback is a lack of control when choosing rules, since the only<br />
control option available is to re-order the agenda. This, however, cannot<br />
always reflect the relative importance of rules.<br />
First come first served is the default selection algorithm for the ruleset.<br />
For example:<br />
ruleset mover<br />
contains push, pull, lift .<br />
ruleset make_tea<br />
contains all rules ;<br />
select rule using first come first served .<br />
The selection algorithm used in both of these examples will be first come<br />
first served.<br />
Conflict Resolution<br />
Conflict resolution is a more sophisticated and computationally expensive<br />
selection scheme whereby the "best" rule is always selected. A conflict occurs<br />
when more than one rule can be fired (i.e. the if conditions of more than<br />
one rule are satisfied). This conflict is then resolved by choosing the rule with<br />
the highest score. In the event of a tie the first is chosen.<br />
This scheme certainly allows far more control over the selection phase, but<br />
at a high cost. The "best" rule can only be chosen if every rule is considered.<br />
For example, if the agenda contains 1000 rules then all of them need to be<br />
tested, even though the best rule may be the 5th rule in the sequence. We<br />
do not know for certain that it is the best rule until the other 995 have been<br />
considered.<br />
The following example assesses the scores of the rules whose conditions are<br />
satisfied and fires the highest found.<br />
ruleset mover<br />
contains push, pull, lift