Generated on Thu Jul 6 07:06:49 2006 for Gecode by doxygen 1.4.7

engine-ctrl.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-08-10 20:28:01 +0200 (Wed, 10 Aug 2005) $ by $Author: schulte $
00010  *     $Revision: 2202 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 namespace Gecode { namespace Search {
00023 
00024   forceinline
00025   EngineCtrl::EngineCtrl(Stop* st0, size_t sz) 
00026     : st(st0), _stopped(false), mem_space(sz), mem_cur(0), mem_total(0) {
00027     memory = 0;
00028   }
00029 
00030   forceinline void
00031   EngineCtrl::start(void) {
00032     _stopped = false;
00033   }
00034 
00035   forceinline bool
00036   EngineCtrl::stop(size_t sz) {
00037     if (st == NULL)
00038       return false;
00039     memory += sz;
00040     _stopped |= st->stop(*this);
00041     memory -= sz;
00042     return _stopped;
00043   }
00044 
00045   forceinline bool
00046   EngineCtrl::stopped(void) const {
00047     return _stopped;
00048   }
00049 
00050   forceinline void
00051   EngineCtrl::push(const Space* s) {
00052     mem_total += mem_space + s->allocated();
00053     if (mem_total > memory)
00054       memory = mem_total;
00055   }
00056 
00057   forceinline void
00058   EngineCtrl::push(const Space* s, const BranchingDesc* d) {
00059     if (s != NULL)
00060       mem_total += mem_space + s->allocated();
00061     if (d != NULL)
00062       mem_total += d->size();      
00063     if (mem_total > memory)
00064       memory = mem_total;
00065   }
00066 
00067   forceinline void
00068   EngineCtrl::pop(const Space* s) {
00069     mem_total -= mem_space + s->allocated();
00070   }
00071 
00072   forceinline void
00073   EngineCtrl::pop(const Space* s, const BranchingDesc* d) {
00074     if (s != NULL)
00075       mem_total -= mem_space + s->allocated();
00076     if (d != NULL)
00077       mem_total -= d->size();      
00078   }
00079 
00080   forceinline void
00081   EngineCtrl::current(const Space* s) {
00082     if (s == NULL) {
00083       mem_total -= mem_cur;
00084       mem_cur = 0;
00085     } else {
00086       mem_cur = mem_space + s->allocated() + s->cached();
00087       mem_total += mem_cur;
00088       if (mem_total > memory)
00089         memory = mem_total;
00090     }
00091   }
00092 
00093   forceinline void
00094   EngineCtrl::reset(const Space* s) {
00095     mem_cur   = mem_space+s->allocated()+s->cached();
00096     mem_total = mem_cur;
00097     if (mem_total > memory)
00098       memory = mem_total;
00099   }
00100 
00101 }}
00102 
00103 // STATISTICS: search-any