Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking for something more lightweight than a rules engine

 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Back in a different geological epoch I built a lot of expert systems. I'm a little rusty, but I think I can say that the system I used the most (TIRS), was a "frame-based" kind of system. Maybe not truly frame-based, but at least kind of frame-based. By "frame-based" I mean a system where you could create class-like templates (frames) and then instantiate them. Then, you could write "rules" that could take the general form:

if there exists an instance of frame X and
if there exists an instance of frame Y and
if there exists an instance of frame Z such that
X.a == Y.e and
X.b == Z.m and
Y.f == Z.n

then do stuff...


Sometimes it felt almost like weird, in-memory SQL queries.

Anyway, I have a Java app. where I need to create a lot of rules (maybe 25 to 50 rules?), like the one I showed above. A really horrible way to do it is to create nested loops (foreach X, Y, Z). I've written a few of those "rules" and they kind of make me throw up in my mouth a little

In my case, I think it's okay to hard code the order in which these rules will "fire" (be executed).

So the question is, is there a cleaner, fairly lightweight way to implement rules like this as a part of a larger Java app?

I remember looking at Jess a long time ago and feeling like it was very capable, but also probably not very lightweight from either a performance or "brain investment" perspective. Maybe I'm wrong about that?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know nothing about Rules Engines but I did fine a list of rules engines written in Java. Might help you find something "lighter".
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gregg,

I guess I posted this here because I'm wondering whether there is some sort of OO or patterns approach to this kind of design that I'm not familiar with. I'd really rather not go down any sort of "rules engine" approach if I can help it. These so-called "rules" are going to have to be executed thousands of times during an interaction.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel like I'm carrying coals to Newcastle here (or owls to Athens)...

Buschmann et al. discuss the Blackboard Architectural Pattern in Pattern-Oriented Software Architecture � A System of Patterns Volume 1 (POSA1) (pp.75-95) which may be applicable in this case.

However it would be difficult in a case like this to tell where you cross the line towards building your own microworld expert system/rules engine - at which point using a more general pre-existing implementation would make more sense.
 
M Easter
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently caught a presentation on JESS at a Java conference. At first blush, I would consider a rules engine.

The 2 dominant ones seem to be JESS and Drools. JESS is based on older technology, and uses a Lisp-like syntax for the rules. However, the speaker said that it can execute 80K rules/second, so performance may not be a problem.

On the other hand, here is an entry-level article on Drools:

http://thediscoblog.com/2007/02/25/curtail-complexity-with-a-rules-engine/

On the _other_, other hand, I too have wondered about basic OO pattern that might work in simple instances. Imagine a Predicate interface like so:



A CompositePredicate could chain together individual predicates, where each one contains a given "rule". Things get a bit muddy here but I'm thinking of the composite pattern combined with a "filter" pattern. It is hard to tell if this would fit your situation.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
josql is an interesting api that allows you to query in memory Objects. Not really a rules engine, but powerful...

http://josql.sourceforge.net/index.html
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far so cool!

That joSQL thingy looks pretty interesting. I'm open for more ideas, and I'll keep you all posted.
 
Naveen K Garg
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bert,

I have used JBoss Rules in couple of Java Application. The results are quite good. I would strongly suggest to use this as it also have a small memory footprint.

Regards
Naveen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic