java - random start in drools -
currently drl file looks 100+ rules.
rule "check 0" when ..... .......... end rule "check 1" when ..... .......... end rule "check 2" when ..... .......... end . . . . rule "check 100" when ..... .......... end
and have set sessionobject.fireallrules(1);
so iterate through rules rule 'check 0'
rule 'check 100'
, returns when ever falls under rule.
is way can start @ random rule instead of starting rule 'check 0'
every time.
i looking this.
start rule 'check 34'
iterate till rule 'check 100'
, iterate rule 'check 0'
rule 'check 33'
.
the idea of testing condition , executing action if true old computers. likewise, concept of ordering actions old. both have been implemented in various versions of known "procedural programming".
the requirements describe meet, , met by, "procedural programming" head-on.
of course, drools can made behave procedural program. so, answer question: yes it's possible, using salience.
rule "to fired first" salience 999999999 when ... ... end
simply use decreasing values, , defines order.
edit idea of randomizing rule firing isn't in rule-based-programming paradigm either. can mimick (why don't use procedural programming??) deriving salience fact attribute.
create 100 objects of class ranking fields int order
, int rank
. insert them order
set 1..100 , rank
random permutation of 1..100.
rule "number 49" salience $rank when ranking( order == 49, $rank: rank ) ... ... end
for next run, use permutation. rule lucky catch ranking rank==100
fire first.
Comments
Post a Comment