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


C++ Propagator::propagate方法代码示例

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


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

示例1: computeWalkerPath

void TraineeWalker::computeWalkerPath()
{
  _maxNeed = 0;  // need of this trainee in buildings
  Propagator pathPropagator;
  pathPropagator.init( *_originBuilding.object() );
  pathPropagator.propagate(_maxDistance);

  for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
  {
    BuildingType buildingType = *itType;
    checkDestination(buildingType, pathPropagator);
  }

  if( _destinationBuilding != NULL )
  {
    // some building needs that trainee!
    // std::cout << "trainee sent!" << std::endl;
    PathWay pathWay;
    pathPropagator.getPath( _destinationBuilding, pathWay);
    setPathWay( pathWay );
    setIJ( _pathWay.getOrigin().getIJ() );
  }
  else
  {
    // nobody needs him...
    // std::cout << "trainee suicide!" << std::endl;
    deleteLater();
  }
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:29,代码来源:oc3_traineewalker.cpp

示例2: computeWalkerPath

void TraineeWalker::computeWalkerPath()
{
   _maxNeed = 0;  // need of this trainee in buildings
   Propagator pathPropagator;
   pathPropagator.init(*_originBuilding);
   pathPropagator.propagate(_maxDistance);

   for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
   {
      BuildingType buildingType = *itType;
      checkDestination(buildingType, pathPropagator);
   }

   if (_destinationBuilding != NULL)
   {
      // some building needs that trainee!
      // std::cout << "trainee sent!" << std::endl;
      PathWay pathWay;
      pathPropagator.getPath(*_destinationBuilding, pathWay);
      setPathWay(pathWay);
      setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
      Scenario::instance().getCity().getWalkerList().push_back(this);
      _destinationBuilding->reserveTrainee(_traineeType);
   }
   else
   {
      // nobody needs him...
      // std::cout << "trainee suicide!" << std::endl;
      _isDeleted = true;
   }

}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例3: propagate

bool Engine::propagate() {
    if (async_fail) {
        async_fail = false;
        assert(!so.lazy || sat.confl);
        return false;
    }

    last_prop = NULL;

 WakeUp:

    if (!sat.consistent() && !sat.propagate()) return false;

    for (int i = 0; i < v_queue.size(); i++) {
        v_queue[i]->wakePropagators();
    }
    v_queue.clear();

    if (sat.confl) return false;

    last_prop = NULL;

    for (int i = 0; i < num_queues; i++) {
        if (p_queue[i].size()) {
            Propagator *p = p_queue[i].last(); p_queue[i].pop();
            propagations++;
            bool ok = p->propagate();
            p->clearPropState();
            if (!ok) return false;
            goto WakeUp;
        }
    }

    return true;
}
开发者ID:cmears,项目名称:chuffed,代码行数:35,代码来源:engine.c

示例4: computeWalkerDestination

void CartPusher::computeWalkerDestination()
{
   // get the list of buildings within reach
   PathWay pathWay;
   Propagator pathPropagator;
   _d->consumerBuilding = 0;
   pathPropagator.init( *_d->producerBuilding.object() );
   pathPropagator.propagate(_d->maxDistance);

   BuildingPtr destBuilding;
   if (destBuilding == NULL)
   {
      // try send that good to a factory
      destBuilding = getWalkerDestination_factory(pathPropagator, pathWay);
   }

   if (destBuilding == NULL)
   {
      // try send that good to a granary
      destBuilding = getWalkerDestination_granary(pathPropagator, pathWay);
   }

   if (destBuilding == NULL)
   {
      // try send that good to a warehouse
      destBuilding = getWalkerDestination_warehouse( pathPropagator, pathWay );
   }

   if( destBuilding != NULL)
   {
      //_isDeleted = true;  // no destination!
     setConsumerBuilding( destBuilding );
     setPathWay( pathWay );
     setIJ( _pathWay.getOrigin().getIJ() );
     setSpeed( 1 );
   }
   else
   {
     _action._direction = D_NORTH;
     setSpeed( 0 );
     setIJ( _d->producerBuilding->getAccessRoads().front()->getIJ() );
     walk();
   }
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:44,代码来源:oc3_walker_cart_pusher.cpp

示例5: assert

 SpaceStatus
 Space::status(StatusStatistics& stat) {
   SpaceStatus s = SS_FAILED;
   // Check whether space is failed
   if (failed()) {
     s = SS_FAILED; goto exit;
   }
   assert(pc.p.active <= &pc.p.queue[PropCost::AC_MAX+1]);
   // Check whether space is stable but not failed
   if (pc.p.active >= &pc.p.queue[0]) {
     Propagator* p;
     ModEventDelta med_o;
     goto unstable;
   execute:
     stat.propagate++;
     // Keep old modification event delta
     med_o = p->u.med;
     // Clear med but leave propagator in queue
     p->u.med = 0;
     switch (p->propagate(*this,med_o)) {
     case ES_FAILED:
       // Count failure
       if (afc_enabled())
         gafc.fail(p->gafc);
       // Mark as failed
       fail(); s = SS_FAILED; goto exit;
     case ES_NOFIX:
       // Find next, if possible
       if (p->u.med != 0) {
       unstable:
         // There is at least one propagator in a queue
         do {
           assert(pc.p.active >= &pc.p.queue[0]);
           // First propagator or link back to queue
           ActorLink* fst = pc.p.active->next();
           if (pc.p.active != fst) {
             p = Propagator::cast(fst);
             goto execute;
           }
           pc.p.active--;
         } while (true);
         GECODE_NEVER;
       }
       // Fall through
     case ES_FIX:
       // Clear med and put into idle queue
       p->u.med = 0; p->unlink(); pl.head(p);
     stable_or_unstable:
       // There might be a propagator in the queue
       do {
         assert(pc.p.active >= &pc.p.queue[0]);
         // First propagator or link back to queue
         ActorLink* fst = pc.p.active->next();
         if (pc.p.active != fst) {
           p = Propagator::cast(fst);
           goto execute;
         }
       } while (--pc.p.active >= &pc.p.queue[0]);
       assert(pc.p.active < &pc.p.queue[0]);
       goto stable;
     case __ES_SUBSUMED:
       p->unlink(); rfree(p,p->u.size);
       goto stable_or_unstable;
     case __ES_PARTIAL:
       // Schedule propagator with specified propagator events
       assert(p->u.med != 0);
       enqueue(p);
       goto unstable;
     default:
       GECODE_NEVER;
     }
   }
 stable:
   /*
    * Find the next brancher that has still alternatives left
    *
    * It is important to note that branchers reporting to have no more
    * alternatives left cannot be deleted. They cannot be deleted
    * as there might be choices to be used in commit
    * that refer to one of these branchers. This e.g. happens when
    * we combine branch-and-bound search with adaptive recomputation: during
    * recomputation, a copy is constrained to be better than the currently
    * best solution, then the first half of the choices are posted,
    * and a fixpoint computed (for storing in the middle of the path). Then
    * the remaining choices are posted, and because of the additional
    * constraints that the space must be better than the previous solution,
    * the corresponding Branchers may already have no alternatives left.
    *
    * The same situation may arise due to weakly monotonic propagators.
    *
    * A brancher reporting that no more alternatives exist is exhausted.
    * All exhausted branchers will be left of the current pointer b_status.
    * Only when it is known that no more choices
    * can be used for commit an exhausted brancher can actually be deleted.
    * This becomes known when choice is called.
    */
   while (b_status != Brancher::cast(&bl))
     if (b_status->status(*this)) {
       // Brancher still has choices to generate
       s = SS_BRANCH; goto exit;
//.........这里部分代码省略.........
开发者ID:Wushaowei001,项目名称:crossbow,代码行数:101,代码来源:core.cpp


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