Generated on Wed Jan 4 17:49:13 2006 for Gecode by doxygen 1.4.6

bab.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Contributing authors:
00006  *     Guido Tack <tack@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2004
00010  *     Guido Tack, 2004
00011  *
00012  *  Last modified:
00013  *     $Date: 2005-08-10 20:28:01 +0200 (Wed, 10 Aug 2005) $ by $Author: schulte $
00014  *     $Revision: 2202 $
00015  *
00016  *  This file is part of Gecode, the generic constraint
00017  *  development environment:
00018  *     http://www.gecode.org
00019  *
00020  *  See the file "LICENSE" for information on usage and
00021  *  redistribution of this file, and for a
00022  *     DISCLAIMER OF ALL WARRANTIES.
00023  *
00024  */
00025 
00026 namespace Gecode { 
00027 
00028   namespace Search {
00029     
00030     /*
00031      * Memory management for engines
00032      *
00033      */
00034     
00035     forceinline
00036     BabEngine::BabEngine(size_t sz)
00037       : FullStatistics(sz) {}
00038 
00039     forceinline void*
00040     BabEngine::operator new(size_t s) {
00041       return Memory::malloc(s);
00042     }
00043     
00044     forceinline void
00045     BabEngine::operator delete(void* p, size_t) {
00046       Memory::free(p);
00047     }
00048     
00049     forceinline
00050     BabEngine::~BabEngine(void) {
00051     }
00052     
00053   }
00054     
00055   /*
00056    * Control for bab search engine
00057    *
00058    */
00059   
00060   template <class T>
00061   forceinline
00062   BAB<T>::BAB(T* s, unsigned int c_d, unsigned int a_d)
00063     : Search::BAB(s,c_d,a_d,sizeof(T)) {}
00064 
00065   template <class T>
00066   forceinline T*
00067   BAB<T>::next(void) {
00068     Space *s1, *s2;
00069     while (!e->explore(s1,s2))
00070       static_cast<T*>(s1)->constrain(static_cast<T*>(s2));
00071     return static_cast<T*>(s1);
00072   }
00073 
00074 
00075 
00076 
00077   /*
00078    * BAB convenience
00079    *
00080    */
00081 
00082   template <class T>
00083   T*
00084   bab(T* s, unsigned int c_d, unsigned int a_d) {
00085     BAB<T> b(s,c_d,a_d);
00086     T* l = NULL;
00087     while (T* n = b.next()) {
00088       delete l; l = n;
00089     }
00090     return l;
00091   }
00092 
00093 }
00094 
00095 // STATISTICS: search-any