Anyone with specific pointers or experience with a 'Generic Rules Engine'? - algorithm

I am looking to integrate with a 'Generic Rules Engine' based on the request of a customer.
I think the objective is to allow business stakeholders to add 'Rules', and have those be incorporated into an overall metric calculated on a dataset. So far, the Rules i have heard seem like straightforward snippets of logic in the code. I suppose the drawback is that even though simple, this would still need to be coded... (as opposed to some kind of runtime or data driven rule specification automatically used in the analysis.)
hopefully not too vague - but anyone have any success with such a thing? which open source projects have the most promise?
thanks

I have played around with DROOLS, a rule engine from JBOSS. I have seen it use in large scale production systems. It offers representation of rules in various different formats such as -- flat rule file written in JAVA or MVEL; using DROOLS rule flow, and decision tables composed in EXCEL.
The execution of rules are using RETE algorithm, which is supposedly faster due to rule memorization and variable sharing. As pointed out by Doug, there are a lot of information on Wikipedia

Expert Systems were the AI rage in the 80s.
There's lots of info on Wikipedia on the Rete Algorithm
See also Inference Engine
One well regarded toolkit is CLIPS

Related

Difference between rules in based expert systems and conditions in normal algorithmic programming

In rule based expert systems the knowledge base contains large number of rules in the form of "if (template) then (action)". The inference engine chooses the rules that match the input facts. That is those rules that their condition section matches the input data are shortlisted and one of them is selected.
Now it is possible to use a normal program with similar conditional statements in some way to possibly reach a result.
I am trying to find a "sound and clear description" of the difference between the two and why we cannot achieve what expert system rules could do with normal algorithmic programming?
Is it just that an algorithm needs complete and very well known inputs while expert systems can accept incomplete information with any order?
Thanks.
Rules are more accurately described as the form "when (template) then (action)". The semantic of "when" is quite different than those of "if". For example, the most direct translation of a distinct set of rules to a procedural programming language would look something like this:
if <rule-1 conditions>
then <rule-1 actions>
if <rule-2 conditions>
then <rule-2 actions>
.
.
.
if <rule-n conditions>
then <rule-n actions>
Since the actions of a rule can effect the conditions of another rule, every time any rule action is applied the rule conditions will all need to be rechecked. This can be quite inefficient.
The benefit provided by rule-based systems is to allow you to express rules as discrete units of logic while efficiently handling the matching process for you. Typically this will involve detecting and sharing common conditions between rules so they don't need to be checked multiple times as well as data-driven approaches where the system predetermines which rules will be effected by changes to specific data so that rule conditions do not need to be rechecked when unrelated data is changed.
This benefit is similar to the one provided by garbage collection in languages such as Java. There's nothing that automatic memory management provides in Java that can't be achieved by writing your own memory management routines in C. But since that's tedious and error prone, there's a clear benefit to using automatic memory management.
There is nothing that a "rule-based expert system" can do that a "normal algorithmic program" can't do because a rule-based expert system is a normal algorithmic program. It is not only possible to write a normal algorithmic program to match the way an expert system inference engine works, that is exactly what the people who wrote the inference engine did.
Perhaps the "difference" that you are seeing is that in one case the rules are "hard-coded" in the programming language, whereas in the other case the rules are treated as data to be processed by the program. The same logic is present in both cases, it's just that in one the "program" is specific to one task while the other shuffles the complexity out of the "program" and into the "data".
To expand on what Gary said, in hard-coded if-then systems the firing order for the rules is more constrained than in most expert systems. In an expert system, the rules can fire based on criteria other than some coded order. For example, some measure of relevance may be used to fire the rule, e.g. firing the rule the success or failure of which will rule in or out the most hypotheses.
Similarly, in many systems, the "knowledge engineer" can state the rules in any order. Although the potential order of firing may need to be considered, the order in which the rules are declared may not be important.
In some types of systems the rules are only loosely coupled. That is, a rule's contribution may not be all or nothing. If a rule fires, it may contribute evidence, if it fails to fire (or is absent), it may not contribute evidence, yet the hypothesis may succeed if some other suite of rules pushes it over a certainty threshold.
This allows experts to contribute rules in a more natural manner. The expert can think of a few rules and they can be tested. The expert can add a few more rules, perhaps even months later, etc., all the while improving the system's accuracy without the need to re-write any of the earlier rules or re-arrange any code.
The ways in which the above are accomplished are myriad, but the production rules described by Gary are one of the most common, easily understood, and effective means and are used by many expert systems.

