System.out.println(
"Utility Potential:\n" + pt.getUtilityPotential().toString()
+ "\n");
CPT policy = new CPT(dom, parentDomains);
policy.setAll(0);
PT weightedUtil = PT.multiplySimTables(pt.getUtilityPotential(),
pt.getProbabilityPotential());
if (probPotential.isSingleValue) {
int[] fiber = new int[] { -1 };
int[] maxReference = weightedUtil.getMaxReference(fiber);
double probScalar = pt.getProbabilityPotential().getValue(
maxReference);
probPotential.setScalarValue(probScalar);
utilPotential.setScalarValue(
weightedUtil.getValue(maxReference) / probScalar);
policy.setValue(maxReference, 1);
} else {
int[] productStructureIterator = utilPotential.index2addr(0);
boolean done = false;
while (!done) {
int[] fiber = mdmap.getFiber(productStructureIterator);
int[] maxReference = weightedUtil.getMaxReference(fiber);
double probVal = pt.getProbabilityPotential().getValue(
maxReference);
probPotential.setValue(productStructureIterator, probVal);
utilPotential.setValue(productStructureIterator,
weightedUtil.getValue(maxReference) / probVal);
policy.setValue(maxReference, 1);
done = utilPotential.addOne(productStructureIterator);
}
}
policyHash.put(dom, policy);
System.out.println(
dom.getName() + ":here it is\n" + policy.toString() + "\n");
utilPotential = PT.divideSimTables(utilPotential, probPotential);
return new JTPotential(probPotential, utilPotential);
}