Vector<DiscreteDomain> parentDomains = new Vector<DiscreteDomain>();
parentDomains.addAll(pt.getDomainProduct());
parentDomains.remove(dom);
FMarginalizationMap mdmap = new FMarginalizationMap(
pt.getDomainProduct(), parentDomains);
// Vector <DiscreteDomain> domProduct=pt.getDomainProduct();
// System.out.println();
// for (DiscreteDomain domain : domProduct) {
// System.out.print (dom.getName()+", ");
// }
// System.out.println();
Vector<DiscreteDomain> projectionDomainProduct = mdmap.getProjectionDomainProduct();
PT probPotential = new PT(projectionDomainProduct);
PT utilPotential = new PT(projectionDomainProduct);
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);