This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes General Computing and the fly likes rules engine decision table book or web page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "rules engine decision table book or web page" Watch "rules engine decision table book or web page" New topic
Author

rules engine decision table book or web page

Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
Can anyone point me to a decent primar on the subject of programming rules engines and utilizing decision trees. Its a new field to me, but a requirement on a project I am on, and I don't know the first thing about it.
Thanks in advance


Sun Certified Java Programmer Java 2<P>Jeff Gaer
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

I found Introduction to Expert Systems by Peter Jackson on Amazon. It makes reference as well to an expert system called CLIPS, which is the predecessor to a Java rules engine called Jess.
These might be worth investigating; I've never had time to peer into this subject much myself but I'm eager for a look-see.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Jess has a horrible Lisp-like langauge.
(combination (letter A) (number ?a&~?d&~?t&~?l&~?r))
(unique (combination (letter E) (number ?e&~?d&~?t&~?l&~?r&~?a&: (= (mod (+ ?d ?d
(* 10 ?l) (* 10 ?l)
(* 100 ?a) (* 100 ?a))
1000)
(+ (* 100 ?e) (* 10 ?r) ?t)))))
;; (unique (combination (letter E) (number ?e&~?d&~?t&~?l&~?r&~?a&: (java-test jess.examples.fastword.FindSolution3))))
- this is from examples shipped with Jess.
I think, it's unreadable.
Other alternatives include CommonRules and Flex (this one is free, so you can play with it!)
Like Michael Ernest, I did not went too deep in any of them, so the links above are the best help I can provide
--------------------
"There are no answers, only cross references."
[ May 22, 2002: Message edited by: Mapraputa Is ]

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
Thanks for the reply, I did manage to turn up a promising solution called mandarax. Its open source (gnu license), the documentation was less than 30 pages, and even understandable. Here's the link if anyone is interested. I'll post again was I reach the point of success/failure.
http://www.mandarax.org
btw, thanks for helping create the RHE book, it was excellant, I credit it and the exam cram book with getting me my certification on the first pass, and was so good I've kept it as a reference for the gotchas of java.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

