本文整理汇总了C++中Monomial::getConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ Monomial::getConstant方法的具体用法?C++ Monomial::getConstant怎么用?C++ Monomial::getConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monomial
的用法示例。
在下文中一共展示了Monomial::getConstant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decomposeAssertion
bool PseudoBooleanProcessor::decomposeAssertion(Node assertion, bool negated)
{
if (assertion.getKind() != kind::GEQ)
{
return false;
}
Assert(assertion.getKind() == kind::GEQ);
Debug("pbs::rewrites") << "decomposeAssertion" << assertion << std::endl;
Node l = assertion[0];
Node r = assertion[1];
if (r.getKind() != kind::CONST_RATIONAL)
{
Debug("pbs::rewrites") << "not rhs constant" << assertion << std::endl;
return false;
}
// don't bother matching on anything other than + on the left hand side
if (l.getKind() != kind::PLUS)
{
Debug("pbs::rewrites") << "not plus" << assertion << std::endl;
return false;
}
if (!Polynomial::isMember(l))
{
Debug("pbs::rewrites") << "not polynomial" << assertion << std::endl;
return false;
}
Polynomial p = Polynomial::parsePolynomial(l);
clear();
if (negated)
{
// (not (>= p r))
// (< p r)
// (> (-p) (-r))
// (>= (-p) (-r +1))
d_off = (-r.getConst<Rational>());
if (d_off.value().isIntegral())
{
d_off = d_off.value() + Rational(1);
}
else
{
d_off = Rational(d_off.value().ceiling());
}
}
else
{
// (>= p r)
d_off = r.getConst<Rational>();
d_off = Rational(d_off.value().ceiling());
}
Assert(d_off.value().isIntegral());
int adj = negated ? -1 : 1;
for (Polynomial::iterator i = p.begin(), end = p.end(); i != end; ++i)
{
Monomial m = *i;
const Rational& coeff = m.getConstant().getValue();
if (!(coeff.isOne() || coeff.isNegativeOne()))
{
return false;
}
Assert(coeff.sgn() != 0);
const VarList& vl = m.getVarList();
Node v = vl.getNode();
if (!isPseudoBoolean(v))
{
return false;
}
int sgn = adj * coeff.sgn();
if (sgn > 0)
{
d_pos.push_back(v);
}
else
{
d_neg.push_back(v);
}
}
// all of the variables are pseudoboolean
// with coefficients +/- and the offsetoff
return true;
}