Problem with inference in Influence Diagrams in pyAgrum
Hi! Thanks for a very helpful library! However, I happened to run into some unexpected behavior with the Influence Diagram inference engine (pyAgrum version '0.17.2' on Windows 10). Minimal code to reproduce is enclosed:
tst_id = gum.InfluenceDiagram()
c = tst_id.add(gum.LabelizedVariable('c', 'chance variable', 2))
c1 = tst_id.add(gum.LabelizedVariable('c1', 'chance variable 1', 2))
d = tst_id.addDecisionNode(gum.LabelizedVariable('d', 'decision variable', 2))
u = tst_id.addUtilityNode(gum.LabelizedVariable('u', 'decision variable', 1))
tst_id.addArc(c, u)
tst_id.addArc(c, c1)
tst_id.addArc(d, u)
tst_id.cpt(c).fillWith([0.5, 0.5])
tst_id.cpt(c1)[{'c': 0}] = [1, 0]
tst_id.cpt(c1)[{'c': 1}] = [0, 1]
tst_id.utility(u)[{'c': 0, 'd': 0}] = [10]
tst_id.utility(u)[{'c': 0, 'd': 1}] = [21]
tst_id.utility(u)[{'c': 1, 'd': 0}] = [100]
tst_id.utility(u)[{'c': 1, 'd': 1}] = [200]
ie = gum.InfluenceDiagramInference(tst_id)
# With the evidence on c set, the utility is completely specified
ie.setEvidence({'c': 0})
ie.makeInference()
ie.getBestDecisionChoice(d) # returns 1 (as expected)
ie.getMEU() # returns 10.5 (I expect to get 21, because for the given
# evidence and the selected decision it is just one line of the utility matrix
Sorry, if I am doing something wrong...