basic rules engine

29
Infosys Basics of Rule Engine February, 2012 INFOSYS TECHNOLOGIES LIMITED CHENNAI Document No. Ver. Rev. : 1.0 Authorized by: Signature/ : Date: Basics Of Corticon Rule Engine 02/13/2012 © 2012 Infosys Technologies Limited, India

Upload: siva-kumar

Post on 23-Nov-2015

60 views

Category:

Documents


3 download

DESCRIPTION

BRE

TRANSCRIPT

Infosys

Basics of Rule Engine

February, 2012

INFOSYS TECHNOLOGIES LIMITED

CHENNAI

Document No.Ver. Rev. :1.0

Authorized by:Signature/:Date:Basics Of Corticon Rule Engine 02/13/2012

COPYRIGHT NOTICE

2010 Infosys Technologies Limited, Bangalore, India. All rights reserved. Infosys believes the information in this document is accurate as of its publication date; such information is subject to change without notice. Infosys acknowledges the proprietary rights of other companies to the trademarks, product names and such other intellectual property rights mentioned in this document. Except as expressly permitted, neither this document nor any part of it may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, printing, photocopying, recording or otherwise, without the prior permission of Infosys Technologies Limited and/or any named intellectual property rights holders under this document.

Infosys Technologies Limited Hosur Road Electronic City, 3rd Cross Bangalore 560 100 India. Telephone: (91) (80)28520 261-270 Fax: (91) (80) 8520 362 Website: http://www.infosys.com

Author(s): Priti MishraDate written 02/13/12 Target readers Developers using rule engines as part of their projects for designing rule models.Keywords

BRMSBusiness Rule Management System

JSRJava Specification Request

DeTiDesign Type Interfacing Algorithm

JREJava Runtime Engine

JVMJava Virtual Machine

APIApplication Programming Interface

Contents1.Introduction52.Scope63.Business Rule Management System64.Rules Engine Types7Forward Chaining8Backward Chaining85.Why and Where to use Rule Engine86.Advantages of Using Rule engine97.JSR 9498.BRMS Vendors109.Corticon Rule Engine119.1 Corticon Studio12Corticon Studio Features13Benefits Offered by Corticon Studio14System Requirement14Basic Steps for designing a rule model in Studio159.2 Corticon Server20Corticon Server Features20System Requirements for Corticon 5 server219.3 Corticon collaborator21Corticon Collaborator Features21Corticon Collaborator functionalities229.4 Corticon Enterprise Data Connector-Single Source23Functional Block Diagram23Advantages of Corticon Enterprise Connector-Single Source24Key Capabilities of Corticon Enterprise Connector249.5 Corticon Enterprise Data Connector-Multi Source25Advantages of Corticon Enterprise Connector-Multiple Source25Key Capabilities259.6 Corticon Dialogues269.7 Corticon Dialogues Designer269.8 Corticon Dialogues Server2710 Advantages of Corticon 5 Rule Engine2711References28

1. Introduction

This document gives an overview of the basics of the business rule engine. Various Business Rule Engines are available in the market and use of these engines in designing of new rule models is being used by IT professionals for various applications. An overview of Corticon rule engine and its features are explained in this document.2. Scope

The document covers the below mentioned concepts:

Need for Business Rule Engine in IT world.

Various BRMS vendors available in Market.

Special focus on Corticon Rule Engine and its implementations and features.

Benefits being provided by Latest Corticon Version.

APIs available for connecting and executing rules.3. Business Rule Management System

