本文整理汇总了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;
}
示例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();
}
}
示例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;
}
}