6

I am looking for a rules engine in C or Python, but if you know a rules engine that is implemented in another language I would be glad to know about it.

The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc. So no "office" rules there (aka do you rules in Excel or such).

I have looked into Jess and Drools which are in Java and do a perfect job. I would like to know of others and possibly using less memory than Java does. I have heard of RuleCore in Python but couldn't really find any documentation on it (version 1.0 is available at SourceForge but it looks like they are selling v. 2.0).

EDIT: By rules engine (inference engine), I mean an implementation of RETE or equivalent.

Yanik
  • 529
  • 2
  • 5
  • 14
  • http://stackoverflow.com/questions/467738/implementing-a-rules-engine-in-python http://www.google.com/search?client=safari&rls=en&q=python+rule+engine&ie=UTF-8&oe=UTF-8 – Alex Brasetvik Dec 17 '09 at 23:42
  • Thanks, I had seen this question and I am not looking for implementing a new rule engine. But I didn't see the reference to CLIPS the first time :) – Yanik Dec 17 '09 at 23:51

10 Answers10

7

In your search for RETE based rules engine in Python either Pyke or PyCLIPS could be the one you would want to use.

PS: I had left a comment to S.Lott's answer about Pyke. I have posted a separate answer as per his suggestion and also to let other readers readily know that the rules engine mentioned in this answer could be a probable choice if they are searching for one.

ardsrk
  • 2,407
  • 2
  • 21
  • 33
2

You could look at CLIPS as already suggested or, if you want to pay money or need it Rete2. I've used CLIPS in the past on Unix and sucessfully embedded it into other applications.

Hope this helps.

Jackson
  • 5,627
  • 2
  • 29
  • 48
1

ruleby is a rule engine in written in ruby. It was subject of a presentation at rubyhoedown 2008: ruleby-the-rule-engine-for-ruby

miku
  • 181,842
  • 47
  • 306
  • 310
1

Pychinko has been around for a while. I've never used it in production, but investigated it for possible production application a while back. It looks like it has pretty good features and a decent community of users.

http://www.mindswap.org/~katz/pychinko/

codekaizen
  • 26,990
  • 7
  • 84
  • 140
  • 1
    Thanks. Do you know of any mailing lists or irc channels for the community? It doesn't look like it is maintained any more.. And have you heard of pyCLIPS (I just found out)? – Yanik Dec 18 '09 at 01:03
0

Rulecore is indeed written partly in Python. But it does not really matter. You as an user would not see any of these implementation details anyway.

The rules are purely declarative and defined using XML. The XML is sent into ruleCore CEP Server as events using a web services or JMS or other protocols.

Nick
  • 11
  • 1
0

Here is a list of 13 open source rules engines in java, Drools is possibly the best of these. http://java-sources.org/open-source/rule-engines

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

I know ruleCore has some parts written in Python. But the API uses XML and ActiveMQ or WebServices so it is on a higher abstraction level.

Stjoan
  • 29
  • 2
0

Nebri is the easiest way to write rules for home automation AND other software/machines. Here's an example to accomplish the light shutoff:

class high_temp_shutdown(NebriOS):
    listens_to == ['shared.pebble_location'] 


    def check(self):
        # if pebble dongle is out or room, return true
        return shared.pebble_location > 3 # in meters

    def action(self):
        smartthings.lights(2,"off")

It's a perfect tool for automating your house since you can pip install existing libraries for use in your script. Nest, SmartThings, Sen.se and so on. It's just Python!

And for a fuller explanation of why Python isn't a rules engine by itself, see this article. Just because Python itself can execute rules, you don't have a rules engine on your hands. It's a huge architectural shift in fact.

Adam
  • 3,311
  • 1
  • 18
  • 9
0

I write a simple rule engine in python. You can store your rules in json or yaml string, and use this rule engine to match the rule with the context.

https://github.com/tclh123/rule

Harry Lee
  • 992
  • 8
  • 7
-1

In effect, Python is a rules engine.

"The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc."

You need sensors and controllers. You write your "rules" as ordinary Python objects.

Your main "program" collects events from your sensors and sends events to your controllers.

If you can read from your sensors via ordinary USB, that's even better. The marine industry uses a couple of closely related standards like NMEA 0183 and NMEA 2000 for specifying the traffic on the bus from sensor to controller.

You don't need Yet Another Rules Language. You have Python.

S.Lott
  • 384,516
  • 81
  • 508
  • 779
  • 2
    I am unsure of what you mean, but I think you could say that any Turing complete language is in fact a rules engine. I probably should have mentioned the RETE algorithm that perform much faster than checking a fact against every rules. Since I am not a Python expert, I am not sure how you would do this. Do you have any link where it is explained? – Yanik Dec 18 '09 at 00:59
  • @Yanik: If inference is part of the problem space, then update the question to include this fact. Must rule processing does not involve inference. If you require inference, update your question, please to state this clearly. – S.Lott Dec 18 '09 at 01:42
  • 1
    If you are looking for inference on your rules then looking at Pyke [ http://pyke.sourceforge.net/ ] would be helpful – ardsrk Dec 18 '09 at 07:26
  • @ardsrk: Please post your comment as a separate answer so I can vote it up. – S.Lott Dec 18 '09 at 11:17