I am not sure if I completely understood how to go about with it.
I have attached the test code which I used, after it didn't work for my network.
The vecJPTs vector is always empty.
(I tried even initializing it to some values but after the GetJpts function call it becomes empty. So I guess there is something happening in GetJpts, which I cant understand!)
Is it because I am using Pearl's Inference algo?
Where am I going wrong?
Code: Select all
// Opening the network
DSL_network testNet;
// Network contains 3 nodes with their Identifier names as A, B, X
testNet.ReadFile("Test_1.dsl");
/* Pearl's Inference Algorithm
- Exact Algorithm
- For Polytrees only
- Like Lauritzen based on message passing, but now messages are passed between original nodes
and not cliques nodes of a join tree */
testNet.SetDefaultBNAlgorithm(DSL_ALG_BN_PEARL);
// Get the handle of node "A"
int nodeA = testNet.FindNode("A");
// Get the handle of node "X"
int nodeX = testNet.FindNode("X");
// Set Evidence on Node X
testNet.GetNode(nodeX)->Value()->SetEvidence(0);
// Enable JPT Storing
testNet.EnableJptStore(true);
// Update the network
testNet.UpdateBeliefs();
// To store the JPTs
vector< pair<vector<int>,const DSL_Dmatrix *>> vecJPTs;
// Get JPT's
int err= testNet.GetJpts(nodeA,vecJPTs);