本文整理汇总了C++中CNode::fold_negated_ilps方法的典型用法代码示例。如果您正苦于以下问题:C++ CNode::fold_negated_ilps方法的具体用法?C++ CNode::fold_negated_ilps怎么用?C++ CNode::fold_negated_ilps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNode
的用法示例。
在下文中一共展示了CNode::fold_negated_ilps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand_neq_constraints
CNode* VariableEliminator::expand_neq_constraints(Clause& cl, set<Leaf*>& neqs)
{
set<Leaf*>::iterator it = neqs.begin();
for(; it!= neqs.end(); it++)
{
Leaf* l = *it;
if(l->get_type() == ILP)
cl.neg_ilp.erase((ILPLeaf*)l);
else
cl.neg_eq.erase((EqLeaf*)l);
}
CNode* node = cl.to_cnode();
set<CNode*> to_and;
to_and.insert(node);
for(it=neqs.begin(); it!=neqs.end(); it++)
{
Leaf* l = *it;
CNode* lt = NULL;
CNode* gt = NULL;
if(l->get_type() == ILP) {
ILPLeaf* ilp = (ILPLeaf*) l;
lt = ILPLeaf::make(ILP_LT, ilp->get_elems(), ilp->get_constant());
lt = lt->fold_negated_ilps();
gt = ILPLeaf::make(ILP_GT, ilp->get_elems(), ilp->get_constant());
gt = gt->fold_negated_ilps();
}
else {
EqLeaf* eq = (EqLeaf*) l;
map<Term*, long int> elems;
elems[eq->get_lhs()] = 1;
elems[eq->get_rhs()] = -1;
lt = ILPLeaf::make(ILP_LT, elems, 0);
lt = lt->fold_negated_ilps();
gt = ILPLeaf::make(ILP_GT, elems, 0);
gt = gt->fold_negated_ilps();
}
CNode* disjunct = Connective::make(OR, lt, gt);
to_and.insert(disjunct);
}
return Connective::make_and(to_and);
}
示例2: expand_neq_constraints_with_bound
bool VariableEliminator::expand_neq_constraints_with_bound(Clause& cl,
set<Leaf*>& neqs, set<ILPLeaf*>& result, Term* evar, bool lt)
{
set<Leaf*>::iterator it = neqs.begin();
for(; it!= neqs.end(); it++)
{
Leaf* l = *it;
if(l->get_type() == ILP){
cl.neg_ilp.erase((ILPLeaf*)l);
long int coef = ((ILPLeaf*)l)->get_coefficient(evar);
if(coef < 0){
CNode* n =((ILPLeaf*)l)->multiply(-1);
n = n->fold_negated_ilps();
assert(n->is_leaf());
l = (Leaf*) n;
}
}
else cl.neg_eq.erase((EqLeaf*)l);
ILPLeaf* to_insert = NULL;
if(lt) {
CNode* _ilp_lt = NULL;
if(l->get_type() == ILP) {
ILPLeaf* ilp = (ILPLeaf*) l;
_ilp_lt = ILPLeaf::make(ILP_LT, ilp->get_elems(),
ilp->get_constant());
_ilp_lt = _ilp_lt->fold_negated_ilps();
}
else {
EqLeaf* eq = (EqLeaf*) l;
map<Term*, long int> elems;
elems[eq->get_lhs()] = 1;
elems[eq->get_rhs()] = -1;
_ilp_lt = ILPLeaf::make(ILP_LT, elems, 0);
_ilp_lt = _ilp_lt->fold_negated_ilps();
}
cnode_type ct = _ilp_lt->get_type();
if(ct == FALSE_NODE) return false;
if(ct == TRUE_NODE) continue;
assert(ct == ILP);
to_insert = (ILPLeaf*) _ilp_lt;
}
else {
CNode* _ilp_gt = NULL;
if(l->get_type() == ILP) {
ILPLeaf* ilp = (ILPLeaf*) l;
_ilp_gt = ILPLeaf::make(ILP_GT, ilp->get_elems(),
ilp->get_constant());
_ilp_gt = _ilp_gt->fold_negated_ilps();
}
else {
EqLeaf* eq = (EqLeaf*) l;
map<Term*, long int> elems;
elems[eq->get_lhs()] = 1;
elems[eq->get_rhs()] = -1;
_ilp_gt = ILPLeaf::make(ILP_GT, elems, 0);
_ilp_gt = _ilp_gt->fold_negated_ilps();
}
cnode_type ct = _ilp_gt->get_type();
if(ct == FALSE_NODE) return false;
if(ct == TRUE_NODE) continue;
assert(ct == ILP);
to_insert = (ILPLeaf*) _ilp_gt;
}
cl.pos_ilp.insert(to_insert);
result.insert(to_insert);
}
return true;
}