Now days IT applications are aiming to separate the business processes from IT infrastructure. Rule engine is growing very fast to achieve this goal as through this software the code for business processes can be isolated from application logic based code.BRMS is used to define, deploy, execute and management of complex rules repository used by operating systems within an organization or enterprise.Rule Engine is one of the software components of Business rule management system (BRMS).The program designed specifically to run the business rules are known as the Rule Engines. As this engine helps in separating the business processes from application code so a non programmer can easily add or modify the rules in the Rule Engine without asking a programmer for help. The engine then takes the responsibility of executing that logic or rule that needs no actual programming.Many commercial Rule engine follows the Rete algorithm that embodies many principle of Rete. There are also other execution algorithms like sequential algorthim,algorithm for decision tables and trees etc.Depending upon the rules definition the algorithm can be followed. If there is minimum sharing of condition between different rules then normal sequential algorithm can be chosen for Rule engine. But for evaluating decision tables and trees an algorithm that exploits the hierarchical relationship between the rules can work better than Rete or any sequential algorithm.The commercial rules can be defined using a conventional programming language or a language similar to natural ones which would be a user friendly to a non programmer.Some commercial BRMS allows design rules by providing user friendly forms to create and edit rules. In this way rules can be created easily by individuals who have minimum knowledge on programming language. If a rule has to be designed similar to natural languages then a vocabulary has to be created. The vocabulary contains words and expressions which resembles business real life operations and objects. With a defined vocabulary it becomes very easy to write rules in BRMS.Some programming languages then needed to implement these defined rules in BRMS from the application. But most Rule Engine has propriety API which makes it very difficult to integrate with applications. But if a Rule Engine no longer exists and the business decides to adhere to a new rule engine then the entire application code has to be rewritten also.Examples of Rule Engine are Corticon, ILOG JRules, Jess, Drools etc

4. Rules Engine Types

Different types of Rule Engine have been defined depending upon the rule execution schedule:-1) Forward Chaining2) Backward Chaining

Forward Chaining

This type of rule engine can be further divided into 2 types:-a) Production/Inference Rules: - This type of rule engine provides an output depending upon the condition being satisfied. This is equivalent to an IF THEN statement that is if the condition satisfies then only action will take place.b) Event Condition Action Rules: - This rule engine detects and reacts to the incoming events. The incoming events are processed and depending upon which the corresponding action are taken.For e.g.:- The engine can alert a manager when certain items are going out of stock.The biggest difference between the two above method is the Inference rules has to invoked by the user or application but Event rules are automatically invoked depending upon the event being occurred in a stateful manner.

Backward Chaining

This type of rule engine starts from goal and move backward from consequent to antecedent to check whether any data available that satisfies those sets of consequents.So it is based on goal driven mechanism which tries to find some information depending upon the existing data.

There is also a third type of Rule Engine defined called deterministic Rule engine. It implements both the forward and backward chaining and uses a domain specific language which is very easy to implement the rules and also advantageous than the above two types.

5. Why and Where to use Rule Engine

Today the business rules are changing in enterprises and companies depending upon the market dynamics.The change in rules is not predictable and these may change further with time. So IT application used for insurances and bank etc should also adhere to these new rules. The Rule Engine acts as a solution to this scenario which enables the developers and analyst to develop, build rules using this tool. This engine separates the business rule logic from actual application code so that if in future if any new rule needs to be added then it doesnt affect the actual application code.The new rules can be created and run using the engine and the existing application will integrate with the new changed set of rules.This Rule engine should be used by those applications where the business logic or policies change dynamically and those needs to reflect immediately in the applications.There are various domains where the policies, rules changes dynamically depending upon the market trends. Application in domains such as insurance, financial services, government, telecom customer care billing and e commerce etc all are greatly benefited by this software component.

6. Advantages of Using Rule engine

The introduction of Rule Engine adds another layer of the system that automates the business processes. The advantages are mentioned below:-1) The engine reduces the cost incurred for modification of the business logic.2) As the application code and business logic are kept separate so the changes to rules can be done easily and with less risk.3) Development time reduces drastically as no change is required in the application code because of the change in the business logic.4) Rules are externalized from application code. So multiple applications or environments can re use the rules easily.

7. JSR 94

