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


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

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


在下文中一共展示了CFactor::states方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: cfactor_setitem

void cfactor_setitem(CFactor& factor, size_t index, double value)
{
	if (index >= 0 && index < factor.states()) {
		factor[index] = value;
	}
	else {
		PyErr_SetString(PyExc_IndexError, "index out of range");
		boost::python::throw_error_already_set();
	}
}
开发者ID:fhadiji,项目名称:liftedgibbs,代码行数:10,代码来源:wrapperSTREAM.cpp

示例3: cfactor_getitem

double cfactor_getitem(CFactor &factor, size_t index)
{
	if (index >= 0 && index < factor.states()) {
		return factor[index];
	}
	else {
		PyErr_SetString(PyExc_IndexError, "index out of range");
		boost::python::throw_error_already_set();
		return -1;
	}
}
开发者ID:fhadiji,项目名称:liftedgibbs,代码行数:11,代码来源:wrapperSTREAM.cpp


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