Question

I need to build a "rule-based" system that can be run and developed in both C# and Java (for a chemistry application). The system needs to be able to get computed properties of objects (through existing libraries) and make decisions on those values. I am not sure what the system will look like but the rules need not be formally consistent (we use a lot of heuristics). As far as possible the rules should be externalised so users and developers can modify them without needing to know about the engine (which should be Open Source and run on both platforms). It's possible that the system will be run through a restricted set of natural-language-like commands. There will be an element of adaptation - new objects (or at least vocabulary) can be added.

This is not as hairy as it sounds - a great deal of progress was made over 30 years ago using FORTRAN but the field has lain fallow. I'd be grateful for pointers to approaches we could experiment with where the overhead of entry was modest. Among the approaches that might work are:

  1. Prolog
  2. OWL Ontologies
  3. Decision trees
  4. RULEML
  5. Text-based games

EDIT The primary aspect of the question is to find a rule-based system (the Java C# mention is secondary and was simply to prevent answers that might say "Windows has a built-in system".) Please do not answer with approaches to converting Java to C#; I want a rule-based approach that - in principle - could be implemented on either. So far only one (or two) answers really addresses the rules aspect.

Was it helpful?

Solution

You could take a look at Drools (now also known as JBoss Rules). This a Rete engine implementation that has been around for quite a long time and has now also been ported to .NET so it should fill your requirements for being able to be used in Java and in C#. I don't know how close the implementations are - you might find yourself limited to a subset of the capability.

JBoss Rules: http://jboss.org/drools/

Drools.NET: http://droolsdotnet.codehaus.org/

Don't worry about the business focus on the JBoss site, Drools is a general purpose Rules Engine implementation.

OTHER TIPS

If you develop in Java you can use the resulting classes in .Net/C# by using IKVM. IKVM converts Java bytecode to the equivalent MSIL and also provides a Java class framework and VM all running within .Net. It works exceptionally well, it's free, is used commercially (e.g. by the Saxon XSLT/XQuery/XPath product) and it's really easy to convert a java class file to a .Net dll.

I often use Java projects in .Net for doing scientific and maths based operations because work in these fields often tends to be in Java - certainly far more often than it is in C#.

If you want to implement your own Domain Specific Language, good options would be IronPython (Microsoft Dynamics uses it for the same purpose), or, for instance Boo language.

You could build a rules engine as a web service, Then you can call the service from either C# or Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top