JSR is the Java specification request for Java Rule engine API.This is a simple API which helps to access a simple rule in Rule engine from a Java SE or Java EE client. The API provides the below mentioned functionalities:-a) Register and unregister ruleb) Parse rulec) Execute ruled) Retrieve resultse) Filter resultsBut JSR 94 doesnt standardize the below parameters:-a) The Rule engine itself.b) Execution flow of the rules.c) The language used to describe the rulesd) The deployment mechanism for Java EE technology.In other words it doesnt describe the rule semantics.Below are some of the BRMS Vendors which uses JSR 94 API:-a) Droolsb) ILOG JRulesc) Jess Programming languaged) OpenRulese) Oracle Business Rules.There are many Rule engine which allows service oriented integration with applications through the web based standards WSDL and SOAP.8. BRMS Vendors

There are many BRMS vendors in market. Some of the vendors are mentioned below:-

VendorsPlatforms

IBM ILOG JRulesPopular for JAVA platforms

IBM ILOG .NETPopular for .NET platforms

Red Hat JBoss RulesPopular for JAVA platforms

Visual RulesPopular for JAVA platforms

DroolsPopular for .NET platforms

InRulePopular for .NET platforms

OpenLexiconPopular for JAVA platforms

Pega SystemsPopular for JAVA platforms

HaleyPopular for .NET platforms

CorticonPopular for JAVA platforms

9. Corticon Rule Engine

Corticon is a rule engine being used by Corticon Technologies Limited BRMS Company for automation of business decisions. This no coding Rule engine has been used by many customers for automating their business processes and rules which gives accurate results in a much faster way and also reduces the development and changes cycle time to around 90 percent.There are many rule engines which need JSR 94 to integrate with applications but this rule engine uses SOA architecture.Many traditional BRMS vendors have implemented Rete algorithm to execute rules in Rule engine. This algorithm is very powerful in solving inference rules but the algorithm requires an enormous amount of data and rules pattern matching to perform in memory during execution. And when this data grows enormously in size and complexity this pattern matching resources overwhelms server resources and the rule engine started to degrade sharply. Corticon rule engine have been implemented with a patented Design type interfacing (DeTi) algorithm. This algorithm can scale linearly with regardless of number of rule or complexity of data.Corticon are used by different domains starting from insurances, ecommerce companies, banks, government organizations etc.Corticon version 5 is the latest version defined by Corticon. This version has been created on the open source eclipse framework.

Basics components of Corticon Rule Enginea) Corticon Studiob) Corticon Serverc) Corticon collaboratord) Corticon data connector

9.1 Corticon Studio

This is one of the components of the Corticon rule engine. This is a standalone desktop environment used by software developer to easily model, analyze, test and deploy rules as decision services which can be used by many applications as services. The studio provides complete rule modeling framework starting from modeling of rules, testing and deployment of the same in the production environment.

Corticon Studio Features

1) Business experts can capture the requirements in natural language rule statements and then divide them into different logical groups. This logical group is then later referenced during model construction.

2) The studio has been provided with an intuitive modeling interface which consists of a graphical spreadsheet which can be used for modeling rules. The rules can be modeled using normal conditional statements. There is no need to remember any rule language for designing rules.

3) Modeling of rules is done in a spreadsheet which requires no knowledge of any programming language. This feature makes it very easy to learn and comprehensive in its expressiveness.

4) For creating rules first the vocabulary needs to be defined in the corticon studio.Vocalbulary consist of all the business related or industry specific terms that are used by rules. User can create as many vocabularies as needed for writing the rules. Also a relationship can be made between the vocabularies and data can then be assigned to them.

The created vocabularies are not specified to a particular rule model but they can be reused by many rule models. Vocabularies are created and defined by the vocabulary editor.

5) Corticon has included its own operator library which consists of all types of operator starting from mathematical operators (+,-,*,/),comparison operators(,=),some defined functions for date manipulations etc.These operators can be used during creating rules. Its library is also extensible that is if a particular operator is not available then it can be added to the corticon studio.

