[[.:..:start|Powrót do samurai:start]] ====== PLOC ====== * {{.:pl-oc.pdf|Orginal rules}} * {{.: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$'' and ''create$'' were used for creation of multifield value (see here ''[[http://clipsrules.sourceforge.net/documentation/v630/bpg.htm#_Toc60827878|member$]]'') * It is necessary to set fact duplication to true in order to assert a number of the same insurance base charge modifiers ''[[http://clipsrules.sourceforge.net/documentation/v630/bpg.htm#_Toc60828120|(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.// ((http://www.jessrules.com/doc/70/changes.html)) * 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 each ''base-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 JAVA ''enum'' 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 using ''lock-on-active'' property which prevents rule, with this property set to true, from firing until their ''agenda-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 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'' or ''Jess'': \\ 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 to ''deffacts'' 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 within ''deffacts'' 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 each ''base-modifier'' fact). ===== Model in XTT2 ===== * Model 1: {{.:ploc-xtt.hml|}} * Rules: 57 * Uwagi: