On 10/05/2013, Sonata <plz.write.to(a)gmail.com> wrote:
Yes, now I know the benefit of this approach, now I am wondering why
we are
only left with one option?
Agenda groups are a way to control the sequencing of rule firings -
they were never meant to control rule evaluation.
Could I propose a new and easy API that you can create a session from kbase
with rules in a particular agenda-group(s)? Then start inserting fact to
that session, so that rules in other agenda-groups will not be evaluated
under this user's choice.
If you put the rules of a group into one (or more) drl files, you can
compile them into separate .pkg files, which can then be used,
individually or combined, into a KB.
Until then, do you think maintaining different kbases for each agenda-group
(i.e. one agenda-group in one kbase) is a good idea?
Might be, depends on the use case.
When rules in an agenda-group are needed to be fired, that kbase is used to
create session(s). When rules across more than one agenda-groups are needed
to be fired, those kbases can be added together to form a bigger kbase to
create a session.
Can be handled with separately compiled groups as well.
This method is not perfect nor an ultimate solution. This is just a trade
off for performance vs flexibility. By doing that, we for sure cannot write
dynamic agenda-group focusing rules (those rules will not break down, just
there will be no such group for that session) and which groups to fire must
be planned beforehand.
It's also possible to have several sessions running in parallel, and
you can pass facts (according to results obtained in the first
session) to the next session, etc.
Yet another idea might be to use an explicit Focus fact with an
attribute that controls whether a rule should be evaluated or not.
Using extends makes this
just as terse as using the attribute, and changing the Focus is done
by a simple modify.
rule StatusOne
when
Focus( value == "one" )
then
end
rule "xyz in group one" extends StatusOne
when
... the conditions for xyz in group one...
then ... end
Given that this can be easily extended to have rules that are in more
than one group, this is even superior to agenda group.
-W