Exemple #1
0
CFactorGraph CompressInterface::createCFactorGraph() {

	createVarClustering();
	createFacClustering();

	// create lifted fg here
	vector<CFactor> superFacs;

	// clusterIdx => facIdx
	for (map<size_t,size_t>::iterator facIter = _facRepr.begin(); facIter != _facRepr.end(); facIter++) {
		VarSet superVarSet;

		foreach (const dai::BipartiteGraph::Neighbor &tmpVar, _cfg.nbF(facIter->second)) {
			Var varCluster = _varRepr[_varColorVec[tmpVar]];
			if (!superVarSet.contains(varCluster)) {
				superVarSet |= Var(varCluster);
			}
		}

		CFactor superFac = CFactor(superVarSet, _cfg.factor(facIter->second).p());
		superFac.sigma() = _cfg.factor(facIter->second).sigma();
		superFac.position() = _cfg.factor(facIter->second).position();

		superFac.counts() = createCounts(facIter->second, superVarSet);
		superFacs.push_back(superFac);
	}

	return CFactorGraph(superFacs);
}
void cfactor_setCounts(CFactor &fac, vector<map<size_t, int> > & counts) {
	fac.counts() = counts;
}