SMILE Tutorial 3: Building an Influence Diagram

From DSL
Jump to: navigation, search

In this tutorial we will extend our old Bayesian network into an influence diagram. Suppose that our venture capitalist invests $5,000 in the venture. She knows that if the venture is successful, she will earn an additional $10,000 on it. If it is not successful, she will lose her entire investment of $5,000, and if she does not invest, her gain will be $500 from a risk-free investment in a bank. We will assume that our capitalist is interested only in financial gain. In case other factors play a role, such as intangible values or non-linearity in the intrinsic value of money, they can be captured by a measure known as utility. We will limit ourselves to mentioning that SMILE supports expected utility calculation, leaving it to the user to learn how to measure and represent utility.

We will extend our simple Bayesian network into an influence diagram by adding to it a decision node and a utility node. The decision will represent the choices of investing or not investing and the utility node will measure the financial gain. We start with the Bayesian network constructed in the tutorial 1.

  DSL_network theNet;
  theNet.ReadFile("tutorial.dsl");

We create decision node Invest. The type of the node will be DSL_LIST which represents a discrete decision node, as explained in the section on node definitions.

  int invest = theNet.AddNode(DSL_LIST,"Invest");

We now set all the possible choices for this decision in the same way we did for the Success and Forecast nodes:

  DSL_stringArray someNames;
  someNames.Add("Invest");
  someNames.Add("DoNotInvest");
  theNet.GetNode(invest)->Definition()->SetNumberOfOutcomes(someNames);

Now we create the utility node. The type used is DSL_TABLE.

  int gain = theNet.AddNode(DSL_TABLE,"Gain");

We now have to create some arcs. From the problem description, we can see that the final financial gain will depend on our decision whether to invest or not and also on whether the company actually succeeds or not. So add these two arcs:

  theNet.AddArc(invest,gain);
  int success = theNet.FindNode("Success");
  theNet.AddArc(success,gain);

Once the structure is complete, let us fill in the numbers. The decision node is perfectly defined by its different options. The value node, on the other hand, needs to be specified in numerical terms. From background information we can tell that the utilities are the following:

U("Invest" = Invest, "Success" = Success) = 10000

U("Invest" = Invest, "Success" = Failure) = -5000

U("Invest" = DoNotInvest, "Success" = Success) = 500

U("Invest" = DoNotInvest, "Success" = Failure) = 500

Since we know that the size of the definition of this node is 4 (2x2x1), this time we will set the values using another method:

  DSL_Dmatrix *theMatrix;
  theNet.GetNode(gain)->Definition()->GetDefinition(&theMatrix);

As we know that the internal representation of the definition of this node is a DSL_Dmatrix, we can gain access to it by means of those last two calls. Given that we know the order of the numbers (because we know the order of the parents of this node), we can set the values of the financial gains directly:

  theMatrix->Subscript(0) = 10000;
  theMatrix->Subscript(1) = -5000;
  theMatrix->Subscript(2) = 500;
  theMatrix->Subscript(3) = 500;

Now we have a complete influence diagram. Let us save it for future use:

  theNet.WriteFile("tutorial.dsl");
Personal tools