当前位置: 首页>>代码示例>>C++>>正文


C++ CFactor::sigma方法代码示例

本文整理汇总了C++中CFactor::sigma方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactor::sigma方法的具体用法?C++ CFactor::sigma怎么用?C++ CFactor::sigma使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFactor的用法示例。


在下文中一共展示了CFactor::sigma方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rearrangeCnfFactor

void CompressInterface::rearrangeCnfFactor(CFactor &cnfClause) {
	State state(cnfClause.vars());
	vector<size_t> (cnfClause.vars().size());
	vector<size_t> pos,neg,sigma;
	for (size_t i=0; i<cnfClause.states(); i++) {
		if (cnfClause[i] == 1) {
			for (vector<Var>::const_iterator varIter=cnfClause.vars().begin(); varIter!=cnfClause.vars().end();varIter++) {
				if (state(*varIter) == 0) {
					pos.push_back(varIter - cnfClause.vars().begin());
				} else {
					neg.push_back(varIter - cnfClause.vars().begin());
				}
			}
			break;
		} else if (cnfClause[i] == 0) {
			//TODO handle factors which contain zero states
			// in such cases the possible zero state could have been clamped;
			// possible solutions:
			// i) restore factor from backup (requires to clamp factors accordingly)
			// ii) cache zero states in advance
			return;
		}
		state++;
	}
	sigma.insert(sigma.begin(),pos.begin(), pos.end());
	sigma.insert(sigma.begin() + pos.size(),neg.begin(), neg.end());
	cnfClause.sigma() = sigma;
}
开发者ID:fhadiji,项目名称:liftandrelax,代码行数:28,代码来源:Compress.cpp

示例2: createCFactorGraph

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);
}
开发者ID:fhadiji,项目名称:liftandrelax,代码行数:29,代码来源:Compress.cpp


注:本文中的CFactor::sigma方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。