Rules Engine in C or Python [closed]
Asked Answered
A

10

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.

Allurement answered 17/12, 2009 at 23:39 Comment(2)
#468238 google.com/…Lorca
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 :)Allurement
V
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.

Voucher answered 18/12, 2009 at 17:3 Comment(1)
PyCLIPS it is. And it is really easy to translate my Jess rules to CLIPS.Allurement
P
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.

Pneumonoultramicroscopicsilicovolcanoconiosis answered 18/12, 2009 at 11:44 Comment(0)
S
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

Saucepan answered 17/12, 2009 at 23:42 Comment(0)
C
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/

Clothilde answered 17/12, 2009 at 23:44 Comment(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)?Allurement
C
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.

Chellman answered 20/12, 2009 at 19:58 Comment(0)
U
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

Unpleasantness answered 20/12, 2009 at 20:5 Comment(0)
T
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.

Tabernacle answered 26/1, 2010 at 9:47 Comment(0)
G
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.

Gause answered 18/9, 2014 at 23:49 Comment(0)
N
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

Nuzzi answered 14/6, 2019 at 13:29 Comment(0)
C
-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.

Cobbler answered 18/12, 2009 at 0:44 Comment(4)
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?Allurement
@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.Cobbler
If you are looking for inference on your rules then looking at Pyke [ pyke.sourceforge.net ] would be helpfulVoucher
@ardsrk: Please post your comment as a separate answer so I can vote it up.Cobbler

© 2022 - 2024 — McMap. All rights reserved.