问题
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.
回答1:
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.
回答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.
回答3:
ruleby is a rule engine in written in ruby. It was subject of a presentation at rubyhoedown 2008: ruleby-the-rule-engine-for-ruby
回答4:
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/
回答5:
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.
回答6:
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.
回答7:
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
回答8:
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.
回答9:
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.
回答10:
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
来源:https://stackoverflow.com/questions/1925360/rules-engine-in-c-or-python