The Business Use Case

Distribute vehicles to dealers in proportion to their day’s supply gap for each type of vehicle.

In the example below 26 20X S-Hybrids will be divided up as follows: Sao Paulo 5, Rio De Janeiro 3, Salvador 3, Fortaleza  4, Manaus 1, Curitiba 3, Recife 4, Macelo 2

Dealer Distribution Rules

Rule #1: Calculate Day’s Supply for each dealer. Day’s Supply = Inventory / Daily Retail Volume

Rule #2: Calculate DS Gap for each dealer. DS Gap = Target DS – Day’s Supply

Rule #3: Calculate Distribution Ratio for each dealer. Distribution Ratio = DS Gap / Total DS Gap

Rule #4: If DS Gap < 0, Set DS Gap = 0. (dealer has plenty of inventory)

Rule #5: Based on Distribution Ratio, distribute units of cars for each dealer.


From these rules and the content of the spreadsheet we can infer the existence of some business objects:

A monthly order (for each type of vehicle) which will have an entry for each model showing the quantity available for distribution. It also has a couple of temporary attributes (shown in orange) that will be used to compute totals)

A dealer object that will show for each model the current inventory, daily sales volume etc

The link between these two objects will be the modelName (eg 20X S-HYBRID)


Sample Data

Here is the same objects structure showing how they might look when populated with the data that will be passed into the rule engine (possibly via a web services call)


Sample Results (for just two dealers)

After we run the rules on this data this is the output we expect to get.

The bold type shows what Corticon determined using the rules


Rule Statements

These results will be returned to the calling application in the response payload of the web services call

In addition the following message will be returned as explanations of how the rule engine made its determination


The Rule Flow

This particular decision is done in several steps which can be represented as a rule flow.

Each box on the diagram is a single rule sheet which may contain one or more rules

Calculate Dealer Supply

Here is the rule sheet for calculating the day’s supply and day’s Supply Gap for each model for each dealer.

Notice that although there may be many dealers and many model names we do not need to code a procedural “loop” to iterate over the two nested collections.

Corticon will automatically apply these rules across all the members of the collections and keep the appropriate vales separate.


Determine Total Day’s Supply Gap (for each Model)

Natural Language form

Corticon Expression form

Technical Note: We cannot make use of the ->sum operator in this case because the item.daysSupply has to be summed across all of the different dealers that might have ordered this item.

Also notice that the item.daysSupplyGap > 0 filter has been disabled at the Dealer level. This is

Style Note: We could have used filters rather than explicit conditions in rule 1 (as shown in the expression view). However since Corticon does not (as of Dec 2014) support the use of Natural Language in the Filter section it makes the rule easier to read when the conditions are documented in the rule sheet.


Determine Dealer Distribution

The Rules

Line 1 of the filter is a “join” expression that ensures that we match up the appropriate modelName in the dealer inventory with the modelName in the monthlyOrder.


Compute Total Allocations


Dealer Report

Simply posts this message for each dealer:

Scenario 1-1

This is the test scenario that was provided by Auto Manufacturer

Test Output

These are the rule statements that the rules produce.

The results from Corticon are in exact agreement with the expected results from the spreadsheet


Scenario 1-2

Test Results

Scenario 1-1 also agrees with the expected results

The other scenarios follow a similar pattern

Combining the Test Scenarios

Because Corticon uses the scope section to maintain the context, it can easily handle multiple different dealer inventories for different models at the same time

So if we combine all the data for scenario 1-1 and 1-2 the results are:


Dealers that have no supply gap

Dealers with a supply gap