Big ontology based on rules

Could someone tell me where I can find an ontology based on rules, not an OWL one. It can be a Prolog one, or similar.
The ontology should have between 10.000 and 100.000 rules in size, or even more. The maximum limit is not very important, the important is the minimum.
Thank you very much.
Well, mostly depends on what you mean by 'rule'. It's a very generic term... If you just want a shallow data model, you can easily generate your own 'ontology' populating SWI-Prolog well engineered Semantic Web DB with some data of your own choice.
For instance, attempting to learn more about RDF, I've done a similar job, putting filesystem info (Prolog sources, actually) in an 'ontology' I designed, and then drawn various hierarchies, testing my pqGraphviz interface.
I think you can get millions 'rules' this way, in seconds... but, how to do something useful with such data it's much more difficult. A good step would be integrating in Cliopatria, but I didn't get it.
There are so many resource available... for instance ROS, and specifically knowrob, seems a good place to search, since it has specific SWI-Prolog hooks.
I hope someone other will contribute a more comprehensive/interesting answer...

Measuring effort / metrics for software configuration code

I was thinking about software metrics to use in the analysis of the effort to develop a piece of software. As I was thinking about using function-point like metrics for object-oriented software, I came across an interesting challenge / question.
Consider a business rules engine. It is an application that consists of the necessary components to run the business rules, and then one has translate business rules or company policies into configuration code for the business rules engine. My assumption is that for applications like a business rules engine, this configuration code could also become quite substantial. However, when considering it from the point of view of the implementation, configuration code essentially instantiates parts of the API.
So, first, am I wrong in assuming that the effort for writing configuration code is substantial enough that measuring it makes sense?
Does anybody have a clue about a function-point like metric (or any other metric) that could measure configuration code?
It definitely makes sense to measure the effort to produce "configuration code". Depending on your application, the configuration code might even be the greater part of the effort.
I don't know of any metrics especially designed for configuration code. There are many configuration languages already existing, and anybody can create a new one. You should probably see how much your configuration language resembles popular programming languages, and adapt a metric that works with that programming language.
Calling BR code "configuration" code doesn't change the problem. (What do you call a dog with 3 legs? It doesn't matter what you call it, its a dog with 3 legs).
Ignoring the considerable hype, business rules engines are just funny-looking programming languages (usually with complicated interfaces to the "non-business rule part" of the system, which the BR stuff is uanble to do). From this point of view, programming BRs isn't a lot different than other langauges, especially if you buy the function-point model (just because you have a BR engine won't get you out of writing code to generate reports!).
What the BR guys typcially try to do is to claim BR programmming is cheap because you can do it as you go. What they don't say is that programming BR is hard, because the very act of not coding the BR rules up front means you've avoided doing the requirements analysis first, on the grounds "you can just code BR later". And there's no guarantee that your BR system or the data it has access to really is ready for the problem you face. (The idea I really detest is "BR makes it possible for managers to understand..." Have you seen real BR rules?)
I totally agree with Ira and KC, that's why we only use standard script languages for in-application rules. You can use V8 or seamonkey to embed a JavaScript interpreter into your software, then use any estimator which understands JS (like ProjectCodeMeter) on your business rules code.

Suggestions for a business application using logic based system like prolog

I need to develop any business application which includes a logic-based system like prolog. Basically I need to develop a business application and we show that the logic-based system is feasible for that.
This is an academic exercise.
I could think of only puzzles which can be solved using prolog. But I need a business application where I can use prolog.
Can any one please give some suggestions on simple business applications where I can use prolog logic based system?
Thanks & Regards.
How about some kind of resource scheduling like, say, conference rooms, labs, classrooms, etc.? You'd have to keep track of locations, available facilities, events, event priorities, times, what facilities are required for which events, etc. and try to balance these "fairly" in some way. That would be a major challenge for a conventional programming environment and would be immediately useful to boot.
Edited to add:
I found the paper I wanted to reference earlier. You'll have to pay for a copy, but it's worth it if you decide to go this route: School time table scheduling in Prolog
Abstract:
The school Time-Table Scheduling task is a very hard operations research and engineering problem, especially when-implemented in a conventional language. That is due to the imperative, deterministic nature of most conventional languages, such as BASIC and PASCAL and to the long series of constraints and goals inside the problem. The descriptive, logic-based and nondeterministic nature of Prolog language, and its ability to backtrack allows one to easily obtain a deductive data base, mixing the facts, rules, and constraints of the Time-table. Two systems, one nonmonotonic, and one monotonic with a non-monotonic reasoning structure are compared and their performances in a significant test are discussed. The approach may be easily generalized to other analogous engineering, scheduling and operations research problems.
How about a business "contact management" application? I'm thinking it could be prototyped around a couple of features, sending notes to thank customers for recent purchases and perhaps a birthday recognition of some kind.

Expert system for writing programs?

I am brainstorming an idea of developing a high level software to manipulate matrix algebra equations, tensor manipulations to be exact, to produce optimized C++ code using several criteria such as sizes of dimensions, available memory on the system, etc.
Something which is similar in spirit to tensor contraction engine, TCE, but specifically oriented towards producing optimized rather than general code.
The end result desired is software which is expert in producing parallel program in my domain.
Does this sort of development fall on the category of expert systems?
What other projects out there work in the same area of producing code given the constraints?
What you are describing is more like a Domain-Specific Language.
http://en.wikipedia.org/wiki/Domain-specific_language
It wouldn't be called an expert system, at least not in the traditional sense of this concept.
Expert systems are rule-based inference engines, whereby the expertise in question is clearly encapsulated in the rules. The system you suggest, while possibly encapsulating insight about the nature of the problem domain inside a linear algebra model of sorts, would act more as a black box than an expert system. One of the characteristics of expert systems is that they can produce an "explanation" of their reasoning, and such a feature is possible in part because the knowledge representation, while formalized, remains close to simple statements in a natural language; matrices and operations on them, while possibly being derived upon similar observation of reality, are a lot less transparent...
It is unclear from the description in the question if the system you propose would optimize existing code (possibly in a limited domain), or if it would produced optimized code, in that case driven bay some external goal/function...
Well production systems (rule systems) are one of four general approaches to computation (Turing machines, Church recursive functions, Post production systems and Markov algorithms [and several more have been added to that list]) which more or less have these respective realizations: imperative programming, functional programming, rule based programming - as far as I know Markov algorithms don't have an independent implementation. These are all Turing equivalent.
So rule based programming can be used to write anything at all. Also early mathematical/symbolic manipulation programs did generally use rule based programming until the problem was sufficiently well understood (whereupon the approach was changed to imperative or constraint programming - see MACSYMA - hmmm MACSYMA was written in Lisp so perhaps I have a different program in mind or perhaps they originally implemented a rule system in Lisp for this).
You could easily write a rule system to perform the matrix manipulations. You could keep a trace depending on logical support to record the actual rules fired that contributed to a solution (some rules that fire might not contribute directly to a solution afterall). Then for every rule you have a mapping to a set of C++ instructions (these don't have to be "complete" - they sort of act more like a semi-executable requirement) which are output as an intermediate language. Then that is read by a parser to link it to the required input data and any kind of fix up needed. You might find it easier to generate functional code - for one thing after the fix up you could more easily optimize the output code in functional source.
Having said that, other contributors have outlined a domain specific language approach and that is what the TED people did too (my suggestion is that too just using rules).

Resources