Task 5: Using the interaction policy

You add a storm alert by updating the data and decision models. When you run the decision model to test the storm alert, it produces a greeting and a warning to stay home.

About this task

In this task, you...

  • Add a boolean attribute to the composite type in the data model.
  • Create a rule to use the new attribute in the decision model.
  • Set the order of the rules to apply the new rule first.
  • Run the decision model to check your changes.

Step 1: Adding an attribute

About this task

In this step, you add an attribute to the composite type in the data model.

Procedure

  1. Click the Navigation history icon in the upper right bar, and then click Data to return to the data model.
  2. In the left panel, select weather.
  3. In the Attributes section, click the Add button to create an attribute.
  4. Change the name of the attribute to storm alert, and set its type to boolean.

Step 2: Modifying the decision logic

About this task

In this step, you add a business rule to use the storm alert attribute in the Weather advice node, and then set the sequence for running the rules in the node.

Rules are run in a specific order. By default, they are sequentially run in the order in which they are listed in a decision node. However, you can supersede the default behavior by setting the order for running the rules (see Choosing an interaction policy).

Procedure

  1. Click the Navigation history icon to return to My Model and its Modeling tab.
  2. Select the Weather advice node, and open the Logic tab.
  3. Click the Add button Add and select Business rule.
  4. Enter storm rule in the Name field, and select Weather is storm alert in the list of criteria.
  5. Click Create. The rule opens in the rule editor.
    The Error report tab shows an error. You fix the error when you define the rule.
  6. Enter the following rule statement:
    if
        Weather is storm alert
    then
        set decision to "Stay home! There is a storm alert." ;
  7. Click Back to the diagram.
  8. To set the order for applying the rules, expand Rules are applied in sequence in the right panel, and select First rule applies in the menu.
  9. Click the dots next to the storm rule in the Logic tab, and select Move to top in the menu to apply the rule first.
    Now, the storm rule runs first. When the storm alert notice is selected in the list of test data, a storm warning is added to the output message.

Step 3: Running the model

About this task

In this step, you run the model to check your changes.

Procedure

  1. Open the Run tab.
  2. Add the following test data:
    • name: Jamie
    • rainForecast: 100
    • stormAlert: True (Select the box.)
    • temperature: cold
  3. Click the Rename test data set icon Icon show rename button.
  4. Enter Jamie-storm as the new name of the data set, and press Enter.
  5. Click Run. You get the following message:
    "Hello Jamie! Stay home! There is a storm alert."
  6. Add another set of test data:
    • name: Robin
    • rainForecast: 90
    • stormAlert: False (Do not select the box.)
    • temperature: cold
  7. Rename the data set Robin-rain.
  8. Click Run. You get the following message:
    "Hello Robin! Rainy day. Take an umbrella."

What to do next

Your decision service is now complete. In the next task, you deploy and execute it by using the Decision Intelligence Client Managed Software runtime.