6) Corticon has added technology which can automatically detect the errors present in the designed rule and provide options or hints to resolve them.

The below 3 functionalities have been included for detecting logical errors in the rule:-

a) Ambiguity Check: In corticon studio rules are designed in a rulesheet.The ambiguity checker will show the conflicts between different rules designed in the rulesheet.This graphical tool will also mention the exact scenario for which the conflict occurs.b) Completeness checker: This feature will identify the missing business scenarios that are not added by the user during the rules designed. Also this will add all the missing parameters thus making the rules complete.c) Logical loop checker: This helps in finding the logical loops that are present in the rules designed by the user which can cause problem in the rule being created by user in run environment.

7) Unit testing, regression testing, data driven functional analysis can be done in corticon studio at the granularity of a rule,rulesheet or ruleset.

Test Cases: The basic building block for testing is the test cases which are designed using the vocabularies which are used for creating rules.This test cases can then be tested which would span the entire rule model thus checking the complex dependencies between various rules.

Automatic Rule Engine: Though Automatic Rule engine test cases can be run one at a time or in a batch process.

Reuse test cases or test data: The test cases can be populated using the test data in hand or using a database to store the test cases to enable reuse and regression testing.

Benefits Offered by Corticon Studio

1) This Rule modeling platform can be used by anyone not having any skill of programming language.2) It assures quality and consistency of business decisions.3) Optimize model performance and scalability every time it is saved.

System Requirement

Corticon Studio 5 is the latest version of corticon BRMS.The minimum system requirements for using this platform are as follows:a) Microsoft Windows 2000, XP, Vista or 7.b) Minimum hardware requirement of Windows 2000 include: Pentium 3 class or compatible CPU 128 MB Ram.

Basic Steps for designing a rule model in Studio

Step 1: Install Corticon studio in desktop and open it by double clicking it.Step 2: Create a Vocabulary first to define the business related entity that needs to be validated.

Step 3: Add entity to the Vocabulary defining all the properties for the entity.

Step 4: After Vocabulary is defined, create a new Rule Set for creating multiple rules.

Step 5: Now add the conditions under the Condition tab and the actions that need to be taken for the defined conditions under Actions tab.

Pre conditions can also be defined for the created rules under Preconditions Tab.

Step 6: Now test the rule set for testing its functionality. Go to Test Tab and create a new test file.

Step 7: The test file will be opened.

Step 8: Drag drop the Vocabulary to the test window.

Step 9: Provide inputs to the entities of the Vocabulary in the test window.

Step 10: To execute the test file, go to Test and Execute Test.

Step 11: The result will be shown in the test window.

9.2 Corticon Server

Corticon server is the execution engine for corticon BRMS.It deploys the rules as services so that it will be accessible to different application.The server executes the rule model that have been modeled, designed and tested in corticon studio ensuring reliable results and better performance.Corticon Server Features

1) Previously most of the Rule Engines were using Rete Algorthim for analyzing the rules .Rete is a very good and preferable algorithm for the rule model that consists of large number of rules.This algorithm generally evaluate condition during the execution time when the system is trying to find out the result of a particular condition. But the performance of Rete degrades exponentially when the complexity of data increases across the rules.

That why the new corticon rule engine have been implemented with DeTi algorthim.This algorithm scales linearly with increasing number of rules and complexity of data ,thus performing good and giving accurate results.

This algorithm analyzed the result of the rules during the design time itself thus giving fast and accurate results.

The rules are deployed in one or many J2EE or Microsoft .NET environments running corticon server after being modeled and tested in corticon studio.

System Requirements for Corticon 5 server

Corticon 5 server is the latest version and below system requirements are needed for its installation:-a) Java supported CPU.b) Java Runtime Engine(JRE) version 1.5.0v or higher(1.6 recommended)c) 512 MB Ram allocated to JVM.d) 10 MB disk space.e) 150 MB disk space.f) Deploying the rules as a web service requires a J2EE web or application server.

