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


C++ CNode::fold_negated_ilps方法代码示例

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


}
开发者ID:xwangsd,项目名称:mistral,代码行数:44,代码来源:VariableEliminator.cpp

示例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;
}
开发者ID:xwangsd,项目名称:mistral,代码行数:75,代码来源:VariableEliminator.cpp


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