Generated on Wed Nov 1 15:04:43 2006 for Gecode by doxygen 1.4.5

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: 2006-08-04 16:03:17 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3511 $
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, const BranchingDesc* d) {
00052     if (s != NULL)
00053       mem_total += mem_space + s->allocated();
00054     mem_total += d->size();
00055     if (mem_total > memory)
00056       memory = mem_total;
00057   }
00058 
00059   forceinline void
00060   EngineCtrl::adapt(const Space* s) {
00061     mem_total += mem_space + s->allocated();
00062     if (mem_total > memory)
00063       memory = mem_total;
00064   }
00065 
00066   forceinline void
00067   EngineCtrl::constrained(const Space* s1, const Space* s2) {
00068     mem_total -= s1->allocated();
00069     mem_total += s2->allocated();
00070     if (mem_total > memory)
00071       memory = mem_total;
00072   }
00073 
00074   forceinline void
00075   EngineCtrl::lao(const Space* s) {
00076     mem_total -= mem_space + s->allocated();
00077   }
00078 
00079   forceinline void
00080   EngineCtrl::pop(const Space* s, const BranchingDesc* d) {
00081     if (s != NULL)
00082       mem_total -= mem_space + s->allocated();
00083     mem_total -= d->size();
00084   }
00085 
00086   forceinline void
00087   EngineCtrl::current(const Space* s) {
00088     if (s == NULL) {
00089       mem_total -= mem_cur;
00090       mem_cur = 0;
00091     } else {
00092       mem_cur = mem_space + s->allocated() + s->cached();
00093       mem_total += mem_cur;
00094       if (mem_total > memory)
00095         memory = mem_total;
00096     }
00097   }
00098 
00099   forceinline void
00100   EngineCtrl::reset(const Space* s) {
00101     mem_cur   = mem_space+s->allocated()+s->cached();
00102     mem_total = mem_cur;
00103     if (mem_total > memory)
00104       memory = mem_total;
00105   }
00106 
00107 }}
00108 
00109 // STATISTICS: search-any