Esempio n. 1
0
 Space*
 RBS::next(void) {
   if (restart) {
     restart = false;
     sslr++;
     NoGoods& ng = e->nogoods();
     // Reset number of no-goods found
     ng.ng(0);
     MetaInfo mi(stop->m_stat.restart,sslr,e->statistics().fail,last,ng);
     bool r = master->master(mi);
     stop->m_stat.nogood += ng.ng();
     if (master->status(stop->m_stat) == SS_FAILED) {
       stop->update(e->statistics());
       delete master;
       master = NULL;
       e->reset(NULL);
       return NULL;
     } else if (r) {
       stop->update(e->statistics());
       Space* slave = master;
       master = master->clone(shared_data,shared_info);
       complete = slave->slave(mi);
       e->reset(slave);
       sslr = 0;
       stop->m_stat.restart++;
     }
   }
   while (true) {
     Space* n = e->next();
     if (n != NULL) {
       // The engine found a solution
       restart = true;
       delete last;
       last = n->clone();
       return n;
     } else if ( (!complete && !e->stopped()) ||
                 (e->stopped() && stop->enginestopped()) ) {
       // The engine must perform a true restart
       // The number of the restart has been incremented in the stop object
       sslr = 0;
       NoGoods& ng = e->nogoods();
       ng.ng(0);
       MetaInfo mi(stop->m_stat.restart,sslr,e->statistics().fail,last,ng);
       (void) master->master(mi);
       stop->m_stat.nogood += ng.ng();
       long unsigned int nl = ++(*co);
       stop->limit(e->statistics(),nl);
       if (master->status(stop->m_stat) == SS_FAILED)
         return NULL;
       Space* slave = master;
       master = master->clone(shared_data,shared_info);
       complete = slave->slave(mi);
       e->reset(slave);
     } else {
       return NULL;
     }
   }
   GECODE_NEVER;
   return NULL;
 }
Esempio n. 2
0
 forceinline
 RBS<E,T>::RBS(T* s, const Search::Options& m_opt) {
   if (m_opt.cutoff == NULL)
     throw Search::UninitializedCutoff("RBS::RBS");
   Search::Options e_opt(m_opt.expand());
   e_opt.clone = false;
   Search::Meta::RestartStop* rs = new Search::Meta::RestartStop(m_opt.stop);
   e_opt.stop = rs;
   Space* master;
   Space* slave;
   if (s->status(rs->m_stat) == SS_FAILED) {
     rs->m_stat.fail++;
     master = NULL;
     slave  = NULL;
   } else {
     if (m_opt.clone)
       master = s->clone();
     else
       master = s;
     slave = master->clone();
     CRI cri(0,0,0,NULL,NoGoods::eng);
     slave->slave(cri);
   }
   E<T> engine(dynamic_cast<T*>(slave),e_opt);
   Search::EngineBase<T>* eb = &engine;
   Search::Engine* ee = eb->e;
   eb->e = NULL;
   e = new Search::Meta::RBS(master,rs,ee,m_opt);
 }
Esempio n. 3
0
 forceinline bool
 CollectBest::constrain(const Space& s) {
   if (b != NULL) {
     b->constrain(s);
     if (b->status() == SS_FAILED) {
       delete b;
     } else {
       return false;
     }
   }
   b = s.clone(false);
   reporter = NULL;
   return true;
 }
Esempio n. 4
0
 void
 RBS::constrain(const Space& b) {
   if (!best)
     throw NoBest("RBS::constrain");
   if (last != NULL) {
     last->constrain(b);
     if (last->status() == SS_FAILED) {
       delete last;
     } else {
       return;
     }
   }
   last = b.clone();
   master->constrain(b);
   e->constrain(b);
 }