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


C++ NodeManager类代码示例

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


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

示例1: Assert

Node RePairAssocCommutativeOperators::case_assoccomm(TNode n){
  Kind k = n.getKind();
  Assert(isAssociateCommutative(k));
  Assert(n.getMetaKind() != kind::metakind::PARAMETERIZED);
  unsigned N = n.getNumChildren();
  Assert(N >= 2);


  Node last = rePairAssocCommutativeOperators( n[N-1]);
  Node nextToLast = rePairAssocCommutativeOperators(n[N-2]);

  NodeManager* nm = NodeManager::currentNM();
  Node last2 = nm->mkNode(k, nextToLast, last);

  if(N <= 2){
    return last2;
  } else{
    Assert(N > 2);
    Node prevRound = last2;
    for(unsigned prevPos = N-2; prevPos > 0; --prevPos){
      unsigned currPos = prevPos-1;
      Node curr = rePairAssocCommutativeOperators(n[currPos]);
      Node round = nm->mkNode(k, curr, prevRound);
      prevRound = round;
    }
    return prevRound;
  }
}
开发者ID:Awesomeclaw,项目名称:CVC4,代码行数:28,代码来源:nary_builder.cpp

示例2: Assert

void PseudoBooleanProcessor::learnGeqSub(Node geq)
{
  Assert(geq.getKind() == kind::GEQ);
  const bool negated = false;
  bool success = decomposeAssertion(geq, negated);
  if (!success)
  {
    Debug("pbs::rewrites") << "failed " << std::endl;
    return;
  }
  Assert(d_off.value().isIntegral());
  Integer off = d_off.value().ceiling();

  // \sum pos >= \sum neg + off

  // for now special case everything we want
  // target easy clauses
  if (d_pos.size() == 1 && d_neg.size() == 1 && off.isZero())
  {
    // x >= y
    // |- (y >= 1) => (x >= 1)
    Node x = d_pos.front();
    Node y = d_neg.front();

    Node xGeq1 = mkGeqOne(x);
    Node yGeq1 = mkGeqOne(y);
    Node imp = yGeq1.impNode(xGeq1);
    addSub(geq, imp);
  }
  else if (d_pos.size() == 0 && d_neg.size() == 2 && off.isNegativeOne())
  {
    // 0 >= (x + y -1)
    // |- 1 >= x + y
    // |- (or (not (x >= 1)) (not (y >= 1)))
    Node x = d_neg[0];
    Node y = d_neg[1];

    Node xGeq1 = mkGeqOne(x);
    Node yGeq1 = mkGeqOne(y);
    Node cases = (xGeq1.notNode()).orNode(yGeq1.notNode());
    addSub(geq, cases);
  }
  else if (d_pos.size() == 2 && d_neg.size() == 1 && off.isZero())
  {
    // (x + y) >= z
    // |- (z >= 1) => (or (x >= 1) (y >=1 ))
    Node x = d_pos[0];
    Node y = d_pos[1];
    Node z = d_neg[0];

    Node xGeq1 = mkGeqOne(x);
    Node yGeq1 = mkGeqOne(y);
    Node zGeq1 = mkGeqOne(z);
    NodeManager* nm = NodeManager::currentNM();
    Node dis = nm->mkNode(kind::OR, zGeq1.notNode(), xGeq1, yGeq1);
    addSub(geq, dis);
  }
}
开发者ID:CVC4,项目名称:CVC4,代码行数:58,代码来源:pseudo_boolean_processor.cpp

示例3: getFunctionValue

