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


C++ XorClause::getGroup方法代码示例

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


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

示例1: handleUpdatedClause

/**
@brief Helper function for replace_set()
*/
const bool VarReplacer::handleUpdatedClause(XorClause& c, const Var origVar1, const Var origVar2)
{
    uint32_t origSize = c.size();
    std::sort(c.getData(), c.getDataEnd());
    Lit p;
    uint32_t i, j;
    for (i = j = 0, p = lit_Undef; i != c.size(); i++) {
        if (c[i].var() == p.var()) {
            //added, but easily removed
            j--;
            p = lit_Undef;
            if (!solver.assigns[c[i].var()].isUndef())
                c.invert(solver.assigns[c[i].var()].getBool());
        } else if (solver.assigns[c[i].var()].isUndef()) //just add
            c[j++] = p = c[i];
        else c.invert(solver.assigns[c[i].var()].getBool()); //modify xorEqualFalse instead of adding
    }
    c.shrink(i - j);
    c.setStrenghtened();

    #ifdef VERBOSE_DEBUG
    cout << "xor-clause after replacing: ";
    c.plainPrint();
    #endif

    switch (c.size()) {
    case 0:
        solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
        if (!c.xorEqualFalse())
            solver.ok = false;
        return true;
    case 1:
        solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
        solver.uncheckedEnqueue(Lit(c[0].var(), c.xorEqualFalse()));
        solver.ok = (solver.propagate().isNULL());
        return true;
    case 2: {
        solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
        c[0] = c[0].unsign();
        c[1] = c[1].unsign();
        addBinaryXorClause(c, c.xorEqualFalse(), c.getGroup(), true);
        return true;
    }
    default:
        solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
        solver.attachClause(c);
        return false;
    }

    assert(false);
    return false;
}
开发者ID:yp,项目名称:ZRHCstar,代码行数:55,代码来源:VarReplacer.cpp

示例2: cleanClause

inline bool ClauseCleaner::cleanClause(XorClause& c)
{
  Lit* i, *j, *end;
  Var origVar1 = c[0].var();
  Var origVar2 = c[1].var();
  uint32_t origSize = c.size();
  for (i = j = c.getData(), end = i + c.size(); i != end; i++)
  {
    const lbool& val = solver.assigns[i->var()];
    if (val.isUndef())
    {
      *j = *i;
      j++;
    }
    else
      c.invert(val.getBool());
  }
  c.shrink(i - j);

  assert(c.size() != 1);
  switch (c.size())
  {
    case 0:
    {
      solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
      return true;
    }
    case 2:
    {
      c[0] = c[0].unsign();
      c[1] = c[1].unsign();
      solver.varReplacer->replace(c, c.xor_clause_inverted(), c.getGroup());
      solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
      return true;
    }
    default:
    {
      if (i - j > 0)
      {
        c.setStrenghtened();
        solver.clauses_literals -= i - j;
      }
      return false;
    }
  }

  assert(false);
  return false;
}
开发者ID:jamesbornholt,项目名称:stp,代码行数:49,代码来源:ClauseCleaner.cpp

示例3: assert

void XorFinder::addXorAsNormal3(XorClause& c)
{
    assert(c.size() == 3);
    Clause *tmp;
    vec<Var> vars;
    vec<Lit> vars2(c.size());
    const bool inverted = c.xor_clause_inverted();

    for (uint32_t i = 0; i < c.size(); i++) {
        vars.push(c[i].var());
    }

    vars2[0] = Lit(vars[0], false ^ inverted);
    vars2[1] = Lit(vars[1], false ^ inverted);
    vars2[2] = Lit(vars[2], false ^ inverted);
    tmp = solver.addClauseInt(vars2, c.getGroup());
    if (tmp) solver.clauses.push(tmp);

    vars2[0] = Lit(vars[0], true ^ inverted);
    vars2[1] = Lit(vars[1], true ^ inverted);
    vars2[2] = Lit(vars[2], false ^ inverted);
    tmp = solver.addClauseInt(vars2, c.getGroup());
    if (tmp) solver.clauses.push(tmp);

    vars2[0] = Lit(vars[0], true ^ inverted);
    vars2[1] = Lit(vars[1], false ^ inverted);
    vars2[2] = Lit(vars[2], true ^ inverted);
    tmp = solver.addClauseInt(vars2, c.getGroup());
    if (tmp) solver.clauses.push(tmp);

    vars2[0] = Lit(vars[0], false ^ inverted);
    vars2[1] = Lit(vars[1], true ^ inverted);
    vars2[2] = Lit(vars[2], true ^ inverted);
    tmp = solver.addClauseInt(vars2, c.getGroup());
    if (tmp) solver.clauses.push(tmp);
}
开发者ID:AmesianX,项目名称:stp,代码行数:36,代码来源:XorFinder.cpp

示例4: findSubsumed

// Will put NULL in 'cs' if clause removed.
void XorSubsumer::subsume0(XorClauseSimp ps)
{
#ifdef VERBOSE_DEBUGSUBSUME0
    cout << "subsume0 orig clause:";
    ps.clause->plainPrint();
#endif

    vec<Lit> unmatchedPart;
    vec<XorClauseSimp> subs;

    findSubsumed(*ps.clause, subs);
    for (uint32_t i = 0; i < subs.size(); i++) {
        XorClause* tmp = subs[i].clause;
        findUnMatched(*ps.clause, *tmp, unmatchedPart);
        if (unmatchedPart.size() == 0) {
#ifdef VERBOSE_DEBUGSUBSUME0
            cout << "subsume0 removing:";
            subs[i].clause->plainPrint();
#endif
            clauses_subsumed++;
            assert(tmp->size() == ps.clause->size());
            if (ps.clause->xorEqualFalse() == tmp->xorEqualFalse()) {
                unlinkClause(subs[i]);
            } else {
                solver.ok = false;
                return;
            }
        } else {
            assert(unmatchedPart.size() > 0);
            clauses_cut++;
#ifdef VERBOSE_DEBUG
            std::cout << "Cutting xor-clause:";
            subs[i].clause->plainPrint();
#endif //VERBOSE_DEBUG
            XorClause *c = solver.addXorClauseInt(unmatchedPart, tmp->xorEqualFalse() ^ !ps.clause->xorEqualFalse(), tmp->getGroup());
            if (c != NULL)
                linkInClause(*c);
            unlinkClause(subs[i]);
            if (!solver.ok) return;
        }
        unmatchedPart.clear();
    }
}
开发者ID:yp,项目名称:reHCstar,代码行数:44,代码来源:XorSubsumer.cpp


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