pub:projects:samurai:cases:ploc
Table of Contents
PLOC
- ploc-rules.txt - 49 rules
Model in CLIPS
- Model 1: ploc-clips.clp
- Rules: 31
- Uwagi:
- It is necessary to use module mechanisms in order to avoid infinite recursion of rules that modify the facts that are also in their LHS.
- In order to decrease number of rules, the predicates
member$
andcreate$
were used for creation of multifield value (see heremember$
) - It is necessary to set fact duplication to true in order to assert a number of the same insurance base charge modifiers
(set-fact-duplication TRUE)
- It is not possible to express infinity (e.g. in case of declaring ranges of allowed values)
Model in Jess
- Model 1: ploc-jess.clp
- Rules: 31
- Uwagi:
- Jess does not allow for using '(range)' construct within
slot
definition - the domain of slots can be set by using(allowed-values)
. However listing of all values from range e.g. [18, 120] is inefficient. - Jess does not allow for fact duplication
Fact-duplication concept eliminated – fact duplication is never allowed. Fact list stored on a HashMap, not a Vector. 1)
- Model 2: ploc-jess-v2.clp
- Rules: 32
- Uwagi:
- The calculation rule uses
accumulate
CE and thus it is fired one instead of several times (for eachbase-modifier
fact).
Model in Drools
- Model 1: ploc.java ploc-drools.drl
- Rules: 32
- Uwagi:
- Drools does not support neither default value nor constraints for fact fields.
- The list of allowed values
allowed-type
can be defined using JAVAenum
types. - Modules in Drools does not have to be defined explicitly - they are automatically defined while first rule assignment
- Drools does not support any construct with the semantics of
(pop-focus)
. However, this construct can be approximately simulated in drools usinglock-on-active
property which prevents rule, with this property set to true, from firing until theiragenda-group
will not loose a focus. In comparison to(pop-focus)
this property does not remove focus from the current module and thus other rules can also be fired after rule having this property set to true. - The multifield values from clips and jess that are created using
(create$)
function, can be represented using Java collections (sometimes such rules must be expressed in java dialect):
CLIPS:(create$ 160 60 0 -10 -20 -30 -40 -40 -50 -50 -60)
Java:
List<Integer> modifiers = Arrays.asList(160, 60, 0, -10, -20, -30, -40, -40, -50, -50, -60);
- The management of focus stack in Drools can be distributed on DRL and JAVA files. Drools allows for set the focus stack in the same way as
CLIPS
orJess
:
CLIP/Jess(focus base-charge bonus-malus base-charge-modifiers)
and corresponding code in Drools:
ksession.getAgenda().getAgendaGroup("base-charge-modifiers").setFocus(); ksession.getAgenda().getAgendaGroup("base-charge").setFocus(); ksession.getAgenda().getAgendaGroup("bonus-malus").setFocus(); ksession.getAgenda().getAgendaGroup("initial").setFocus();
Nevertheless, this can be done only within the Java file. In order to provide more more reliable translation from CLIPS/Jess to Drools the above setup of focus stack can be translated in the following way:
- For each drools application, the java file push the first
agenda-group
(e.g. initial) on the focus stack. - Within this
agenda-group
only one rule is defined - LHS-less rule that asserts all the initial facts. Such rule corresponds todeffacts
CLIPS/Jess construct. - In the RHS of this rule, the focus stack is defined e.g.
drools.setFocus("base-charge-modifiers"); drools.setFocus("base-charge"); drools.setFocus("bonus-malus");
the order of the
agenda-grop
names must be reversed in comparison to the order of the names withindeffacts
construct.
- Model 2: ploc.java ploc-drools-v2.drl
- Rules: 33
- Uwagi:
- The calculation rule uses
accumulate
CE and thus it is fired one instead of several times (for eachbase-modifier
fact).
Model in XTT2
- Model 1: ploc-xtt.hml
- Rules: 57
- Uwagi:
pub/projects/samurai/cases/ploc.txt · Last modified: 2016/01/05 22:32 by 127.0.0.1