Node UfModelTreeNode::getFunctionValue(std::vector<Node>& args, int index, Node argDefaultValue, bool simplify) {
  if(!d_data.empty()) {
    Node defaultValue = argDefaultValue;
    if(d_data.find(Node::null()) != d_data.end()) {
      defaultValue = d_data[Node::null()].getFunctionValue(args, index + 1, argDefaultValue, simplify);
    }

    vector<Node> caseArgs;
    map<Node, Node> caseValues;

    for(map< Node, UfModelTreeNode>::iterator it = d_data.begin(); it != d_data.end(); ++it) {
      if(!it->first.isNull()) {
        Node val = it->second.getFunctionValue(args, index + 1, defaultValue, simplify);
        caseArgs.push_back(it->first);
        caseValues[it->first] = val;
      }
    }

    NodeManager* nm = NodeManager::currentNM();
    Node retNode = defaultValue;

    if(!simplify) {
      // "non-simplifying" mode - expand function values to things like:
      //   IF      (x=0 AND y=0 AND z=0) THEN value1
      //   ELSE IF (x=0 AND y=0 AND z=1) THEN value2
      //   [...etc...]
      for(int i = (int)caseArgs.size() - 1; i >= 0; --i) {
        Node val = caseValues[ caseArgs[ i ] ];
        if(val.getKind() == ITE) {
          // use a stack to reverse the order, since we're traversing outside-in
          stack<TNode> stk;
          do {
            stk.push(val);
            val = val[2];
          } while(val.getKind() == ITE);
          AlwaysAssert(val == defaultValue, "default values don't match when constructing function definition!");
          while(!stk.empty()) {
            val = stk.top();
            stk.pop();
            retNode = nm->mkNode(ITE, nm->mkNode(AND, args[index].eqNode(caseArgs[i]), val[0]), val[1], retNode);
          }
        } else {
          retNode = nm->mkNode(ITE, args[index].eqNode(caseArgs[i]), caseValues[caseArgs[i]], retNode);
        }
      }
    } else {
      // "simplifying" mode - condense function values
      for(int i = (int)caseArgs.size() - 1; i >= 0; --i) {
        retNode = nm->mkNode(ITE, args[index].eqNode(caseArgs[i]), caseValues[caseArgs[i]], retNode);
      }
    }
    return retNode;
  } else {
    Assert(!d_value.isNull());
    return d_value;
  }
}
开发者ID:4tXJ7f,项目名称:CVC4,代码行数:57,代码来源:theory_uf_model.cpp

示例4: done_guard

void RaftStatImpl::default_method(::google::protobuf::RpcController* controller,
                              const ::braft::IndexRequest* /*request*/,
                              ::braft::IndexResponse* /*response*/,
                              ::google::protobuf::Closure* done) {
    brpc::ClosureGuard done_guard(done);
    brpc::Controller* cntl = (brpc::Controller*)controller;
    std::string group_id = cntl->http_request().unresolved_path();
    std::vector<scoped_refptr<NodeImpl> > nodes;
    NodeManager* nm = NodeManager::GetInstance();
    if (group_id.empty()) {
        nm->get_all_nodes(&nodes);
    } else {
        nm->get_nodes_by_group_id(group_id, &nodes);
    }
    const bool html = brpc::UseHTML(cntl->http_request());
    if (html) {
        cntl->http_response().set_content_type("text/html");
    } else {
        cntl->http_response().set_content_type("text/plain");
    }
    butil::IOBufBuilder os;
    if (html) {
        os << "<!DOCTYPE html><html><head>\n"
           << "<script language=\"javascript\" type=\"text/javascript\" src=\"/js/jquery_min\"></script>\n"
           << brpc::TabsHead() << "</head><body>";
        cntl->server()->PrintTabsBody(os, "raft");
    }
    if (nodes.empty()) {
        if (html) {
            os << "</body></html>";
        }
        os.move_to(cntl->response_attachment());
        return;
    }

    std::string prev_group_id;
    const char *newline = html ? "<br>" : "\r\n";
    for (size_t i = 0; i < nodes.size(); ++i) {
        const NodeId node_id = nodes[i]->node_id();
        group_id = node_id.group_id;
        if (group_id != prev_group_id) {
            if (html) {
                os << "<h1>" << group_id << "</h1>";
            } else {
                os << "[" << group_id << "]" << newline;
            }
            prev_group_id = group_id;
        }
        nodes[i]->describe(os, html);
        os << newline;
    }
    if (html) {
        os << "</body></html>";
    }
    os.move_to(cntl->response_attachment());
}
开发者ID:ctero-graham,项目名称:braft,代码行数:56,代码来源:builtin_service_impl.cpp

示例5: preRewrite

// static
RewriteResponse TheorySetsRewriter::preRewrite(TNode node) {
  NodeManager* nm = NodeManager::currentNM();

  // do nothing
  if(node.getKind() == kind::EQUAL && node[0] == node[1])
    return RewriteResponse(REWRITE_DONE, nm->mkConst(true));
  // Further optimization, if constants but differing ones

  return RewriteResponse(REWRITE_DONE, node);
}
开发者ID:Awesomeclaw,项目名称:CVC4,代码行数:11,代码来源:theory_sets_rewriter.cpp

