Task 7: Applying decision models to multi-valued variables

You learn how to apply decision tables to multi-valued variables and decompose complex decision logic into manageable components.

A decision table can process all values of a multi-valued variable by using a precondition that iterates over each value. For example, if lens requirements contains standard lens and super-telephoto lens, the decision table evaluates both values sequentially.

The decision table from Task 6 includes a dedicated lens requirements column to make decisions based on the lens type:

An example of a decision table

Task 4 introduced decomposition of complex decision logic by using intermediate decisions. This principle extends to multi-valued variables but requires extra modeling constructs.

Consider an enriched decision logic for lens model selection. A fixed-focus lens must be chosen instead of a zoom lens in these cases:

  • Professional photographers who take portraits.
  • Super-telephoto lenses that are used for sports photography.

The lens model decision now depends on the subject, the photographer level, the sensor format, and the lens type:

An example of a decision model

Based on this update, two columns for level and subject are added to the decision table by using the following rules:

Lens Type Photographer Level Subject Lens Model
Standard, telephoto, wide-angle, super wide-angle Professional Portrait Fixed-focus
Standard, telephoto, wide-angle, super wide-angle Any Landscape, Sports Zoom
Standard, telephoto, wide-angle, super wide-angle Beginner Any Zoom
Super-telephoto Professional Portrait, Sports Fixed-focus
Super-telephoto Beginner Sports Fixed-focus
Super-telephoto Any Landscape Zoom
Super-telephoto Beginner Portrait, Landscape Zoom

This results in a 46-row decision table:

An example of a decision table with 46 rows

This large decision table can be decomposed by using the method from Task 4, but this requires refactoring:

  1. Introduce a new decision model for choosing lens models based on photographer level, subject, sensor format, and selected lens type. This submodel contains a single decision node with a decision table that has no precondition and references the selected lens type from an input data node.
  2. Replace the decision table with a rule that calls the submodel for each value in lens requirements:
    for each lens type called 'lens type' , in 'lens requirements'
        add the lens-model computed from
            subject being subject ,
            level being level ,
            sensor format being 'sensor format' ,
            lens type being 'lens type' to decision ;

It is now possible to apply the decomposition method from Task 4 in the submodel.

Note: The solution for the following exercises are available through the New decision service wizard under Practice tutorials. For more information about importing samples, see Building decision services.

Exercise 1: Enhancing the main decision table

You update an existing decision table:

  1. Add two dependencies to the decision diagram that you built in Task 6:
    • lenses must depend on level
    • lenses must depend on subject
  2. Click the lenses decision node and open the decision table that it contains. Then, add two condition columns for level and subject.
  3. Expand the decision table by duplicating and refining rows for different photographer levels and subjects:
    Standard, telephoto, and wide-angle lenses
    Create four rows per sensor format:
    Row Photographer Level Subject Lens Model
    1 Beginner Any Zoom
    2 Professional Landscape Zoom
    3 Professional Sports Zoom
    4 Professional Portrait Fixed-focus
    Super wide-angle lenses
    Create four rows for full-frame cameras:
    Row photographer level subject lens model
    1 Beginner Any Zoom
    2 Professional Landscape Zoom
    3 Professional Sports Zoom
    4 Professional Portrait Fixed-focus
    Super telephoto lenses
    Create six rows for full-frame cameras (three for each photographer level):
    Row photographer level subject lens model
    1 Beginner Sports Fixed-focus
    2 Beginner Landscape Zoom
    3 Beginner Portrait Zoom
    4 Professional Sports Fixed-focus
    5 Professional Portrait Fixed-focus
    6 Professional Landscape Zoom

    The resulting decision table should contain 46 rows.

Exercise 2: Creating the lens model submodel

You create a new decision model called lens-model:

  1. Add four single-valued input data nodes: level, subject, sensor format, lens type.
  2. Add a decision node named lens of output type lens model.
  3. Draw links between the lens node and the four input data nodes.
  4. Add a decision table to the lens node:
    1. Create the same columns as in Exercise 1 without defining preconditions.
    2. Update the lens requirement column so it references the lens type node value instead of a value that is defined by preconditions.
    3. Update the action column to use a set decision to construct instead of an add construct.
    4. Copy rows and from Exercise 1.

Exercise 3: Introducing an intermediate decision node

You refactor the decision model by introducing an intermediate decision node:

  1. Add a decision node named fixed focus lens of output type Boolean.
  2. Draw the following links:
    • From fixed focus lens to subject, level, and lens type.
    • From lens model to fixed focus lens.
  3. Remove the links between subject and lens model and level and lens model.
  4. Refactor the decision table to reduce complexity:
    1. Replace multiple columns with one: remove the photographer level and subject columns and add a single fixed focus lens Boolean column.
    2. Reduce the row count by keeping only two rows per lens type and sensor format combination:
      • One row for when fixed focus lens = true
      • One row for when fixed focus lens = false
Before refactoring
Lens Type Sensor Format Photographer Level Subject Lens Model
Standard Full-frame Beginner Any Zoom 24-70 mm
Standard Full-frame Professional Landscape Zoom 24-70 mm
Standard Full-frame Professional Sports Zoom 24-70 mm
Standard Full-frame Professional Portrait Fixed 50 mm
After refactoring
Lens Type Sensor Format Fixed Focus Lens Lens Model
Standard Full-frame false Zoom 24-70 mm f/2.8
Standard Full-frame true Fixed 50 mm f/1.4

Exercise 4: Integrating the submodel

You adjust the decision logic of the lenses node in the main decision model:

  1. Add a function node to the main decision model:
    1. Select the decision model that you created in Task 7, Exercise 3 for the function node.
    2. Draw a link between the function node and the lenses node.
  2. Replace the existing decision logic of the lenses node with a single rule that:
    • Iterates over all lens types in the lens requirements multi-valued node.
    • Calls the submodel from Exercise 3 for each lens type.
    • Passes four arguments for each invocation: subject, level, sensor format, and lens type.
    • Adds the returned lens model to the multi-valued decision node.

Lessons learned

Submodels enable:

  • Complex decision logic on multi-valued nodes and variables.
  • Decomposition into maintainable components.

Limitations

The main model's dependency graph currently contains two separate decision nodes that each represent part of the recommendation result. This separation can be simplified.

The final step in this tutorial demonstrates how to merge these two decision nodes into a single, unified decision node for a cleaner model architecture.