restart.icc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 namespace Gecode {
00023
00024
00025
00026
00027
00028
00029 template <class T>
00030 Restart<T>::Restart(T* s, unsigned int c_d, unsigned int a_d,
00031 Search::Stop* st) :
00032 Gecode::DFS<T>(s,c_d,a_d,st), root(s->clone()), best(NULL) {}
00033
00034 template <class T>
00035 forceinline
00036 Restart<T>::~Restart(void) {
00037 delete best;
00038 delete root;
00039 }
00040
00041 template <class T>
00042 forceinline T*
00043 Restart<T>::next(void) {
00044 if (best != NULL) {
00045 static_cast<T*>(root)->constrain(static_cast<T*>(best));
00046 this->e.clone++;
00047 this->e.reset(root->clone(true,this->e.propagate));
00048 }
00049 Space* b = this->e.explore();
00050 delete best;
00051 best = (b != NULL) ? b->clone() : NULL;
00052 return static_cast<T*>(b);
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 template <class T>
00064 T*
00065 restart(T* s, unsigned int c_d, unsigned int a_d, Search::Stop* st) {
00066 Restart<T> b(s,c_d,a_d,st);
00067 T* l = NULL;
00068 while (T* n = b.next()) {
00069 delete l; l = n;
00070 }
00071 return l;
00072 }
00073
00074 }
00075
00076