Links- Python Inference Engines
Oct 5 2009: PyKE 1.0.2 download, seems to be fairly active
Updated Jan 26 2009: new SimPy 2.0 release, Twisted framework, more links
Updated Oct 29 2008: added Narval
An important and growing segment of the rule engine world ... Python runs fast, a necessary requirement for all large rule-based applications.
PyCLIPS
PyCLIPS is an interesting Python inference engine, embedding the famous C-based engine CLIPS inside of Python as binary modules. Power = 10 / Configurability = 0 ( or close to it for a shared hosting situation ). If you can install binaries, it is worth a look. The PyCLIPS Manual is a very good technical introduction to the CLIPS API.
A significant application of PyCLIPS is the openEHR project for Python ( Open Electronic Health Records ). It requires ZOPE. Python 2.5 and will at some point in the near future work with PyCLIPS.
Pure Python Engines
There is an inference engine called PyIE that may be OK, but the site causes a strange error message about domain mismatch on their security certificate. ???
Perhaps the most widely-used "rule engine" is Plone.Contentrules. It is an ECA-style process engine and not very elaborate but it does provide a level of abstraction above simple code-level logic.
Another interesting variation is Products.Relations, a Plone-based relational engine that navigates through sets of rules for validation/creation of "Archetype references". In the implementation, the subject is RDF-able resources on the web, but it appears to be capable of extension to other domains.
Yet another application with "good bones" is RuleCore, an event-driven reactive (ECA style) rule engine, triggering actions by detecting complex patterns of events. It supports XML-RPC as well as sockets.
Narval is notable effort to create an event-driven intelligent personal assistant that has apparently been dormant since 2002. It still has some interesting features and the Narval source code is still available. Cribbed from the comments in Engine.py:.
Terminology:
- memory: place where Narval stores all it knows of.
- elements: pieces of information stored in memory
- recipe: a recipe is an element that describes a sequence of steps, separated by transitions. A recipe does nothing. It is knowledge.
- plan: a plan is an element. A plan is an instance of a recipe. A plan actually does something.
- step: A step can point to an action, a transform or a recipe.
- transition: a transition links steps in a recipe. it can be fired iff the associated condition is true.
The clever part of Narval is supposed to be run_step() and eval_transition() because of the way they build the list of arguments to pass to the actions and deal with the output.
Other advantages of Narval are supposed to be:
- its reflexivity: it can reason about what it is doing, as what it is doing are running plans and plans are elements in memory. it can reason about what it knows how to do, as recipes are elements in memory. it can reason about what it can do as each action is defined as a transformation (set of inputs and outputs).
- its possibilities for machine learning. because everything is recorded, and because of the above flexibility, lots of possibilities are opened for automatic learning.
For good material about inferencing, see SWAP ( Semantic Web Application Platform).
Simpy Simulation Engine
While not an inference engine, SimPy ( Simulation in Python) might be useful for implementing inference engines by discrete-event simulation. Certainly, it would be useful for implementing the workflow component, since inference engines only make inferences and don't actually do anything after all is said. It also has the advantages of excellent documentation and a recent release ( March 2008 ).
A new release is coming out within days ( as of Jan 26 2009 ); mostly notably, SimPy 2.0 will implement an "Object Oriented API".
Also see the SimPy Wiki.