RuleLab.Net Architecture
RuleLab.Net
Web-based Business Rules Management
System (BRMS). Provides a Rules Designer GUI, a Business Rules Engine (BRE), an
XML Web Service, and an online Rules repository. Empowers business users with
the direct access to the Rules. Enables seamless integration with applications
supporting XML. Use it in our ASP model or host on your server.
RuleLab.Net enables business logic automation via a set of Rules stored and implemented separately from the application code. The Rules are expressed in an easily readable format and can be maintained through the internet environment. A rules-centralized repository and an application interface allow seamless integration in which business rule changes can take effect at runtime.
RuleLab.Net uses XML for interfacing with application data and expressing the Rules internally. In fact, every object of the RuleLab.Net user project is stored in an XML document that is available for download. The application data you pass to the BRE should be formatted in XML. By linking your XML data nodes with RuleLab.Net objects at design time, you can teach RuleLab.Net how to interpret your data model. This process is fully supported by the Rules Designer through an intuitive Web GUI.
The RuleLab.Net environment accommodates both system developers and business users managing the rules. RuleLab.Net consists of:
Our Rules editor and the Rules Engine allow you to know nothing about how your Rules are stored. If, however, it is beneficial for you to deal with Rule files directly, you will find that your rules and rule building primitives are stored in XML files in an easy-to-understand, open format.
At the heart of RuleLab.Net are the links between rules and application XML data. The rules that you create can only be evaluated when they are related to a context of data that you supply at runtime. The association between your data and the Rules is defined via XML References that tell RuleLab.Net about your data elements. References are built into Rule building blocks such as Atoms and Facts which in turn provide the foundation for composing the actual business rules.
The RuleLab.Net project consists of the following objects:
Application XML data is an integral part of a RuleLab.Net project. The BRE process has one primary purpose: to return data updates to the application XML document. RuleLab.Net allows you to build the rule base around your data model, and it does that by applying the following:
RuleLab.Net provides support for loop structures as long as they do not contain nested loops. You can specify a node as a Loop Reference which allows you to create Rules with predicates such as “Any”, “Each”, “Maximum”, “Minimum” etc. and aggregate functions like “Number Of”, “Sum Of”, “Average”, and more. A Rule can also be applied separately to every group of loop items.
The default currency symbol is set to “$”. You have the option of entering another symbol via the Account Settings so that monetary fields are rendered in the Rules Designer according to your preferred currency type and monetary data assigned by the BRE is prefixed with the currency symbol.
Application database direct access
You can have RuleLab.Net
rules engine run SQL commands on your database
including selects, updates, inserts and stored procedures. The rules engine
will automatically execute your commands at runtime to move data between the
application XML and your database. Through entering SQL commands into the Rules
Designer, you can make the rules operate directly on your application’s
database.
RuleLab.Net Data Structure
RuleLab.Net stores objects of each type in an XML document. There is an XML document for XML References, a document for Atoms, and documents for Facts and Rules. Each document is written into a file. XML files are stored in the online database under your master login. They can be downloaded to your local box. Every RuleLab.Net XML file can be instantiated through the Rules Designer using the Project screen and the Editor tab corresponding to this file category.
At design time, the Rules Designer enforces many restrictions in order to maintain data integrity of the XML documents being edited. While it doesn’t prevent you from saving inconsistent information, it arms you with the validation that catches many issues. Rule developers will have to correct the problems identified by the validation before running the BRE. The result of using the Rules Designer is a set of files that should be passed to the BRE via one of the integration methods.
You can have multiple Rule files utilizing the same Reference, Atom, and Fact files. By the same token, you can have multiple Fact files referring to the same Atom XML file. At design time, you link Reference, Atom, Fact, and Rule files together into an online Project. At runtime, your application provides these 4 files as an input for the BRE. There is no Project constraint at runtime. The developer and the application are responsible for supplying RuleLab.Net XML files that logically belong together. Normally that would be a set of files from the online Project.
Rules Designer projects assist with organizing the files online. Each RuleLab.Net project is Rules-file oriented. A project includes one Rules file and 3 corresponding Reference, Atom, and Fact files. The project is only needed to link the 4 files together for online editing. When integrating, you will have to keep track of which RuleLab.Net XML files logically belong together. When running the BRE, you will supply these 4 files to initiate the BRE session. Additionally, there is an option of including a number of common Rule files with the main Rules file.
The Rules Designer is a web page that implements an integrated development environment where you can create and manage the Rules and other RuleLab.Net objects. The Designer offers an intuitive GUI, easy navigation, and powerful set of commands for Rule editing. No programming is required to build the rules. Your entire project can be composed through clicking and typing object names. Rules are presented in an easy to read syntax. When it comes to editing a rule, a full set of commands is available. The only syntax you will have to adhere to is the calculation Formula format which is easy and fairly common.
Rules Designer screens have Validate buttons that check the syntax and ensure data integrity across the files loaded into the Designer. For example, it will alert you if an Atom utilized by one of the Rules has been erased (most likely via editing offline and uploading Atoms files). Or, it will tell you that the Formula calculation result is incompatible with the Atom type it is being compared with. All error messages are click-through. Message links will take you right to the affected element.
Conditions, Preconditions and Actions
Each Rule consists of a Condition and an Action. Optionally, you can specify a Precondition that will disable rule processing if the Precondition is not satisfied. When the Rule is evaluated, it utilizes XML References to extract data values from your XML document and to write back the assigned values. Data-value extraction takes place in the Condition parsing.
Condition
The Condition is an IF-statement consisting of logical functions (And, Or, Not), comparison predicates (Equal To, Less Than, One Of, etc), data parsing functions (Sum Of, Text Length, Regular Expression, etc.), calculation formulas, Atoms, and Facts. Ultimately, the Condition compares groups of XML data references (Atoms and Facts) against each other to yield the true or false returns. If the Condition was not able to find data to evaluate its every Atom, then the Rule won’t fire. The following classification is used to describe various Condition processing outcomes:
Rule Fired – the rule Action was evaluated and executed based on the Rules Conflict Set resolution
Action
Actions are groups of Atom assignments that are executed if the Rule condition is satisfied. Each Action may assign data to one or multiple XML nodes in your document. In addition, Actions can assign a value to a system variable that is utilized for Rule processing just like your XML Data Reference but is not stored within your XML document. The assignment result could be the final data assignment your application is looking for, and/or it can be data context resolution that other Rules are looking for. By assigning values to Atoms, an Action can enable other rules which would fail to fire otherwise.
If you would like the Rules to generate user messages, you can set an Atom to a text string that embeds other Atoms. The Action will replace them with data values at run time. Multiple messages instantiated by several rules can be concatenated within a single Atom string.
You may find it useful to dynamically generate user choices through building selection lists via an Action. An Action can add XML fields to the application XML document. The application GUI would then render them in dropdowns and listboxes.
Preconditions
A precondition is an optional logical statement that enables Rule Condition processing. A precondition consists of 2 parts:
- logical If-statement just like the Condition (same format)
- set of Satisfied Riles – a list of Rules that must be satisfied in order for this rule to process
You may find it useful to use a precondition in many scenarios. For example, you can control whether a particular empty data item should be treated as missing data or a blank. In other words, you can tell the Rule whether to fire or not if empty data is encountered. For data validation applications, you can use Preconditions to specify the required data that must be filled before data is analyzed by the Condition.
RuleLab.Net Business Rules Engine
The Business Rules Engine (BRE) executes the rules against application data. Rules are executed in cycles using event driven reasoning (forward chaining). The RuleLab.Net BRE implements an Inference Engine that processes the Rules. With each cycle, the BRE attempts to make all possible inferences from application data available through XML References. A rule can be evaluated by the BRE only when all data values specified in the Condition are known and when the Precondition is met. The rule fires if the rule condition evaluation was successful. As a result, the rule’s Action is executed. If the condition was satisfied, the Action parses the on-success clause, otherwise it carries out the on-failure clause. The Action may set data values that add to the set of known facts. With more facts available, new inferences become possible. The BRE continues its cycles until all inferences have been made.
When your application calls the Engine to initiate rule processing, it starts the Engine pass. Within each pass, the Engine runs in cycles until no more rules fire. Depending on rule conditions and actions, each pass may consist of multiple cycles. As long as at least one rule has fired in a given cycle, the Engine runs another cycle to evaluate the rules that have not yet fired. Once the pass is complete (no rules fire any more) the control is returned back to the application.
Your BRE session may consist of multiple passes. How many passes to initiate is entirely up to you. Only you and your application know the ultimate goals driving your system. Of course, if all rules have fired there is no point in starting another pass. But if the goals have not been reached while there are misfired rules, your application can supply the missing data and have the BRE run another pass.
With every pass, the BRE
returns an XML document containing the
Rule Priorities and Rule Conflicts
The order in which rules are evaluated is determined by the rules’ physical order and the assigned priority. The priority of rules in the main Rules document ranges from 1 to 10. Included Rules documents may feature higher priority numbers. Rules within the same priority level are executed according to their original order.
If multiple rules attempt to change the same Atom then the “rule conflict” occurs. The BRE resolves the conflict by granting the first or the highest priority rule the right to alter the object but it also returns the other conflicting rules through the State. Your application can overwrite the BRE’s default decision. For more information on custom conflict resolving, see the BRE State documentation.
When multiple rules target the same Atom, the one that will change it must be the first to fire or have a higher priority. To fire first, it should be physically (in the Rules Browser) positioned above the other rules. If a Rule within the conflict set has a higher priority but fails to fire in the cycle in which a lower priority conflicting Rule fires, then it can overwrite the target Atom within a cycle where its condition becomes satisfied.
Having higher priority, however, does not entitle a higher priority Rule to overwriting an assignment made by a lower priority Rule in one of the preceding cycles if the assigned Atom has been accessed after the assignment had been made. This situation might occur if the higher priority Rule’s condition is not satisfied in a given cycle but a conflicting lower priority one is satisfied, fires, and the assignment it makes is utilized in some other rule condition evaluation. The BRE keeps track of the assigned Atoms being utilized by subsequent Rules. The BRE will not allow changing them if the assigned value has become part of the subsequent rules evaluation process.
You have the option of
marking an Atom “overwritable” in which case the conflict issue will not apply
to it. Such Atoms can be changed by any rule at the time it is fired. For
example, you may want to mark the “total” Atom as overwritable if it can be
subsequently altered by several rules/formulas. Or, you would want to make the
“UserMessage” Atom an overwritable atom if multiple rules can add additional
text messages to it.
You can overwrite the default ruleset by selecting which rules to run and the order of evaluation. The rule selection document can be passed to the BRE at runtime as well as through the Test screen.
BRE workflow
The following steps take place at runtime when your application calls the BRE:
Developers --
The first step of building your RuleLab.Net application is defining the data model reflecting the business context. Assuming you already have an XML data model that needs a rule based component, the developer will have to work with business users to identify and label knowledge elements that will be utilized in the RuleLab.Net projects. They can be simply the existing XML data document nodes. Note that the aliases assigned to them in the RuleLab.Net can be made far more descriptive than the XML node name.
Business requirements to the rule based system will usually go beyond the existing XML data document. It should be expected to have more categories and relationships that would have to be formalized as Atoms and Facts. Some of them might already exist within your program code. Others will have to be worked out between the business analyst and the developer in order to fit into an automated solution.
As a result of the joint effort between business analysts and developers, a preliminary set of the building blocks - Atoms and Facts - should be created. It is a good idea to write down how each Fact should be interpreted by the system – in plain English. It will make Rules a lot more readable to business users and help you build a knowledge base. You will also need to decide how the Atom/Fact library might be utilized by multiple Rule files and preset your RuleLab.Net Projects accordingly.
Once you write up the basic building blocks of your desired rule based system, using RuleLab.Net should be easy for most developers. First you need to register and get a login. You will need to decide whether you want to have your RuleLab.Net content encrypted (this can be changed later on). Once you feel comfortable with the system, follow these steps to build your rule-based solution.
|
Business Analysts –
RuleLab.Net gives you the ability to define application logic in your terms, unwire it from the program code, and modify it on the fly to support changing business requirements. Business analysts should work with the developers to produce a basic set of Atoms, Facts, Natural Terms, and Rules. The developer should integrate RuleLab.Net with the application and test it on the initial Rule set. As a result of this process, the developer should deliver the following:
Business analysts can use the system to do the following:
If multiple users are going to update the system, decide who and when should be making changes to avoid conflicts. Note that the system provides limited capabilities of protecting data from overwrite by concurrent users. There is no data locking but RuleLab.Net’s Rule Designer watches for multiple users logging in and updating same data. It gives warnings and confirms user actions accordingly.
For more information on how
to manage RuleLab.Net files online and deploy changes into the production,
see the Project Screen section. |
|
Once your team masters the initial stage of designing and integrating your rule based system, you will have a shared rule repository available for secure browsing/editing from anywhere on the internet. Your business rule changes will be picked up by your software application and applied to the runtime data.
Learn more
about the RuleLab.Net online service (ASP model)
Managing RuleLab.Net projects.
Security of the online content