write and read functions in jSMILE

The engine.
Post Reply
tamuzem
Posts: 4
Joined: Tue Jul 21, 2009 7:36 am

write and read functions in jSMILE

Post by tamuzem »

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,
shooltz[BayesFusion]
Site Admin
Posts: 1473
Joined: Mon Nov 26, 2007 5:51 pm

Re: write and read functions in jSMILE

Post by shooltz[BayesFusion] »

tamuzem wrote:Is there in the write and read methods, some other things that just writting and reading, or is it a bug?
If your observations is correct, it's definitely a bug. Can you post your Java code you're using to create the network?
tamuzem
Posts: 4
Joined: Tue Jul 21, 2009 7:36 am

Post by tamuzem »

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
Attachments
MyTree.txt
main file
(11.19 KiB) Downloaded 1069 times
Path.txt
Class 1
(1.03 KiB) Downloaded 819 times
Edge.txt
Class 2
(929 Bytes) Downloaded 1067 times
shooltz[BayesFusion]
Site Admin
Posts: 1473
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

tamuzem wrote:I join you my code, I have simplify that I have done because it would be to complex.
Bug confirmed. I'll notify you when new jSMILE binaries with this problem fixed are ready for download.
tamuzem
Posts: 4
Joined: Tue Jul 21, 2009 7:36 am

Post by tamuzem »

Ok, thank you
shooltz[BayesFusion]
Site Admin
Posts: 1473
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

The bug is in your code. You should change the following fragment:

Code: Select all

anameDef[0]=1;
anameDef[1]=1;
to this:

Code: Select all

anameDef[0]=1;
anameDef[1]=0;
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.
tamuzem
Posts: 4
Joined: Tue Jul 21, 2009 7:36 am

Post by tamuzem »

Thank you very much, it was a very stupid error...
Post Reply