# A Small Influence Diagram

## (Tutorial)

This tutorial shows you how to implement a small influence diagram in HUGIN Runtime. It requires that you have already constructed the Bayesian belief network from the first tutorial. The influence diagram you are about to implement is the one modeled in the introduction to influence diagrams in the basic concepts section. It helps plantation owner Apple Jack to decide whether or not to give his apple tree, which is losing its leaves, some treatment. The qualitative representation of the influence diagram is shown in figure 1.

Figure 1: The qualitative representation of the influence diagram used for decision making in Apple Jacks plantation.

## Open the Bbn for Editing

First, you must open the Bbn constructed in the first tutorial if it is not already open. Here is how to do it:

- Select "Open" from the "File" menu.
- Enter the name of the Bbn file ("apple.hkb"). You can do this by selecting it from the list of Bbn files (which have the "hkb" extension).

In figure 2, the Bbn has been opened and HUGIN Runtime is currently working in "edit" mode. We need to be in "edit" mode to edit the Bbn, so if your network window shows the Bbn in "run" mode, press the "edit" mode tool button. If you opened it in "edit" mode, you do not need to do anything.

Figure 2: The open Bbn from the first tutorial in "edit" mode.

## Copying Nodes

In the influence diagram in figure 1, there are three nodes very similar to those that we already have. In this case, HUGIN Runtime allows you to copy a group of nodes and paste them in another area of the network pane. Here is how to do it:

- Create a rectangle selection with the mouse cursor around all three nodes (drag a rectangle by holding down the left mouse button).
- Select "Copy Nodes" from the "Edit" menu in the HUGIN window tool bar.
- Select "Paste Nodes" from the "Edit" menu in the HUGIN window tool bar.
- Move the new group of nodes to a spot where there is room for them.

HUGIN Runtime generates new names and labels for the new nodes. You can keep the names and change the labels to Sick', Dry', and Loses' (you cannot use "Sick'" as the name because it contains the prime character which is illegal in names). Do you remember how to change the labels?:

- Select the node with the mouse cursor.
- Enter "Node Properties" by pressing the node properties tool (the left most tool button in the tool bar of the network window).
- Change the "Label" field.
- Press the "OK" button.

You perform the steps above for all three new nodes. Your network should then look as the one in figure 3.

Figure 3: The Bbn extended with Sick', Dry', and Loses'.

The next step is to add causal arrows from Sick to Sick' and from Dry to Dry'. If you do not remember how to do this, these steps will help you create one from Sick to Sick':

- Press the causal arrow tool.
- Drag an arrow from Sick to Sick' with the left mouse button (while holding down the SHIFT key).

Holding down the SHIFT key enables you to create more causal arrows sequentially without having to press the causal arrow tool again and again.

## Adding a Utility Node

So far, the network we have constructed is still a Bbn. Now, we shall make the first change making it an influence diagram. This change is the addition of a utility node. The utility node we shall add is the Harv node (see figure 1) representing the utility gained from the harvest. Here is how to add it:

