How to create a 'Rule Package'

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Disclaimer

Below is an extremely simplified model of automotive industry. Please don't use it for serious purposes other than the one I'm going to explain ;-)

Philosophy

To benchmark rules engines performance and integratability in ADempiere, a real rule package is needed. However since rule extraction from real systems is not a trivial task, a simplified model of the real world is presented here to be considered as the world of business from which the rules should be extracted. The model is represented here as plain text, since some of us may not have access to modeling tools.

The model

Entities and their attributes. Each attribute has an abbreviation which may be used when writing rules, eg. instead of SteeFactory profit one may write just SPF.

Model's entities

RawMaterial
Attribute Abbrev. Description
1. name RN Material name: for this purpose only 'Oil' and 'Iron stone'.
2. price RP Price per ton or drum.
3. production RA Production amount per month in tons or drums.



SteelFactory
Attribute Abbrev. Description
1. name SN Steel factory name.
2. rawInput SRI Iron stone input per month in tons.
3. rawDemand SRD Iron stone demand per month in tons.
4. prodcution SPR Net production per month in tons.
5. quality SQU Production quality, between 0 and 100. The less the quality, the less the price will be.
6. price SPC Price per ton.
7. profit SPF Profit per month.
8. customerDemand SCD Customers' demand for steel. Stricly means how many tons of steel sold out per month.



AutomotiveFactory
Attribute Abbrev. Description
1. name AN Automotive factory name.
2. rawInput ARI Steel input per month in tons.
3. rawDemand ARD Steel demand per month in tons.
4. prodcution APR Net production per month in number of automobiles produced.
5. quality AQU Production quality, between 0 and 100.
6. price APC Price per automobile.
7. profit APF Profit per month.
8. customerDemand ACD Customers' demand for automobile. Stricly means the number of automobiles sold out per month.


Model's Effected and Effectors


An X in (R, C) shows that the row R is directly effected by column C.

  RN RP RA SN SRI SRD SPR SPC SPF SCD AN ARI ARD APR APC APF ACD
RN  
RP  
RA  
SN  
SRI X1   X
SRD   X
SPR X  
SPC X1 X   X
SPF X   X
SCD X  
AN  
ARI X   X
ARD X   X
APR X  
APC X   X
APF X   X
ACD X2 X2 X  

1: If the material name is 'Iron stone'.
2: If the material name is 'Oil'.

Model's relations described

  • (SRI <= SRD) always should be true.
  • (SPR <= SCD) always should be true.
  • (SPR <= nSRI) for (n) a pre-defined constant, should be true.
  • (ARI <= ARD) always should be true.
  • (APR <= ACD) always should be true.
  • (SCD = ARI) always should be true.


How profit is calculated:

  • SPF = SPC*SCD - RP*SRI
  • APF = APC*ACD - SPR*SPC

Implementation

After the rule package reaches a reasonable size, implementation will start, probably with multiple engines such as JBossRules[1], Mandarax [2] or eclipse-clp[3]. Then we may judge the performance and ease of use.
For more info, see the related forum on SourceForge [4].

How to add rules?

Should you have extracted a rule, just edit the page and add the rule to the bottom of the page (Don't forget to put your signature at the end of the edited text!). We will discuss it and add it to the package if it is appropriate for the purpose.
Rules should be expressed in plain simple English so that they are understandable by anybody who reads them.

Download the rule package

The latest version of the rule package is always downloadable here: [5]

Any comments or ideas?

Please study the model and inform (me) through 'discussion' tab, in case you have got a better idea or model.

Rules here!

Your rules go here: