There is, but you have to look at things slightly differently - and we have to really work
on a new DRL to better support it, so it's all very experimental and bleeding edge.
It's also probably more lambdas and closures than pure functions.
Where I see lambdas helping is in creating meta control systems for expert systems,
attaching functions to events handlers. I'd quite like to see C# style delegator
operators, for compact ways of assigning event handlers.
I'd then like to start exposing subsystems event models and life cycles in DRL, to
have handlers added. These functions can have state (closures) and control how execution
happens. I sketched a document some time ago on ideas going on in my head - it's very
rough and much is already out of date on how I'd like to do it:
https://community.jboss.org/wiki/RuleModule
So for instance at the moment Drools has "activation-group", which provides hard
coded behaviour. What if instead we exposed the RuleModule (group) and it had events you
could attach to
onRuleAdded
onRuleRemoved
onBeforeRuleFired
onAfterRuleFired
I could add a function to "onAfterRuleFired" which would cancel all the other
waiting rules. So I'd like to actually expose a RuleModule in DRL as declarable
artefact (just a sketch, not working or compilable code)
module MyModule {
onAfterRuleFire() {
conflictSet.cancelAll();
}
}
While the above is declaration based approach, it could use an api approach too
getRuleModule( "MyModule" ).onAfterRuleFire += new RuleModuleEvent() {
conflictSet.cancelAll();
}
I'd more recently sketch out some ideas on controlling rule execution semantics -
based on the DADO research paper for "all" instances to be fired. If you scroll
down to the bottom, you can see a suggested life cycle for rule firings:
https://community.jboss.org/wiki/RuleExecutionSemantics
Other proposed life cycles:
OnBeforeMatchFire
Before a single Match instance is executed
OnAfterMatchFire
After a single Match instance is executed
onBeforeAllFire
Before any Matches in the set have fired
onAfterAllFire
After all Matches in the set have fired
onDeleteMatch
invoked when a Match is deleted (no longer true)
onUpdateMatch
invoked when a Match is updated
onChangeMatch
invoked when a Match is either updated or deleted
I'm also starting to prefer the C# "on" prefix notation for events.
I think as well instead of doing it initially in DRL, a lot can be done in pure Java with
annotations used for wiring and discovery. We can replace or atleast more easily expose
conflict handling and all the "group" stuff we have now. Note a lot of these
events already exist, but they are more for observing. So it's all about re-looking at
our events, and our sub systems, thinking about how they can be better exposed to create a
meta system.
@RuleModule( "MyModule" ) // RuleModule can be optional and inferred from class
name.
public class MyClassName {
@ConflictSet
private ConflictSet set; // Tells it to inject the conflict on instiation
public void onAfterRuleFired(Match match) {
set.canceAll()
}
}
So over all our longer term research is looking into a meta expert system - that looks at
better ways to expose sub systems and their life cycles and using event handlers to allow
the user to control the behaviour. I also think we'll need a sort of macro system, to
make this easily re-usable.
If this is work you are interested in research, then please pop onto irc - we'll be
happy to mentor.
http://www.jboss.org/drools/irc
Mark
On 7 Mar 2013, at 20:44, Matteo Mortari <matteo.mortari(a)gmail.com> wrote:
Ciao everybody, I have a question I would like to submit to this
community, given Drools is my preferred choice for Expert Systems :)
A quick background: I'm not an Expert Systems / Rule engines expert, but I'm a
happy power user "of Rules" since my CS Engineering thesis, a paper published,
and used it with happy results at work and hobby projects. Currently boarded on a new
project with Rules+Processes at work, and still very happy, so happy, I'm using Drools
again in a new hobby project. [semi-brag-mode off]
Now, in recent times, I cannot ignore what (apparently) is a strong renaissance of
Functional Programming, specifically all this momentum which Scala and Java 8's
Lambda's are getting.
The Question I'm asking myself: is there a specific, or few, areas where Functional
Programming could actually benefit Expert Systems so much to actually spawn new paradigms
of writing Rules? Or benefit in a new generation of the Rete algorithm?
Or actually, Functional Programming will spawn a completely different paradigm of system
which will go beyond Expert Systems the way are designed today?
Ignore my rant if you feel it's too generic, but I really wanted to seize a chance to
ask the question to this community :)
Thank you for your feedback,
Ciao,
Matteo
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users