示例6: build

RESULT Builder::build(const char* context, const char* ops, const char* braces, const char* blanks )
{
    if( table_ops.load(ops) && table_braces.load(braces) && table_blanks.load(blanks) ) {
        NodeManager* mgr = NodeManager::getSingleton();
        if( mgr->getHeader() ) {
            return read( mgr->getHeader() );
        }
    }
    return E_BUILD_CONFIG;
}
开发者ID:jiexx,项目名称:core,代码行数:10,代码来源:Builder.cpp

示例7: Assert

Node InequalityGraph::makeDiseqSplitLemma(TNode diseq)
{
  Assert(diseq.getKind() == kind::NOT && diseq[0].getKind() == kind::EQUAL);
  NodeManager* nm = NodeManager::currentNM();
  TNode a = diseq[0][0];
  TNode b = diseq[0][1];
  Node a_lt_b = nm->mkNode(kind::BITVECTOR_ULT, a, b);
  Node b_lt_a = nm->mkNode(kind::BITVECTOR_ULT, b, a);
  Node eq = diseq[0];
  Node lemma = nm->mkNode(kind::OR, a_lt_b, b_lt_a, eq);
  return lemma;
}
开发者ID:CVC4,项目名称:CVC4,代码行数:12,代码来源:bv_inequality_graph.cpp

示例8: Trace

bool DtInstantiator::processEqualTerms(CegInstantiator* ci,
                                       SolvedForm& sf,
                                       Node pv,
                                       std::vector<Node>& eqc,
                                       CegInstEffort effort)
{
  Trace("cegqi-dt-debug") << "try based on constructors in equivalence class."
                          << std::endl;
  // look in equivalence class for a constructor
  NodeManager* nm = NodeManager::currentNM();
  for (unsigned k = 0, size = eqc.size(); k < size; k++)
  {
    Node n = eqc[k];
    if (n.getKind() == APPLY_CONSTRUCTOR)
    {
      Trace("cegqi-dt-debug")
          << "...try based on constructor term " << n << std::endl;
      std::vector<Node> children;
      children.push_back(n.getOperator());
      const Datatype& dt =
          static_cast<DatatypeType>(d_type.toType()).getDatatype();
      unsigned cindex = Datatype::indexOf(n.getOperator().toExpr());
      // now must solve for selectors applied to pv
      for (unsigned j = 0, nargs = dt[cindex].getNumArgs(); j < nargs; j++)
      {
        Node c = nm->mkNode(
            APPLY_SELECTOR_TOTAL,
            Node::fromExpr(dt[cindex].getSelectorInternal(d_type.toType(), j)),
            pv);
        ci->pushStackVariable(c);
        children.push_back(c);
      }
      Node val = nm->mkNode(kind::APPLY_CONSTRUCTOR, children);
      TermProperties pv_prop_dt;
      if (ci->constructInstantiationInc(pv, val, pv_prop_dt, sf))
      {
        return true;
      }
      // cleanup
      for (unsigned j = 0, nargs = dt[cindex].getNumArgs(); j < nargs; j++)
      {
        ci->popStackVariable();
      }
      break;
    }
  }
  return false;
}
开发者ID:CVC4,项目名称:CVC4,代码行数:48,代码来源:ceg_dt_instantiator.cpp