9.3 Corticon collaborator

The Rule project generally involves a lot more activities other than the rule creation, deployment etc.All project involves many projects artifacts which also need to be managed properly to make the project documents consistent.For this reason corticon collaborator has been introduced by corticon. Corticon collaborator is a rule repository as well as a life management system which manages the rule asset from their creation to development to deployment in the corticon server. With collaborator the team involved in rules design can work in harmony and rules can be managed in a more effective way.The collaborator provides a dynamic environment where to capture, share and manage all rule assets. This not only include only the rules designed by corticon studio but all the project assets that are linked to the designed rules such as the requirement document, project schedule, test cases designed for unit testing etc and then all are saved in the corticon rule collaborator product.

Corticon Collaborator Features

1) This web based application doesnt need any client software to be installed in the system.2) The collaborator provides a common platform or environment where all the team members can store and share their changes that will be visible to all other team members. This ensures right version of the rule asset to be used by all team members thus making the rule development correct and defect free.3) The collaborator manages group centric collaborative spaces giving distributed project teams easy access to content and information.

Corticon Collaborator functionalities

1) Management of rules is very critical after rules development. It is very important to ensure that right person is doing right changes to the latest updated version and correct access is given to the authorized person as the changes moved from creation to production.

Version and access control has been provided by the collaborator which ensures right person is doing right changes the rules designed. The access right has been provided according to the roles assigned to the user. Distributed administration provides the content administrators the power to defined policies for different domains of the rules development. Users can also subscribe to the subscription services which would notify the user whenever there will be a change or update done to the rule set or rule model. Collaborator is providing multiple levels of security to the rules designed.

2) Rules or condition has become an integral part of the business world. So it is very important to decide which rule sets are required for a business scenarios and it is also very important to get track of the rules impacted because of any other changes in other part of the project development.So corticon collaborator also provides of knowledge on the use of the business rules for a project.

Collaborator also suggests some business rules based on the vocabulary designed by the user. This also provide a impact analysis tool which analyze the rules impacted due to the change in some other rule done by other member of the team and also suggest hints to resolve them.

3) Corticon provides a complete workflow system for moving the rules project work from review to approval process in secure and effective way.

The collaborator has defined a workflow for the rules vocabularies and other documents that are linked to the rule asset like requirement document, test cases, and design document to move smoothly from development to testing to deployment in the run environment. New workflow can be also created by the user without having any programming knowledge. Audit and monitoring measures are also provided which sends updated and alert messages whenever a change occurs to the rules repository.

4) Intuitive web based client that requires no client software. It can run on multiple platforms like Solaris, Linux or windows server.

9.4 Corticon Enterprise Data Connector-Single Source

Corticon Enterprise Data connector is a new product being introduced by Corticon which helps in connecting Corticon decision services with data models.The decision services can easily update or modify the enterprise data model with absolutely no SQL coding.The decision services which are deployed in the corticon server can access or manipulate data during their execution. As the data model and the decision services are maintained separately so both can be modified simultaneously without affecting each other.Functional Block DiagramCORTICON ENTERPRISE DATA CONNECTOR-Data AccessCORTICON SERVERRULE EXECUTIONCORTICON STUDIO RULE MODELLING

Relational DatabaseUsing Corticon EDC, important decision services can directly access missing data or can also create, insert or update data into the relational databases during the rule processing. Scenario based testing using large data sets stored in the databases is very much possible though the connector. Decision services can be also used for batch processing either for live transactions or of warehouse data for compliance.

Advantages of Corticon Enterprise Connector-Single Source

1) Mapping of the vocabulary with the data source can be done easily.2) Decision model can be kept separated from Enterprise data so either can be updated or modified independently of each other.3) Cost can be reduced and product can be delivered very fast and on time for data hungry decision services.

