jSmile and updating network

The engine.
Post Reply
orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

jSmile and updating network

Post by orzech »

Hello,

Lately I've been investigation SMILE quite thoroughly and I'd be thankful if you could help me with this one.
Please take a look at the code below:

Code: Select all

(...) set evidence

net.updateBeliefs();

int faultIndex = diagNet.findMostLikelyFault();
diagNet.setPursuedFault(faultIndex);

DiagResults diagResult = diagNet.update();
In this code the network gets updated twice - the first time on net.updateBeliefs() and then during diagNet.update() (internally invokes updateFaultBeliefs). Obviously there is no need to re-update the network durign diagNet.update() since no new observations occurred. And here is my question - did you use some kind of optimization which prevents updating a network multiple times (i.e. the network keeps track of nodes which have to be recalculated)?

Thanks in advance,
Peter
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: jSmile and updating network

Post by shooltz[BayesFusion] »

Obviously there is no need to re-update the network durign diagNet.update() since no new observations occurred.


With single fault marked as pursued, diagNet.update() actually calls the bayesian inference once for each state of all uninstantiated ranked observations. The number of inference calls is even greater when multiple faults are pursued.
did you use some kind of optimization which prevents updating a network multiple times (i.e. the network keeps track of nodes which have to be recalculated)?
No, there's no special code for this. I don't think you'd get any significant performance boost with such feature implemented. If you worry about the cost of updateBeliefs() call before findMostLikelyFault, set the fault nodes as targets with Network.setTarget.

Also, Smile.DiagNetwork sets the most likely fault in its constructor.
orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

Re: jSmile and updating network

Post by orzech »

Thank you for your response.

I was curious how things work in jSmile so I took some time to play around with SMILE using C++ and Java. As a result I've got an important question to ask - don't you think there should be independent methods UpdateFaultBeliefs and ComputeTestStrengths in DiagNetwork? Now since these two methods are wrapped in a single DiagNetwork.update() there is no way to independently update fault beliefs, look up vector of faults, set pursued fault and the invoke computeTestStrengths. The only thing you can do using jSmile is:

diagNet.update(); // (A)
diagNet.setPursuedFault(diagNet.findMostLikelyFaultIndex());
DiagResult results = diagNet.update(); // (B)

Thus, in (A) ComputeStrengths is redundant and in (B) UpdateFaultBeliefs is redundant. Especially the first one is very expensive.
Maybe I am doing something completely wrong but I don't think so since I am getting the same results as GeNIe. Also it's not a big issue because I've already recompiled jSmile to adapt my changes but I am just not sure why did you decided to change the C++ API?

Best regards
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: jSmile and updating network

Post by shooltz[BayesFusion] »

The C++ API was mostly designed for high profile client before I joined the DSL, so I can't give you much insight on the 'why' side. There were some minor changes later, related to new diagnostic features.

There's no Java wrapper for DIAG_network::UpdateFaultBeliefs because nobody asked for it yet, but I think you can go around this limitation by reading the fault beliefs returned from DiagNetwork.update - fault info entries are already sorted by descreasing posteriors. Since DiagNetwork constructor sets the most likely fault as pursued, your code would look like this:

1) set the initial evidence in your Network instance
2) create a DiagNetwork object - this automatically sets most likely fault as pursued
3) instantiate observation(s)
4) call DiagNetwork.update, retrieve the most likely fault from the DiagResults, set is as pursued and optionally go to 3 above
orzech
Posts: 51
Joined: Wed Aug 04, 2010 11:40 pm

Re: jSmile and updating network

Post by orzech »

Thanks for your help. Well I just wanted to point out some possible improvements in case of preparing new releases of jSmile, SMILE.NET. Like I said I've solved my problems by modifying the wrappers so maybe I can voluntarily help you a bit in the future. :)

Cheers
Post Reply