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


C++ Predicate::getId方法代码示例

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


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

示例1: getConstantTuples

double Clause::getConstantTuples(const Domain* const & domain,
                                 const Database* const & db,
                                 Array<int>* const & mlnClauseTermIds,
                                 const Clause* const & varClause,
                                 PredicateTermToVariable * const & ptermToVar,
                            ClauseToSuperClauseMap* const & clauseToSuperClause,
                                 bool useImplicit)
{
  bool ignoreActivePreds = true;
  double numTrueGndings = 0;

    //initialize the constants tuple with the var Ids - we will fill them in
    //with constants as we go along
  Array<int> *constants = new Array<int>(*mlnClauseTermIds);

    //Copy the literals so that their original order in the clause is
    //not affected by the subsequent sorting
    
  cout<<"***************************************************************"<<endl;
  cout<<"Came to process the clause : "<<endl;
  print(cout, domain);
  cout<<endl;

  createVarIdToVarsGroundedType(domain);

  Array<Predicate*>* origClauseLits = new Array<Predicate*>(*predicates_);

    // Array of partially grounded clauses achieved by using the inverted
    // index
  Array<Array<Predicate*>* > partGroundedClauses;

    //Assign to each variable in clause, the corresponding variable class
    //(stores the list of indexed constants). It is accessed through the
    //predicates appearing in the clause
  PredicateTermToVariable::iterator itr;
  PredicateTerm *pterm;
  Predicate *pred;
  const Term *term;
  Array<Variable *> *eqVars = new Array<Variable *>();
  eqVars->growToSize(mlnClauseTermIds->size());
    
    //initialize with NULL
  for (int i = 0; i < eqVars->size(); i++)
    (*eqVars)[i] = NULL;

  if (useImplicit)
  {
    for (int predno = 0; predno < varClause->getNumPredicates(); predno++)
    {
      pred = varClause->getPredicate(predno);
      int predId = pred->getId();
      for (int termno = 0; termno < pred->getNumTerms(); termno++)
      {
        term = pred->getTerm(termno);
        assert(!term->isConstant());
        int termId = term->getId();
        pterm = new PredicateTerm(predId, termno);
        itr = ptermToVar->find(pterm);
        assert(itr != ptermToVar->end());
        assert(-termId < eqVars->size());
        (*eqVars)[-termId] = itr->second;
        delete pterm;
      }
    }
  }

  if (useInverseIndex)
  {
      // Put the indexable literals first and ground them
    sortLiteralsByNegationAndArity(*origClauseLits, ignoreActivePreds, db);
    groundIndexableLiterals(domain, db, *origClauseLits, partGroundedClauses,
                            ignoreActivePreds);
  }
  else
  {
      //Sort preds in decreasing order of #TrueGndOfLiteral/#numOfGroundings.
      //The larger the number of true groundings of a literal, the more likely
      //it is to be true, so put it in front so that we can decide whether the
      //clause is true early.The larger the number of groundings of the
      //literal, the larger the savings when we decide that preceding literals
      //are true.
    sortLiteralsByTrueDivTotalGroundings(*origClauseLits, domain, db);
      // Put the original clause as the only clause into partGroundedClauses
    Array<Predicate*>* clauseLitsCopy = new Array<Predicate*>;
    clauseLitsCopy->growToSize(origClauseLits->size());
    for (int i = 0; i < origClauseLits->size(); i++)
      (*clauseLitsCopy)[i] = new Predicate(*(*origClauseLits)[i]);
    partGroundedClauses.append(clauseLitsCopy);
  }

    // At this point partGroundedClauses holds the nodes of the branch and
    // bound algorithm. This means nothing more is indexed and we must ground
    // out the rest of the predicates
  if (clausedebug)
  {
    cout << "Partially grounded clauses to be completed: " << endl;
    for (int pgcIdx = 0; pgcIdx < partGroundedClauses.size(); pgcIdx++)
    {
      cout << "\t";
      for (int i = 0; i < partGroundedClauses[pgcIdx]->size(); i++)
//.........这里部分代码省略.........
开发者ID:Artemid,项目名称:alchemy-2,代码行数:101,代码来源:clause.cpp

示例2: addTmpRelation

// Only used in prematerialization
void EDBLayer::addTmpRelation(Predicate & pred, IndexedTupleTable * table) {
    tmpRelations[pred.getId()] = table;
}
开发者ID:jrbn,项目名称:vlog,代码行数:4,代码来源:edb.cpp


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