- Press the utility tool (to the right of the causal arrow tool).
- Click somewhere in the network pane (a good place would be in the lower right corner besides the Loses' node.
- Change the name and label of the new utility node to "Harv".

The harvest depends on the state of Sick' and thus there is an arrow from Sick' to Harv. Add this arrow:

- Press the causal arrow tool.
- Drag an arrow from Sick' to Harv.

The utility of the harvest was specified to that found in table 1.

Sick'="sick" | Sick'="not"
3000 | 20000
Table 1: U(Harv).

You enter the values of table 1 into the utility table of Harv as follows:

- Choose the Harv node as the currently active node by selecting it from the drop down list below the tool bar or simply by double clicking it.
- Enter the values from table 1 in the utility table in the node edit pane.

## A Desicion Node and one more Utility Node

Now, you are about to add the decision node Treat (see figure 1). This is done similar to the way you add chance nodes and utility nodes:

- Press the decision tool (to the right of the utility tool).
- Click somewhere in the network pane (a good place would be to the right of the Dry node)
- Change the name and label of the new decision node to "Treat".

You add an action to a decision node in the same way as you add a state to a chance node:

- Choose the Treat node as the currently active node by selecting it from the drop down list below the tool bar or simply by double clicking it.
- Press the add state tool.
- Change the action names to "treat" and "not".

The Treat decision node has an impact on the Sick' node so:

- Add an arrow from Treat to Sick'.

The new decision node represents the decision to give the tree some treatment or not. If the plantation owner (Apple Jack) chooses to give treatment this will cost him something which shall be modeled by the Cost utility node. The Cost node has the utility table shown in table 2.

Treat="treat" | Treat="not"
-8000 | 0
Table 2: U(Cost).

Now, add the Cost utility node to the influence diagram:

- Add a new utility node (a good place would be to the right of the Treat node).
- Change the name and label of this node to "Cost"
- Add an arrow from Treat to Cost.
- Fill in table 2 in the utility table of Cost.

## Filling in Cpts

When we copied the nodes Sick' and Dry', they inherited the cpts of Sick and Dry. However, as both these nodes have become children of other nodes, their cpts are no longer correct. Their new cpts were specified to those found in table 3 and table 4.

- Fill in table 3 as the cpt of Sick'.
- Fill in table 4 as the cpt of Dry'.

| Treat="treat" | Treat="not"
Sick="sick" | Sick="not" | Sick="sick" | Sick="not"
Sick'="sick" | 0.20 | 0.01 | 0.99 | 0.02
Sick'="not" | 0.80 | 0.99 | 0.01 | 0.98
Table 3: P(Sick' | Sick, Treat).

| Dry="dry" | Dry="not"
Dry'="dry" | 0.60 | 0.05
Dry'="not" | 0.40 | 0.95
Table 4: P(Dry' | Dry).

Now, your influence diagram is finished and it should look like the one in figure 4. At this point it would be a good idea to save your influence diagram.

Figure 4: The complete influence diagram.

## Compiling the influence diagram

You can now try out the influence diagram and hopefully you are eager to see how it works. First, compile the influence diagram:

- Press the compile tool (the right most tool button in the network window tool bar).

In addition to the errors described in the first tutorial in the case of influence diagrams the compiler alse checks that there is a directed path through all of the decision nodes - if not it will return an error message. If the influence diagram does not compile, you have probably made some minor error. You should first check that the causal arrows are correct. Then, go through each of the cpts/utility tables of the nodes.

## What Should Apple Jack Do?

When the influence diagram has been compiled, first imagine that the only thing Jack knows about his tree is that it is losing leaves. Then, what will be the best thing for him to do? To find out this, follow these steps:

- Expand the Loses chance node and the Treat decision node in the node list pane on the left (by double clicking them).
- Enter the evidence that Loses is "yes" (by double clicking the "yes" state).
- Propagate the influence diagram (press the sum propagation tool).
- Read the expected utility of "treat" and "not" in the Treat decision node.

You should be reading something looking like that in figure 5.

Figure 5: The influence diagram propagated with the evidence that Loses="yes".

You read 10234.4 as the expected utility of giving treatment and 11514.0 as the expected utility of not doing anything. This suggests that it will be best for Apple Jack not to treat the tree.

If you read other values than those specified above, you have probably mistyped something when filling in the cpts. Then, check the cpts/utility tables of all the nodes.

In a decision situation, your opinion about what to do will sometimes change when you learn more facts about your situation. Lets see what happens if Jack knows that it has been raining a lot lately and that the tree under no circumstances can be suffering from drought. Then the state of Dry can be set to "not":

- Enter the evidence that Dry is "not".
- Propagate the influence diagram.
- Read the expected utility of "treat" and "not" in the Treat decision node.

You should read 9138.33 as the expected utility of giving treatment and 5918.33 as the expected utility of not doing anything. In this case, it will obviously be best for Jack to give the tree some treatment.

The reason for the difference between these two cases is that in the first case, it is likely that the tree is suffering from drought. Then, of course, the costs of treating the tree for a sickness will not pay off.

This finishes the tutorial. You should now be able use HUGIN Runtime to construct your own influence diagrams. However, if you want to create large and complex models, you should study the area more than just reading this tutorial.

| HUGIN Expert A/S | , 1998

Back