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.

9. Flex Predicates 128<br />

forward_chain( +Selection,+Misfire,+Termination,+Update,+Agenda )<br />

Initiate a forward chaining session with the given selection algorithm and<br />

rule agenda.<br />

Selection is the name of the algorithm for selecting rules during each<br />

cycle of the forward chaining engine. There are three built-in algorithms:<br />

fcfs<br />

crss<br />

crss(T)<br />

First come first served.<br />

Conflict resolution scoring system.<br />

Conflict resolution with a threshold value.<br />

In addition, a user-defined algorithm can be nominated. For example,<br />

my_selector/3 randomly selects a rule from the agenda.<br />

my_selector( Agenda, Rule, Action) :-<br />

length( Agenda, N ),<br />

Posn is irand( N ) + 1,<br />

mem( Agenda, [Posn], Rule ),<br />

isa_rule( Rule, _, Action, _, _ ) .<br />

If the Selection algorithm fails then the call to forward_chain/5 will<br />

terminate.<br />

Misfire is the name of a program which is executed whenever the action<br />

associated with the selected rule fails.<br />

There are three built-in misfire programs :<br />

true<br />

fail<br />

misfire<br />

Ignore misfires.<br />

The original call to forward_chain/5 will also fail.<br />

Report the misfire and abort the process.<br />

In addition, the name of a user-defined program can be nominated, such as<br />

the following mf/1.<br />

mf( Name ) :-<br />

write( 'Rule has misfired ' - Name ), nl.<br />

Termination is a Prolog call which is tested during each and every cycle<br />

of the forward chaining engine. As soon as the Termination criterion<br />

succeeds the call to forward_chain/5 will terminate.<br />

In particular, if Termination is the atom fail, then the call to<br />

forward_chain/5 will only terminate when a situation arises in which no<br />

rules can be selected.<br />

Agenda and Update together specify the rule agenda, and how it changes<br />

after each cycle of the forward chaining engine.<br />

<strong>flex</strong> toolkit

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

Saved successfully!

Ooh no, something went wrong!