示例9: remEntryPoints

	ProgramPtr Program::remEntryPoints(NodeManager& manager, const ProgramPtr& program, const ExpressionList& entryPoints) {
		ExpressionList list;
		for_each(program->getEntryPoints(), [&list, &entryPoints](const ExpressionPtr& cur) {
			if(!contains(entryPoints, cur, equal_target<ExpressionPtr>())) { list.push_back(cur); }
		});
		return manager.get(Program(list));
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:7,代码来源:ir_program.cpp

示例10: getAllValuesInModel

void InequalityGraph::getAllValuesInModel(std::vector<Node>& assignments)
{
  NodeManager* nm = NodeManager::currentNM();
  for (ModelValues::const_iterator it = d_modelValues.begin();
       it != d_modelValues.end();
       ++it)
  {
    TermId id = (*it).first;
    BitVector value = (*it).second.value;
    TNode var = getTermNode(id);
    Node constant = utils::mkConst(value);
    Node assignment = nm->mkNode(kind::EQUAL, var, constant);
    assignments.push_back(assignment);
    Debug("bitvector-model") << "   " << var << " => " << constant << "\n";
  }
}
开发者ID:CVC4,项目名称:CVC4,代码行数:16,代码来源:bv_inequality_graph.cpp

示例11: zeroArity

Node NaryBuilder::zeroArity(Kind k){
  using namespace kind;
  NodeManager* nm = NodeManager::currentNM();
  switch(k){
  case AND:
    return nm->mkConst(true);
  case OR:
    return nm->mkConst(false);
  case PLUS:
    return nm->mkConst(Rational(0));
  case MULT:
    return nm->mkConst(Rational(1));
  default:
    return Node::null();
  }
}
开发者ID:Awesomeclaw,项目名称:CVC4,代码行数:16,代码来源:nary_builder.cpp

示例12: getValue

Node InferBoundsResult::getLiteral() const{
  const Rational& q = getValue().getNoninfinitesimalPart();
  NodeManager* nm = NodeManager::currentNM();
  Node qnode = nm->mkConst(q);

  Kind k;
  if(d_upperBound){
    // x <= q + c*delta
    Assert(getValue().infinitesimalSgn() <= 0);
    k = boundIsRational() ? kind::LEQ : kind::LT;
  }else{
    // x >= q + c*delta
    Assert(getValue().infinitesimalSgn() >= 0);
    k = boundIsRational() ? kind::GEQ : kind::GT;
  }
  Node atom = nm->mkNode(k, getTerm(), qnode);
  Node lit = Rewriter::rewrite(atom);
  return lit;
}
开发者ID:g2graman,项目名称:CVC4,代码行数:19,代码来源:infer_bounds.cpp

示例13: Assert

Node AbstractionModule::getSignatureSkolem(TNode node) {
  Assert (node.getKind() == kind::VARIABLE);
  unsigned bitwidth = utils::getSize(node);
  if (d_signatureSkolems.find(bitwidth) == d_signatureSkolems.end()) {
    d_signatureSkolems[bitwidth] = vector<Node>(); 
  }
  
  vector<Node>& skolems = d_signatureSkolems[bitwidth];
  // get the index of bv variables of this size
  unsigned index = getBitwidthIndex(bitwidth); 
  Assert (skolems.size() + 1 >= index );
  if (skolems.size() == index) {
    ostringstream os;
    os << "sig_" <<bitwidth <<"_" << index;
    NodeManager* nm = NodeManager::currentNM(); 
    skolems.push_back(nm->mkSkolem(os.str(), nm->mkBitVectorType(bitwidth), "skolem for computing signatures"));
  }
  ++(d_signatureIndices[bitwidth]);
  return skolems[index];
}
开发者ID:jinala,项目名称:CVC4,代码行数:20,代码来源:abstraction.cpp

示例14: parse

void Builder::parse( const char* content )
{
    NodeManager* mgr = NodeManager::getSingleton();
    const char* last = content;
    int width;
    while( *content ) {
        if( (width = isBlank(content)) > 0 ) {
            content += width;
        } else if( (width = isOp( content )) > 0 ) {
            mgr->createOperator(content, width);
            mgr->createOperand(content, content-last);
            last = content;
            content += width;
        } else if( (width = isBrace( content )) > 0 ) {
            mgr->createBrace(content, width);
            last = content;
            content += width;
        }
        content ++;
    }
}
开发者ID:jiexx,项目名称:core,代码行数:21,代码来源:Builder.cpp

示例15: unserialize

void Builder::unserialize(const char* file)
{
    NodeManager* mgr = NodeManager::getSingleton();
    vector<Node*> nodes;
    const char* last = file;
    int width;
    while( file ) {
        if( (width = Config::hasDelimiter( file )) > 0 ) {
            nodes.push_back( mgr->unserialize( file, file - last ) );
            last = file;
            file += width;
        }
        file ++;
    }
    Node* node;
    for( int i = 0 ; i < nodes.size() ; i ++ ) {
        node = nodes.at(i);
        if( node ) {
            node->addLeft( nodes.at(2*i) );
            node->addRight( nodes.at(2*i+1) );
        }
    }
    root = nodes.at(0);
}
开发者ID:jiexx,项目名称:core,代码行数:24,代码来源:Builder.cpp


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