Home / PolicyModels Tutorial

The Section Node

Decision graph nodes can be grouped into sections. This is useful when a set of nodes deals with a certain issue, and we want to group them semantically. For this, PolicyModels offers the [section] node.

A section node has two components. An optional title, and a the set of decision graph nodes it groups:

[>section-id< section:
  {title: Sample Section Title}
      {text: ..... }
  [set: Slot=value]

Section nodes can be nested as needed. It is also possible to skip to the end of a section, using a [continue] node.

Sample Graph with Sections

Suppose we want the user to select three independent sets of animals: dogs, cats, and frogs. The graph below uses sections to logically group the nodes that deal with each animal type together.

Sections are normally inlined, that is, are part of the decision graph. If a section is large enough, it may make sense to wrap it in a part node, and then call it. In the code below, the >frogs< section is inlined, and the >cats< and >dogs< sections are not.

The >cats< section demonstrates a typical use of a [continue] node: It starts by asking the user whether she is interested in adding cats at all. If the answer is “no”, the rest of the section is skipped.

 1 [call:pDogs]
 2 [call:pCats]
 3 [>frogs< section:
 4   {title: Add frogs}
 5   [todo: Add frog 1]
 6   [todo: Add frog 2]
 7 ]
 8 [todo: specify mice]
 9 [end]
11 [-->pDogs<
12 [>dogs< section:
13   {title: Dogs!}
14   [ask:
15     {text: What type of dogs?}
16     {answers:
17       {none: }
18       {animated: [set: Dogs += Pluto]}
19       {cute: [set: Dogs += Rex, Lassie]}
20       {hounds: [set: Dogs += Pluto, Lassie]}
21     }
22   ]
23 ]
24 --]
26 [-->pCats<
27 [>cats< section:
28   {title: Cats}
29   [ask:
30     {text: Do you want cats?}
31     {answers:
32       {no: [continue]}
33     }
34   ]
35   [ask:
36     {text: Which cats?}
37     {answers:
38       {all: [set: Cats += Tom, Garfield, Cleo]}
39       {some: [set: Cats += Tom, Garfield]}
40     }
41   ]
42 ]
43 --]

Visualization of a decision graph with sections.

This completes the types of nodes PolicyModels currently has to offer. The last tutorial will look into a why the order of values in a slot matters.