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


C++ Partition::begin方法代码示例

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


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

示例1: TransformPartitionIntoOrderedListStrategies

void Party::TransformPartitionIntoOrderedListStrategies(DifferentSizePartitions *different_size_partitions) {
    for (DifferentSizePartitions::iterator my_iterator = different_size_partitions->begin();
         my_iterator != different_size_partitions->end(); my_iterator++) {
        SameSizePartitions same_size_partitions = *my_iterator;
        SameSizeStrategies same_size_strategies;
        Strategy *strategy;
        for (SameSizePartitions::iterator same_size_iterator = same_size_partitions.begin();
             same_size_iterator != same_size_partitions.end(); same_size_iterator++) {
            Partition partition = *same_size_iterator;

            strategy = new Strategy(this);
            CandidateListInfo *to_be_find_group;
            for (Partition::iterator group_iterator = partition.begin();
                 group_iterator != partition.end(); group_iterator++) {
                GroupInPartition group_in_partition = *group_iterator;
                to_be_find_group = new CandidateListInfo();
                for (GroupInPartition::iterator my_iterator = group_in_partition.begin();
                     my_iterator != group_in_partition.end(); my_iterator++) {
                    CandidateId candidate_id = *my_iterator;
                    to_be_find_group->candidates_->push_back(candidate_id);
                }
                strategy->candidate_list_info_list_.push_back(GetExactGroupPointer(to_be_find_group));
                delete to_be_find_group;
            }

            same_size_strategies.push_back(*strategy);
            delete strategy;
        }
        strategies_with_different_size_.push_back(same_size_strategies);
    }
}
开发者ID:CheYulin,项目名称:OpenListProportionalElection,代码行数:31,代码来源:open_list_party.cpp

示例2: exec

void SequentialEquivalenceAction::exec() {
  TrivialEq teq;
  vector<EqualFn *> eqs;
  eqs.push_back(&teq);

  int rseed = model().options()["rand"].as<int>();
  if(rseed != -1)
    srand(rseed);

  ExprAttachment * const eat = (ExprAttachment *) model().constAttachment(Key::EXPR);

  Expr::Manager::View * ev = model().newView();

  FMap fmap;
  vector<ID> vars = eat->stateVars();
  for (vector<ID>::const_iterator it = vars.begin(); it != vars.end(); ++it)
    fmap.insert(FMap::value_type(*it, eat->nextStateFnOf(*it)));
 
  //uninitialized latches or those that get dropped out of ECs
  FMap singletonLatches = fmap; 

  // currently only works for AIGER 1.9 initial conditions
  Partition parts;
  set<ID> fpart, tpart;
  fpart.insert(ev->bfalse());
  tpart.insert(ev->btrue());
  vector<ID> init = eat->initialConditions();
  for (vector<ID>::const_iterator it = init.begin(); it != init.end(); ++it) {
    if (ev->op(*it) == Expr::Var) {
      tpart.insert(*it);
      singletonLatches.erase(*it);
    }
    else {
      fpart.insert(ev->apply(Expr::Not, *it));
      singletonLatches.erase(ev->apply(Expr::Not,*it));
    }
  }

  if (fpart.size() == 1 && tpart.size() == 1) {
    delete ev;
    return;
  }
  parts.push_back(fpart);
  parts.push_back(tpart);

  // Construct map of latches to fan-in latches.
  IDIDSetMap nsfSupport;
  for (vector<ID>::const_iterator it = vars.begin(); it != vars.end(); ++it) {
    set<ID> support;
    eat->supportStateVars(*ev, eat->nextStateFnOf(*it), support);
    nsfSupport.insert(IDIDSetMap::value_type(*it, support));
  }

  if (model().verbosity() > Options::Terse)
    cout << "SequentialEquivalenceAction starting" << endl;
  if (model().verbosity() > Options::Silent)
    cout << "SequentialEquivalence: Initial # latches = " << vars.size() << endl;

  //Refine classes
  if (model().verbosity() > Options::Informative)
    cout << "SequentialEquivalence: Simulation refinement" << endl;
  SimRefine simRefine(model(), ev, parts, fmap);
  sequentialSimulateRandom64(model(), 100, simRefine);

  CacheMap cache;
  ev->begin_local();
  for (vector<EqualFn *>::iterator eq = eqs.begin(); eq != eqs.end(); ++eq) {
    for (;;) {
      if (model().verbosity() > Options::Informative) {
        cout << " " << parts.size();
#if 0
        for (Partition::iterator it = parts.begin(); it != parts.end(); ++it)
          cout << " " << it->size();
#endif
        cout << endl;
      }
      FMap curr(fmap);
      iterate(ev, eat, parts, curr, nsfSupport, cache);
      if (!refine(ev, parts, curr, fmap, **eq)) {
        if (eq+1 == eqs.end()) {
          // globalize roots
          vector<ID> roots;
          for (FMap::const_iterator it = curr.begin(); it != curr.end(); ++it)
            roots.push_back(it->second);
          ev->global(roots);
          // make curr point to global roots
          unsigned int i = 0;
          for (FMap::iterator it = curr.begin(); it != curr.end(); ++it, ++i)
            it->second = roots[i];
          // save as fmap
          fmap = curr;
        }
        break;
      }
    }
  }
  ev->end_local();
  model().constRelease(eat);

  //Add latches that were dropped from ECs
//.........这里部分代码省略.........
开发者ID:shengyushen,项目名称:compsyn,代码行数:101,代码来源:SequentialEquivalence.cpp


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