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


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

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


在下文中一共展示了CNode::contains_term方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eliminate_var_rec

CNode* VariableEliminator::eliminate_var_rec(CNode* node,
		VariableTerm* evar, CNode* active_constraint)
{


	CNode* and_c = Connective::make(AND, node, active_constraint);

	/*CNode* canonical = and_c->make_canonical();
	Solver s(canonical, UNSAT_SIMPLIFY);
	CNode* res_c = s.get_result();
	if(res_c->get_type() == FALSE_NODE) return False::make(); */

	if(DEBUG) {
		cout << "CUR CONSTRAINT: " << node->to_string() << endl;
		cout << "Active constraint: " << active_constraint->to_string() << endl;
	}

	if(!and_c->contains_term(evar)){
		if(DEBUG) {
			cout << "Does not contain var to eliminate " << endl;
			cout << "Result: " << and_c->to_string() << endl;
		}
		return and_c;
	}


	/*
	 * If we can find an equality like t=T', then substitute
	 * every occurence of t in the subtree with T'.
	 */


	Term* sub = and_c->contains_term_equality(evar);
	if(sub != NULL) {
		if(DEBUG){
			cout << "Simple substitution found! " << evar->to_string()
			<< "-> " << sub->to_string() << " in constraint: " <<
			and_c->to_string() << endl;
		}
		map<Term*, Term*> sub_map;
		sub_map[evar] = sub;
		CNode* res = and_c->substitute(sub_map);
		if(DEBUG) {
			cout << "Result: " << res->to_string() << endl;
		}
		return res;

	}


	if(and_c->is_conjunct())
	{
		simplify = true;
		CNode* res = eliminate_var_conjunct(and_c, evar);
		CNode* simp_res = res;
		if(DEBUG) {
			cout << "Base case (conjunct)  " << endl;
			//cout << "Result: " << res->to_string() << endl;
		}
		return simp_res;
	}

	if(node->is_conjunct())
	{
		CNode* res = eliminate_var_rec(and_c, evar, True::make());
		if(DEBUG) {
			cout << "Pseudo base-case: " << endl;
			cout << "Result: " << res->to_string() << endl;
		}
		return res;
	}

	assert(node->is_connective());
	Connective* parent = (Connective*) node;

	bool changed = false;
	set<CNode*> new_children;
	set<CNode*>::const_iterator it = parent->get_operands().begin();

	if(parent->get_type() == OR)
	{
		bool and_active_constraint = false;
		it = parent->get_operands().begin();
		for(; it!= parent->get_operands().end() ;it++)
		{
			CNode* child = *it;
			if(!child->contains_term(evar)) {
				and_active_constraint = true;
				new_children.insert(child);
				continue;
			}
			CNode* new_child = eliminate_var_rec(child, evar,
					active_constraint);
			if(new_child->get_type() == TRUE_NODE) {
				return True::make();
			}
			if(new_child != child) {
				changed = true;
			}
			new_children.insert(new_child);
//.........这里部分代码省略.........
开发者ID:xwangsd,项目名称:mistral,代码行数:101,代码来源:VariableEliminator.cpp


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