Key Capabilities of Corticon Enterprise Connector

1) Model driven access to external data source during the rule execution: No SQL coding is required for data connectivity. All the sophisticated processing is hidden from the user.2) Optimized complier offloads the data intensive operations to DB.3) It follows the data driven testing that is only the primary key need to be supplied and all other data can be retrieved by the connector.4) Smart retrieve and smart query extracts data which only what is needed and when needed.

9.5 Corticon Enterprise Data Connector-Multi Source

Through Corticon Enterprise Data connector the decision services or rules can connect to any type of data models whether it may be structural or no structural including documents, blogs, data warehouses, data sources, web services and message queues.The Corticon connector creates a unified view of the enterprise data which can be accessed by all the decision services.

Advantages of Corticon Enterprise Connector-Multiple Source

1) Model driven real time access to Enterprise data sources.2) Less time, lab our and risk involved when multi source data integration is required.3) Improved quality and consistency in multi source data integration of corticon BRMS projects.

Key Capabilities

1) It supports SQL 99 standards.2) It supports Xquery 2004 standards.3) Transparent, direct and run time provision is provided for decision services to interact with multiple data sources that require no SQL coding and processing logic are all hidden.4) Drag and drop provision is there for data integration.5) Comprehensive administrative tools:

Efficient remote server configurations and maintenance. Resource management of data sources, remote tables, views, user groups etc. Session and transaction processing. Access management of one or more EDC server instances.

9.6 Corticon Dialogues

Corticon dialogue is a web based platform that enables user to create, deploy and maintain an intelligent web based interaction without programming.Corticon dialogue along with Corticon BRMS together have introduced worlds first model driven, rule based intelligent interaction platform.A dialogue is not an electronic web form but it is completely different from it. A form is a static web page being designed by the programmer which forces the user read and skips over questions that do not apply to them.But a dialogue is created by the business user which is applied with some business rules that present questions that are needed to be ask depending upon the user responses.

9.7 Corticon Dialogues Designer

The questions can be modeled with the help of the corticon dialogue designer. The developer can model the questions, number of pages required and also the form or web look using the designer.This corticon dialogue designer have been integrated with corticon BRMS so the developer can also implement or model the rules that will decide the question that need to be asked depending on the user responses.

9.8 Corticon Dialogues Server

Corticon Dialogues Server is the engine that dynamically renders the intelligence, interactive dialogue pages in the web environment. Using the rules defined and deployed along with the dialogue application corticon server creates a fully reflexive user experience enabling sophisticated user interaction.10 Advantages of Corticon 5 Rule Engine

1) Corticon 5 Rule Engine gives responses in milliseconds and scales easily to support millions of transaction per day. Designed using Deti algorithm the engine scales linearly with increasing number of rules and complexity of data.

2) Corticon 5 Rule Engine ensures accurate results with unique rule engine features that ensure right decisions at right time. A new visual representation, vocabulary enhancements and variance testing ensures data integrity.

3) In this dynamic business environment, rules and policies changes often. So rules designed needs to be updated with time. Corticon 5 spreadsheet provisions for rules development reduce the time and effort to implement the changes and give result with accuracy.

4) Business analysts and policy makers who knows the dynamic change in the business world can easily model new rule and modify the existing ones without the need of having any traditional programming. And as the rules engine are deployed as decision services so rule written once can be used by multiple applications as services. This increases the reusability.

5) Corticon 5 Rule engine enhanced APIs and integration with open source development environments makes it easier for the software developer to choose this as a solution for their business requirements.

11References

http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html

http://www.itbusinessedge.com/cm/blogs/vizard/new-business-rules-for-it/?cs=46382

http://rulesworld.corticon.com/book/export/html/10

http://www.corticon.com/About/News/co_news_pr_20110405.php

2012 Infosys Technologies Limited, India