Tutorial Creating Decision Table Functions - Gnorion/BizVR GitHub Wiki
back to BizVR Tutorial
Tutorial Creating Decision Table Functions
BizVR supports many Different Types of Decision Tables
This tutorial covers how create and execute decision tables as functions
Here is a simple example that allocates resources to tasks:
You can see on the input side there are two inputs:
These will be json structures like this:
On the output side you can see a function call:
The output will also be json and will look like this
In the middle is the decision table which implements the function allocate(RESOURCES,TASKS)
Its important that the order of the arguments is the same in each place (Inputs, Decision Table and Outputs)
The decision table detail looks like this:
The first two line define the context of the decision table. In this case every resource and every task that is in the input json. The decision table will automatically create every combination of resource and task and then test the three conditions in lines 3, 4 and 5.
- Line 3 makes sure the resource is available
- Line 4 checks that the capability of the resource matches the requirement of the task. In a real-world decision this might be quite complicated)
- Line 5 checks the resource cost. Rule 1 tells what to do if the resource cost is under the maximum cost allowed for the task. Rule 2 tells what to do when it isn't
When a match is found, the actions:
- Create a new assignment
- Set a suitable description
- Add the resource to the assignment.
- Add the task to the assignment.
- Add the new assignment to a list of assignments
- Return the list as the output
We could also have done this instead of line 3:
{aResource in RESOURCES where aResource.available='yes'}
This is reminiscent of a SQL query
Alternate Representation for Resource Allocation
back to BizVR Tutorial