Task 5: Implementing sequential rule-based decision modeling
In previous tasks, each rule independently made decisions based on available information for all applicable cases. For composite decisions, this approach requires all decision components to exist as predecessor nodes of the decision node. The decision logic then assembles these pre-computed components into a composite value.
An alternative is to construct both components and composite values within a single decision logic. This approach uses multiple rules to build the composite value incrementally:
- A first rule creates an instance of the composite type.
- Subsequent rules create each component and add it to the composite value.
Rules construct the decision node's value step-by-step through a chain of modifications:
- Each rule receives the decision variable value from the previous rule.
- Each rule outputs a modified version of the decision variable.
- The final decision value is determined by the last rule that executed.
This behavior is enabled by the Rules are applied in sequence policy, which
introduces a computational state that rules can modify. This state consists solely of the decision
variable's value and the values of its attributes. Other variables remain immutable: only the
decision variable and its attributes can be modified.
The Rules are applied in
sequence policy can be used to configure a complete camera system, including camera model
and all lens models, within a single decision logic. The following decision diagram illustrates this
approach:

This diagram eliminates the submodel previously used for selecting multiple lens models. In Task 7: Applying decision models to multi-valued variables, a submodel was invoked for each specific lens requirement, scoping the fixed focus lens and lens model nodes to that requirement.
fixed focus lens
and lens requirement must now be preserved within the lens model itself. The
solution is to extend the data types to embed this contextual information:lens modelis replaced withlens model with details, which contains two attributesfixed focus lensandlens requirement.camera systemis replaced withcamera system with details, which contains one attributelens model with detailsof the newlens model with detailstype.camera systemcan be renamed tocamera system with detailsfor consistency.
The decision logic consists of six rules executed in the following order:
- Init camera system: It initializes a new
camera system with detailswith all attributes undefined. The value of the decision variable is now a camera system with undefinedcamera modelandlens models with details. - Choose camera: It selects the camera model and sets the
camera modelattribute depending on the weight limit, the sensor format, and whether it is equipped with a tilt screen or not, like in Task 8: Adding a final decision node. - Create lenses: It initializes lens models for each requirement. For each
requirement, it creates a new
lens model with detailsand adds it to thelens models with detailslist. It setsfixed focus lenstofalse. Attributes forfocal lengthandapertureare initialized with new objects of typerange. Values for theminimumandmaximumattributes are undefined. - Choose fixed focus lens for portrait and professional: It sets the value
of the
fixed focus lensattribute for each lens model of the camera system totrueif the level is professional photographer and the subject is portrait. - Choose fixed focus lens for sports and super-telephoto lens: It sets the
value of the
fixed focus lensattribute for each lens model of the camera system totrueif the lens model is a super telephoto lens and the subject is sports photography. - Choose lens models: It determines the name, minimum and maximum focal
length, and minimum and maximum aperture of each lens model of the camera system based on the
lens typeattribute of the lens model, sensor format, and thefixed focus lensattribute of the lens model. The decision table contains five custom action columns that set the values of the five attributes like the one defined in Task 8: Adding a final decision node.
Rules are applied in sequence policy executes rules in their listed
order, with each rule potentially modifying the computational state for subsequent rules. Since the
first rule has no condition, it is always applicable in the initial state and executes immediately.
This creates a new state where the decision variable is a camera system with
details object. The second rule is a decision table containing multiple rows. Each row is
executed in the current state if it is applicable in this very same state and the execution modifies
this current state. The third rule is a quantified rule. It follows a specific execution pattern:- All instances of the quantified rule are created based on the current state.
- New instances are not created after the first instance executes.
- Each instance executes in order: the first instance evaluates applicability in the current state. If applicable, it executes and modifies the state. The second instance evaluates applicability in the modified state. If applicable, it executes and further modifies the state. This continues for all instances.
- A rule instance's applicability is always evaluated in the state at the moment of execution, not in the initial state.
Exercise: Using the Rules are applied in sequence policy
- Duplicate the
lens modeldata type and rename it tolens model with details. - Add the following attributes to the
lens model with detailsdata type:fixed focus lengthof typeBooleanlens typeof typelens type
- Duplicate the
camera systemdata type and rename it tocamera system with details. - Rename the
lens modelattribute tolens model with detailsand change its type tolens model with details. - Create a decision model with the following nodes and define its nodes:
- Add the following input data nodes:
- level of type
level - subject of type
subject - budget of type
integer - requirement of type
requirement - lens requirements of type
lens type, multi-valued
- level of type
- Add the following decision nodes:
- sensor format of output type
sensor format - camera system with details of output type
camera system with details
- sensor format of output type
- Draw links between the sensor format node and the level, subject, and budget nodes.
- Draw links between the camera system with details node and the sensor format, requirement, and lens requirements nodes.
- Add the following input data nodes:
- Add a decision table to the sensor format decision node:
- Click the decision node and open the Logic tab.
- Click Create rule artifact and select Decision table.
- Copy content from the decision table available in Task 4: Making intermediate decisions.
- Define the decision logic of the camera system with details decision node:
- Make sure the
Rules are applied in sequencepolicy is selected. - Implement the six rules described earlier.
- Make sure the
- Go to the Run tab.
- Create a test data set with the following values:
- level: professional
- subject: sports
- budget: 2000
- weight limit: 1000
- equipped with tilt screen: false
- lens requirements: super-telephoto lens
- Click Run and note the lens model result.
- Go back to the camera system with details decision node and change the order of the rules by moving Choose lens models before the two rules that determine the fixed focus lens.
- Go back to the Run tab and run the data set again. Is the same lens model returned?
Lessons learned
A decision logic using the Rules are applied in sequence policy has three
defining characteristics:
- Rules execute in order and may modify the decision variable or its components but no other variables.
- If no rule is applicable, the decision remains undefined.
- The value of the decision node is the value of the decision variable after the last rule executes.
Limitations
Determining composite values and their components within a single decision logic has several drawbacks:
- Rules that depend on results from other rules must be ordered after those rules. For example,
the decision table for determining lens models requires
fixed focus lensinformation, so it must follow the rules that set this attribute. Incorrect ordering produces incorrect results. - Dependencies between intermediate computations are implicit rather than explicit in the model structure. This reduces visibility into the decision-making process and makes the logic harder to understand and maintain.
- Composite values must be extended with attributes needed for intermediate computations, mixing concerns within a single type.