/** Adds FACTOR to this graph, but while maintaining the invariant that every set of variables has * at most one factor over exactly that domain. If the given FACTOR has a domain that is already * used by some other factor PREV, then PREV is replaced with a FactorGraph containing PREV and FACTOR. * @param clique * @param factor The factor to add */ private void addFactorInternal (UnrolledVarSet clique, Factor factor) { clique.setFactor (factor); Factor prevFactor = factorOf (factor.varSet ()); if (prevFactor == null) { addFactor (factor); } else if (prevFactor instanceof FactorGraph) { prevFactor.multiplyBy (factor); } else { divideBy (prevFactor); addFactor (new FactorGraph (new Factor[] { factor, prevFactor })); } }
/** Adds FACTOR to this graph, but while maintaining the invariant that every set of variables has * at most one factor over exactly that domain. If the given FACTOR has a domain that is already * used by some other factor PREV, then PREV is replaced with a FactorGraph containing PREV and FACTOR. * @param clique * @param factor The factor to add */ private void addFactorInternal (UnrolledVarSet clique, Factor factor) { clique.setFactor (factor); Factor prevFactor = factorOf (factor.varSet ()); if (prevFactor == null) { addFactor (factor); } else if (prevFactor instanceof FactorGraph) { prevFactor.multiplyBy (factor); } else { divideBy (prevFactor); addFactor (new FactorGraph (new Factor[] { factor, prevFactor })); } }
/** Adds FACTOR to this graph, but while maintaining the invariant that every set of variables has * at most one factor over exactly that domain. If the given FACTOR has a domain that is already * used by some other factor PREV, then PREV is replaced with a FactorGraph containing PREV and FACTOR. * @param clique * @param factor The factor to add */ private void addFactorInternal (UnrolledVarSet clique, Factor factor) { clique.setFactor (factor); Factor prevFactor = factorOf (factor.varSet ()); if (prevFactor == null) { addFactor (factor); } else if (prevFactor instanceof FactorGraph) { prevFactor.multiplyBy (factor); } else { divideBy (prevFactor); addFactor (new FactorGraph (new Factor[] { factor, prevFactor })); } }