Exemplo n.º 1
0
 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();
   }
 }
Exemplo n.º 2
0
 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");
   }
 }
Exemplo n.º 3
0
Arquivo: core.cpp Projeto: 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();
 }