VB.NET Tutorial Code 3: Building an Influence Diagram

From DSL
Jump to: navigation, search
Public Sub UpgradeToInfluenceDiagram()
 Try
   Dim net As new Network()
   net.ReadFile("tutorial_a.xdsl")
   
   ' Creating node "Invest" and setting/adding outcomes:
   net.AddNode(Network.NodeType.List, "Invest")
   net.SetOutcomeId("Invest", 0, "Invest")
   net.SetOutcomeId("Invest", 1, "DoNotInvest")
   
   ' Creating the value node "Gain":
   net.AddNode(Network.NodeType.Table, "Gain")
   
   ' Adding an arc from "Invest" to "Gain":
   net.AddArc("Invest", "Gain")
   
   ' Adding an arc from "Success" to "Gain":
   net.AddArc("Success", "Gain")
   
   ' Filling in the utilities for the node "Gain". The utilities are:
   ' U("Invest" = Invest, "Success" = Success) = 10000
   ' U("Invest" = Invest, "Success" = Failure) = -5000
   ' U("Invest" = DoNotInvest, "Success" = Success) = 500
   ' U("Invest" = DoNotInvest, "Success" = Failure) = 500
   Dim aGainDef() As Double = {10000, -5000, 500, 500}
   net.SetNodeDefinition("Gain", aGainDef)
   
   net.WriteFile("tutorial_b.xdsl")
 Catch e As SmileException
   Console.WriteLine(e.Message)
 End Try
End Sub
Personal tools