Comparison of Rule Language in ilog, drools, and Jess Rules Engine

Source: Internet
Author: User

Ilog jrules

Today, we have compared these three representative Rule Engine rule languages. Among them, ilog is a commercial product and has no chance to practice it.

Author: Jiangnan Baiyi

1. The same if-then sentence and Rete Engine

All three will solve the chaotic if --- else --- elseif ---- else mystery,
Split it into the sentence format of "If condition statement then execution statement" with N strip priority.

The three mainly use the foreward-chaining rete engine to execute the rule Statement by matching the Condition Statement by priority.
After the rule is executed, the fact changes, and the engine re-matches the condition until no matching is available. The Rete algorithm ensures the highest efficiency.

2. Rules used by developers

2.1 drools XML framework + Java/groovy/Python embedded Language

<Conditons>, <consequence>   The node expresses the if -- Then sentence, which can be embedded with the code of the above language as the judgment statement and execution statement.
Among them, Java code will be interpreted using anlr, while groovy and Python are scripting languages and can be called directly.
Drools's cleverness is that it uses XML nodes to regulate the if-then sentence and fact definitions, making the engine very comfortable.
The use of Java, groovy and other native languages for judgment and execution of statements makes it easy for programmers to transition and transplant, and the learning curve is very low.

<Java: Condition>
Hello. Equals ("hello ")
</Java: Condition>

<Java: Consequence>
Helloworld (Hello );
</Java: Consequence>

2.2 ilog IRL (ilog Rule Language)

IRL uses when {} Then {} to express the if-then sentence

When
{
? Customer: customer (totaltime >=1000 );
}
Then
{
Execute {? Customer. setamount (getamount ()-20.00 );
}

The IRL syntax in this document is Java syntax-like, but I cannot see that the two are the same. However, because he is a commercial product and has powerful editors and management tools, the speed of writing rules should not be bad.

2.3 Jess clips
Jess expresses the if-then sentence with =>. This clips is a real programmer-specific language, and it must be something that very professional programmers get used. However, this is the AI language used for expert systems, and the ability to express rules should be the strongest.
To explain the code below, airplane has a property -- name, which has two sub-classes: jet and propeller aircraft. The propeller aircraft can use any runway, while the jet aircraft cannot use the Grass runway.


; Fact templates
(Deftemplate airplane (slot name ))
(Deftemplate jet extends airplane)
(Deftemplate prop extends airplane );

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 used by the customer

If the customer can write rules on their own, it is undoubtedly a great selling point of the product. Most customers like such a toy. In addition, only by writing rules to the customer can the rule engine be fully meaningful.

3.1 drools DSL
In drools's latest version drools2.0rc2, the two examples of house and conways game of live are DSL versions.
Compare the Java version with the following results:

<House: Condition>
<House: Room name = "Calvin">
<House: temperature>
<House: greater-than scale = "Celsius"> 20 </House: greater-than>
</House: temperature>
</House: Room>
</House: Condition>

Vs, but the DSL Syntax of this XML base is actually not much better, and the implementation cost is a little higher. You need to implement the conditons and consequence factory classes by yourself, and explain the XML section by yourself, basically, there is no convenient underlying support.
As a matter of fact, it is better to simply define the real DSL using anlr, and to implement the conditons and consequence factory classes. It's only explained that XML is common to everyone, and anlr is rarely used.

<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?
I have never actually used it. I can only read documents. From the document, the ilog editor is indeed a 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 jolt;
Drools is the most active open-source rule engine;
Jess is the JAVA Implementation of clips. For example, jruby is represented by the AI system in ruby.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.