We three of the RHE say "you're welcome!" Our pleasure.
The syntax of Jess is what kept me away too. I had the all-too-common reaction of looking at it and thinking there was something I just didn't get about expert systems. I had the same reaction to math when I first got to college -- WTF are all these symbols? Did I miss a year of high school? -- then later figured out that geek math people just like all manner of queer symbols. I finally caught on when I saw Hungarian notation -- then I knew they were just messing with us.
Thanks for the link, Jeff -- I'll go check it out. Maybe I'll finally get interested.
[ May 23, 2002: Message edited by: Michael Ernest ]
Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
I'm REALLY pleased with Mandarax. It reads and writes RuleML xml rules, and there is a GUI editor( alibeit a limited one) to make it a bit simpler.
On the downside it doesn't support negation (yet).
The author is great about providing support. I know nothing about inference engines, but was able to populate a knowledge base with some simple rules and write the code to run queries against it in less then a week ( less than 20 lines of code). I'd imagine there are a lot of limitation compared to Jess, but I only needed a simple engine and it meets my needs. Your mileage may vary.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
There's information here at the Ranch, too. I reviewed a book about writing your own expert system ( http://www.coderanch.com/t/93222/Book-Reviews/Constructing-Intelligent-Agents-Java )
I used some of the ideas from this book to seed further research and eventually produced my own expert system "inkling". there's also a JSR for a rules engine API, but they don't seem to have published anything yet.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
Frank, what sort of work do you get 'inkling' to do ?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Not much, at the moment. I have it partly configured as a design rules assistant for "Car Wars" (but the 'old' rules have now been deprecated), and sort of have it available as a plug-in to my portal/webmining framework "Wayne".
Mainly though, I'm still in need of a serious application for it, to give the impetus to move from a theoretically capable system to one which is useful in practice.
For interest, major design goals for Inkling included:
  • A complete separation of rules and state/values, so that a single Inkling "engine" can be processing several queries on the same rulebase at once. Most such systems mix rules and data and have to clone the whole huge mess to run parallel queries.
  • expressive yet simple XML syntax for rule definition, data assertion and query specification. From what I've seen RuleML is (like SOAP) much too wordy for its own good. RuleML reads like LISP-with-angle-brackets.


  • When I next get some time to work on my own projects, I plan to get a demonstration application of Inkling running on the web, which should make things much clearer. For now it's just one of my thirty-or-so projects in a not-quite-releasable state
    Jeff Gaer
    Ranch Hand

    Joined: Jun 04, 2001
    Posts: 99

    For interest, major design goals for Inkling included:
    A complete separation of rules and state/values, so that a single Inkling "engine" can be processing several queries on the same rulebase at once. "

    Madarax accomplishes this by allowing the use of a database for facts. Whats nice for large amounts of data you get the speed of the database for resolving facts but the convenience of a text based rules editor for applying business logic. The predicates on those facts that are in the database translate into configurable queries. I've only played with that with some simple cases, but it seems to work well.
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    Interesting. I'll go look at Mandarax.
    Do you know if Mandarax separates "static" or "environment" facts from the fact assertions which are part of the setup for a query? I found that this was vital to allow effective simultaneous queries on the same rule/fact base.
    I haven't looked at Mandarax, but the half-dozen or so others I looked at were far too clumsy for effective multi-user use. They seemed to come from a tradition of single-user or single-threaded applications which appears archaic today.
    To be able to use a rulebase in (for example) a web application, you need to be able to run as many lightweight queries (with parameter fact assertion, forward/backward chaining, result querying and so on) through the same rule/fact base as you have concurrent requests. The lack of this, combined with typically obscure rule syntax, is what led me eventually to write my own.
    Jeff Gaer
    Ranch Hand

    Joined: Jun 04, 2001
    Posts: 99

    Interesting. I'll go look at Mandarax.
    Do you know if Mandarax separates "static" or "environment" facts from the fact assertions which are part of the setup for a query? I found that this was vital to allow effective simultaneous queries on the same rule/fact base.

    There are several methods for accomplishing this in mandarax. The rules are passed to the engine with each query so that one can maintain a base set of rules from an original copy separate from
    those rules associated with state, particularly on a thread by thread basis.
    There is also a capability to remove a rule from the knowledge base, though I haven't used that. Lastly the use of a datastore for a fact base allows multiple tables to be associated with state in one and logic in one or more tables.

    I haven't looked at Mandarax, but the half-dozen or so others I looked at were far too clumsy for effective multi-user use. They seemed to come from a tradition of single-user or single-threaded applications which appears archaic today.

    I haven't received an answer on the threading issue yet, but since the fact base ( state) is maintained separately, I imagine that it should be thread safe.

    To be able to use a rulebase in (for example) a web application, you need to be able to run as many lightweight queries (with parameter fact assertion, forward/backward chaining, result querying and so on) through the same rule/fact base as you have concurrent requests. The lack of this, combined with typically obscure rule syntax, is what led me eventually to write

    Mandarax supports RuleML and also a enhanced variant RuleXKB that while not exactly user friendly is orders of magnitude simpler then JESS. There is also an nice gui based rules editor available. The downside is the functionality is still relatively simple, negation is not supported nor forward chaining. You might consider combining efforts with the author on this, He's got a good base in place, the proof being that a rules newbie like me is able to apply the engine in a real application, but I think time constraints will prohibit his adding all the features you need in a timely fashion. It is open source so itt might well be a good starting point for you otherwise.
    Jeff Gaer
    [ June 05, 2002: Message edited by: Jeff Gaer ]
    [ June 05, 2002: Message edited by: Jeff Gaer ]
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    I've now looked at Mandarax a bit more. It's still not clear to me how well it separates transient query state information from static environment state information, but I will definately look more deeply when I have more time.
    I like the idea of the database-backed fact groups, and can see why that choice has led to limiting it to backward chaining only. I think some of the arguments in the documentation for this are a bit over the top though. Some problems just work much better with forward chaining.
    I'm now looking forward to studying the Mandarax source code, and trying a few benchmark trials to see how it really compares against my own attempt.
    Mandarax is definately the closest yet to the sort of "practical" knowledge base / expert system which can actually be used in real applications.
    Well, except for my own, of course
    markus leppaenen
    Greenhorn

    Joined: Jun 11, 2002
    Posts: 1
    Hi Frank and Jeff,
    we�re a group of 3 three students studying business administration and we�ve got to evaluate some rule engines for a project. We�ve found most info on Jess and Mandarax so we focused on them.
    So if you find more advantages/disadvantages, similarities or differences between them, we would be glad,if you could tell us, as we�re not very much into programming.
    Frank, you said that forward chaining works better for some problems, which?
    cheers
    markus
    [ June 11, 2002: Message edited by: markus leppaenen ]
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    Forward chaining usually works best for "analysis" and "validation" type prblems.
    Imagine, for example, an expert system which is given a specification for a PC, and the desired output is a table of expected benchmark figures and a list of any compatibility issues between components.
    You could try backward-chaining from each issue it knows about, to see if the problem applies, but that seems very inefficient. Much better to insert the specification data and forward-chain until no more rules can fire. If/when a compatibility problem rule becomes true, then it can add itself to the output list.
    There are a lot of problems in this class, including the medical diagnosis and categorization processes which started the whole expert systems business.
    Jens Dietrich
    Greenhorn

    Joined: Jun 07, 2002
    Posts: 1
    Hi Jeff and Frank,
    I just wanted to reply to the issue of separating transient query state information from static environment state information. Indeed, one way to achieve this is to hold various copies of the same knowledge base. But this approach may lead to problems concerning the consistency of the knowledge base, and all changes in the rule base must be propagated to all copies.
    A better approach is an implementation of a clause set based on a knowledge base. This would allow separate knowledge bases 'linking in (referencing)' the master knowledge base. I am currently designing something similar: a clause set based on a combination of a query/a knowledge base/ an inference engine. The idea is that the clause set at evaluation time issues the queries and facts are built for each result (substitution found). This facilitates building 'knowledge clusters' according to the principle 'expert asks expert'.
    Kind regards, Jens


    Jens Dietrich
    Richard Hill
    Greenhorn

    Joined: Jul 30, 2002
    Posts: 2
    Here is a simple example for Mandarax 1.8

    Hope this helps all!
    added UBB CODE tags to help keep the code readable
    [ August 05, 2002: Message edited by: Frank Carver ]
    Bruce Wayne
    Greenhorn

    Joined: Aug 12, 2002
    Posts: 2
    Hello,
    Is there any samples on how to use XML in Mandarax? In the documentation, it talks about the XKB package support XML import and export of KnowledgeBase, but there is no explanation of the format or syntax of the XML. Is there another documentation devoted to that?
    thanks,
    Alan
    Jeff Gaer
    Ranch Hand

    Joined: Jun 04, 2001
    Posts: 99
    There are lots of examples in the JUNIT test cases, but here is code I use to read and write ruleML files. RuleKB would probably be the same, but useing the ruleKB driver


    [ August 12, 2002: Message edited by: Jeff Gaer ]
    Briann Lee
    Greenhorn

    Joined: May 28, 2003
    Posts: 6
    Has anyone checked out drools and compared it to Mandarax? (http://www.drools.org)
    So far the only advantages I've seen of each open source project:
    Mandarax: RuleML GUL Editor
    More Documentation, including database connectivity
    Drools: Forward Chaining (This is important since I need an engine for validation)
    Jeff Gaer
    Ranch Hand

    Joined: Jun 04, 2001
    Posts: 99
    I haven't checked out drools, but thanks for the pointer. I will mention that Mandarax has is great support.
    Briann Lee
    Greenhorn

    Joined: May 28, 2003
    Posts: 6
    From what I can tell based on a small budget, time contraints, complexity, and documentation, looks like Mandarax wins....
    I just wished there was more documentation.
    Briann Lee
    Greenhorn

    Joined: May 28, 2003
    Posts: 6
    documentation like a cookbook - would be really nice
    Hien Nguyen
    Greenhorn

    Joined: Jun 25, 2003
    Posts: 1
    Does anybody know if Mandarax support something like this:
    If product is one of A, B, C then product is on-sale?
    If possible can you please provide some code?
    Thanks...
    oscar mondragon
    Greenhorn

    Joined: Jul 01, 2003
    Posts: 2
    --------------------------------------------------------------------------------
    Hi all,
    I am working in a diagnosis expert System with JAVA
    Is Mandarax a good option to develop this system?
    Is mandarax better than jess or Jeops in this case ?
    are there other similar system with mandarax ?
    thanks
    Oscar H
    Alex Kozlenkov
    Greenhorn

    Joined: May 10, 2004
    Posts: 1
    Hi All
    May I suggest to have a look at the Mandarax spin-off called Prova (Prolog+Java) at http://comas.soi.city.ac.uk/prova. It is derivative of the work I and Michael Schroeder have done after we published the paper on Agents for Semantic Web with Jens Dietrich (the author of Mandarax).
    Cheers--Alex
    Sergio del Valle
    Greenhorn

    Joined: Jul 19, 2004
    Posts: 2
    I've created a set of rules in Oryx and part of the rule accesses a database. When I create queries within Oryx, I get the result I want. However, when I save as a ZKB and import the file in a Java application, the same query does not work, I don't get any result at all.

    I went back into Oryx and changed the database function to a constant, and then when I ran the Java program, I got the result I expected. It seems like I am unable to open a database connection from the Java application. Does anybody have any advice or ideas as to why this may be happening and how I can fix it?

    Thanks,
    Sergio
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: rules engine decision table book or web page
     
    Similar Threads
    Int value to mark Deleted
    Rules Roundup nitpicking
    EURO 2004 Finals
    WA #2 ..... word association
    Alfred Neumann