Yes that would be exactly the way to do it!
If you know the names of the set of utility nodes beforehand, you could structure your code like so:
//reference the utility nodes un1 and un2
UtilityNode un1 = (UtilityNode)domain.getNodeByName("un1");
UtilityNode un2 = (UtilityNode)domain.getNodeByName("un2");
...
...
//iterate all cases
for (int i = 0; i < numCases; ++i) {
//enter case #i, propagate, SPU etc.
...
//report utilities for un1 and un2
System.out.println("utility 1: " + un1.getExpectedUtility());
System.out.println("utility 2: " + un2.getExpectedUtility());
...
}
By the way, since you are working with a
LIMID.
If your network contains uninstantiated decisions after propagating a case then you might want to perform SPU (single policy update) before reading out beliefs and utilities.
SPU takes the entered evidence into account to compute new policies for uninstantiated decisions which may improve overall expected utility of the decision problem (and influence beliefs for the nodes that depends on uninstantiated decisions).
See chapter 9.3
"Inference in LIMIDs: Computing optimal policies" in the API reference manual for details about SPU.
http://download.hugin.com/webdocs/manuals/api-manual.pdfIn the Java API the SPU function is
Domain.updatePolicies()