I have noticed that after to have create a network net, when I want to update the beliefs, if I put just this line:
net.updateBeliefs();
or if I put these three lines:
net.writeFile("graph.xdsl");
net.readFile("graph.xdsl");
net.updateBeliefs();
I don't have the same results.
It is the results with the second method which are corrects.
Is there in the write and read methods, some other things that just writting and reading, or is it a bug?
Thanks,
write and read functions in jSMILE
-
- Site Admin
- Posts: 1473
- Joined: Mon Nov 26, 2007 5:51 pm
Re: write and read functions in jSMILE
If your observations is correct, it's definitely a bug. Can you post your Java code you're using to create the network?tamuzem wrote:Is there in the write and read methods, some other things that just writting and reading, or is it a bug?
I join you my code, I have simplify that I have done because it would be to complex.
You will see that when you execute the class Mytree.java you will have the result 0.396
And if you execute the same code in uncomment the two lines
//toto.Tree.writeFile("graph.xdsl");
//toto.Tree.readFile("graph.xdsl");
you will have the result 0.655
Thanks
You will see that when you execute the class Mytree.java you will have the result 0.396
And if you execute the same code in uncomment the two lines
//toto.Tree.writeFile("graph.xdsl");
//toto.Tree.readFile("graph.xdsl");
you will have the result 0.655
Thanks
- Attachments
-
- MyTree.txt
- main file
- (11.19 KiB) Downloaded 1068 times
-
- Path.txt
- Class 1
- (1.03 KiB) Downloaded 819 times
-
- Edge.txt
- Class 2
- (929 Bytes) Downloaded 1066 times
-
- Site Admin
- Posts: 1473
- Joined: Mon Nov 26, 2007 5:51 pm
-
- Site Admin
- Posts: 1473
- Joined: Mon Nov 26, 2007 5:51 pm
The bug is in your code. You should change the following fragment:
to this:
Without the change, the CPT in Tree_Status is inconsistent - the node is deterministic and it's first parent configuration (the column of the CPT) has two 1.0 values. Network.setNodeDefinition does not perform consistency checks and allows you to pass anameDef with invalid numbers.
Your program calculated correct values when you added writeFile/readFile, because .xdsl format stores only the 'resulting states' for deterministic nodes. For Tree_Status and first parent config it's Fully_connected. This ignores the second 1.0, because the writing code looks for first state with non-zero value. Subsequently, the reading code makes sure that there's only one 1.0 in each config.
Code: Select all
anameDef[0]=1;
anameDef[1]=1;
Code: Select all
anameDef[0]=1;
anameDef[1]=0;
Your program calculated correct values when you added writeFile/readFile, because .xdsl format stores only the 'resulting states' for deterministic nodes. For Tree_Status and first parent config it's Fully_connected. This ignores the second 1.0, because the writing code looks for first state with non-zero value. Subsequently, the reading code makes sure that there's only one 1.0 in each config.