VB.NET Tutorial Code 4: Performing Inference in Influence Diagrams
From DSL
Public Sub InferenceWithInfluenceDiagram()
Try
' Loading and updating the influence diagram:
Dim net As new Network()
net.ReadFile("tutorial_b.xdsl")
net.UpdateBeliefs()
' Getting the handle and the name of value indexing parent (decision node):
Dim aValueIndexingParents() As Integer = net.GetValueIndexingParents("Gain")
Dim nodeDecision As Integer = aValueIndexingParents(0)
Dim decisionName As String = net.GetNodeName(nodeDecision)
' Displaying the possible expected values:
Console.WriteLine("These are the expected utilities:")
For i As Integer = 0 To net.GetOutcomeCount(nodeDecision) - 1
Dim parentOutcomeId As String = net.GetOutcomeId(nodeDecision, i)
Dim expectedUtility As Double = net.GetNodeValue("Gain")(i)
Console.Write(" - """ + decisionName + """ = " + parentOutcomeId.ToString() + ": ")
Console.WriteLine("Expected Utility = " + expectedUtility.ToString())
Next
Catch e As SmileException
Console.WriteLine(e.Message)
End Try
End Sub