This is a creation in Article, where the information may have evolved or changed. Ilog JRules is the most famous commercial brms, just took the jolt;
Drools is the most active open source rules engine, all the way up;
Jess is the clips Java implementation, as JRuby to Ruby, is the representative of the AI department.
Today, we compare the rules of these three quite representative rules engines. Ilog is a commercial product, there is no chance to combat.
1. The same if--then sentence and Rete engine
All three will confuse the original if---else---elseif----else mystery,
The sentence of the "If conditional statement then EXECUTE statement" that is split into N-band precedence.
All three mainly use Foreward-chaining's Rete engine, according to the priority match condition statement, executes the rule statement.
The Rete algorithm guarantees the highest efficiency when the rules are executed and the engine is re-matched until it can no longer match.
2. The rule language used by the developer
2.1 drools XML Framework +java/groovy/python Embedded language
Drools uses XML <Conditons>, <Consequence> nodes to express if--then sentence patterns, which can be embedded in the code of the above language as the judgment statement and execution statement.
Java code is interpreted using ANTLR, and groovy and Python itself are scripting languages that can be called directly.
The clever thing about drools is that XML nodes are used to standardize the definition of if--then sentences and facts so that the engine is comfortable to work.
Using native languages such as java,groovy to make judgments and execute statements makes it easy for programmers to transition and transplant, with low learning curve.
< java:condition >
Hello.equals ("Hello")
</ java:condition >
< java:consequence >
HelloWorld (hello);
</ java:consequence >
2.2 ILog's IRL (ILog Rule Language)
IRL uses when{}then{} to express if--then sentence patterns
When
{
? Customer:customer (TotalTime >= + );
}
Then
{
Execute { ? Customer.setamount (Getamount () - 20.00 );
}
The document says that the syntax of IRL is Java syntax-like, but I can't see how the two are the same. However, because he is a commercial product, there is a very powerful editor and management tools, the speed of writing rules should not be bad.
2.3 Jess's clips
jess Use = = to express if-then sentence patterns. This clips is a real programmer-specific language, and it's something a professional programmer gets used to. But this is used to do the expert system of AI language, the ability to express the rules should also be the strongest.
To explain the following code, airplane has an attribute--name, there are two subcategories--jet and propeller aircraft, where propeller planes can use any runway, and jets cannot use the grass runway.
; Fact templates (Deftemplate airplane (slot name)) (Deftemplate Jetextendsairplane) (Deftemplate propextendsAirplane);
Rules (Defrule can- Use-Grass-runway (Prop (name?N)) = (PrintOut t"aircraft can use grass-" ?n CRLF))
(Defrule can- Use-Asphalt-runway (Airplane (Name?N)) = (PrintOut t"aircraft can use asphalt-" ?n CRLF)) |
3. Rules language used by customers
If the customer can write their own rules, is undoubtedly a big selling point of the product. Most customers will like such a toy. And only when the rules are written to the customer to achieve the full meaning of the rule engine.
3.1 Drools's DSL
Drools's latest version of Drools2.0rc2, house and Conways game of live two examples have a DSL version
Compare the Java version with the following effect:
< house:condition >
< House:room name = "Calvin" >
< House : Temperature >
< House:greater-than Scale = "Celsius" > - </ House:greater-than >
</ House : Temperature >
</ House:room >
</ house:condition >
vs but this kind of XML base DSL syntax is not much good, and the realization of the cost of a lot, to achieve their own conditons and consequence factory class, self-explanatory XML, basically there is no convenient bottom support.
In fact, pound, simply using ANTLR to define a real DSL, the same implementation conditons and consequence factory class might be better. Just explain XML everyone, ANTLR less people use it.
< java:condition >
Room.getname (). Equals ("Calvin")
< java:condition >
< java:condition >
Converttocelsius (Room.gettemperature ()) > 20
< java:condition >
3.2 Ilog's bal (business Action Language)--The perfect king?
No actual use, can only see the document too enjoyable. Judging from the documentation, the editor with Ilog is really the perfect rule language.
If
The call destination number is the preferred number
Then
Apply the preferred number rate is the most famous commercial brms, just took the jolt;
Drools is the most active open source rules engine, all the way up;
Jess is the Java implementation of clips, as JRuby to Ruby, is the representative of the AI department.