コード例 #1
0
ファイル: core.cpp プロジェクト: Wushaowei001/crossbow
 void
 Space::_trycommit(const Choice& c, unsigned int a) {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative("Space::commit");
   if (failed())
     return;
   if (Brancher* b = brancher(c._id)) {
     // There is a matching brancher
     if (b->commit(*this,c,a) == ES_FAILED)
       fail();
   }
 }
コード例 #2
0
ファイル: core.cpp プロジェクト: Wushaowei001/crossbow
 NGL*
 Space::ngl(const Choice& c, unsigned int a) {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative("Space::ngl");
   if (failed())
     return NULL;
   if (Brancher* b = brancher(c._id)) {
     // There is a matching brancher
     return b->ngl(*this,c,a);
   } else {
     return NULL;
   }
 }
コード例 #3
0
ファイル: core.cpp プロジェクト: Wushaowei001/crossbow
 void
 Space::print(const Choice& c, unsigned int a, std::ostream& o) const {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative("Space::print");
   if (failed())
     return;
   if (Brancher* b = const_cast<Space&>(*this).brancher(c._id)) {
     // There is a matching brancher
     b->print(*this,c,a,o);
   } else {
     // There is no matching brancher!
     throw SpaceNoBrancher("Space::print");
   }
 }
コード例 #4
0
ファイル: core.cpp プロジェクト: lquan/CSAI
 void
 Space::_commit(const Choice& c, unsigned int a) {
   if (a >= c.alternatives())
     throw SpaceIllegalAlternative();
   if (failed())
     return;
   /*
    * Due to weakly monotonic propagators the following scenario might
    * occur: a brancher has been committed with all its available
    * choices. Then, propagation determines less information
    * than before and the brancher now will create new choices.
    * Later, during recomputation, all of these choices
    * can be used together, possibly interleaved with 
    * choices for other branchers. That means all branchers
    * must be scanned to find the matching brancher for the choice.
    *
    * b_commit tries to optimize scanning as it is most likely that
    * recomputation does not generate new choices during recomputation
    * and hence b_commit is moved from newer to older branchers.
    */
   Brancher* b_old = b_commit;
   // Try whether we are lucky
   while (b_commit != Brancher::cast(&bl))
     if (c._id != b_commit->id())
       b_commit = Brancher::cast(b_commit->next());
     else
       goto found;
   if (b_commit == Brancher::cast(&bl)) {
     // We did not find the brancher, start at the beginning
     b_commit = Brancher::cast(bl.next());
     while (b_commit != b_old)
       if (c._id != b_commit->id())
         b_commit = Brancher::cast(b_commit->next());
       else
         goto found;
   }
   // There is no matching brancher!
   throw SpaceNoBrancher();
 found:
   // There is a matching brancher
   if (b_commit->commit(*this,c,a) == ES_FAILED)
     fail();
 }