Generated on Fri Mar 20 15:56:19 2015 for Gecode by doxygen 1.6.3

cutoff.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Contributing authors:
00007  *     Christian Schulte <schulte@gecode.org>
00008  *
00009  *  Copyright:
00010  *     Christian Schulte, 2013
00011  *     Guido Tack, 2013
00012  *
00013  *  Last modified:
00014  *     $Date: 2015-03-11 10:45:36 +0100 (Wed, 11 Mar 2015) $ by $Author: schulte $
00015  *     $Revision: 14434 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 namespace Gecode { namespace Search {
00043 
00044   forceinline
00045   Cutoff::Cutoff(void) {}
00046   forceinline
00047   Cutoff::~Cutoff(void) {}
00048   forceinline void*
00049   Cutoff::operator new(size_t s) {
00050     return heap.ralloc(s);
00051   }
00052   forceinline void
00053   Cutoff::operator delete(void* p) {
00054     heap.rfree(p);
00055   }
00056 
00057 
00058   forceinline
00059   CutoffConstant::CutoffConstant(unsigned long int c0) 
00060     : c(c0) {}
00061 
00062 
00063   forceinline
00064   CutoffLinear::CutoffLinear(unsigned long int s) 
00065     : scale(s), n(0) {}
00066 
00067 
00068   forceinline
00069   CutoffLuby::CutoffLuby(unsigned long int scale0) 
00070     : i(1U), scale(scale0) {}
00071   forceinline unsigned long int 
00072   CutoffLuby::log(unsigned long int i) {
00073     if (i == 1U)
00074       return 0U;
00075     unsigned long int exp = 0U;
00076     while ( (i >> (++exp)) > 1U ) {}
00077     return exp;
00078   }
00079   forceinline unsigned long int 
00080   CutoffLuby::luby(unsigned long int i) {
00081     while (true) {
00082       if (i <= n_start)
00083         return start[i-1];
00084       unsigned long int l = log(i);
00085       if (i == (1U<<(l+1))-1)
00086         return 1UL<<l;
00087       i=i-(1U<<l)+1;
00088     }
00089     GECODE_NEVER;
00090     return 0;
00091   }
00092 
00093 
00094   forceinline
00095   CutoffGeometric::CutoffGeometric(unsigned long int scale0, double base0) 
00096     : n(1.0), scale(static_cast<double>(scale0)), base(base0) {}
00097 
00098 
00099   forceinline
00100   CutoffRandom::CutoffRandom(unsigned int seed, 
00101                              unsigned long int min0, 
00102                              unsigned long int max0, 
00103                              unsigned long int n0)
00104       : rnd(seed), min(min0), n(n0 == 0 ? (max0-min+1U) : n0), 
00105         step(std::max(1UL,
00106                       static_cast<unsigned long int>((max0-min0+1U)/n))) {
00107     cur = ++(*this);
00108   }
00109 
00110 
00111   forceinline
00112   CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long int n0, Cutoff* d2) 
00113     : c1(d1), c2(d2), n(n0) {}
00114   forceinline
00115   CutoffAppend::~CutoffAppend(void) {
00116     delete c1; delete c2;
00117   }
00118 
00119 
00120   forceinline
00121   CutoffMerge::CutoffMerge(Cutoff* d1, Cutoff* d2) 
00122     : c1(d1), c2(d2) {}
00123   forceinline
00124   CutoffMerge::~CutoffMerge(void) {
00125     delete c1; delete c2;
00126   }
00127 
00128 
00129   forceinline
00130   CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long int n0)
00131     : c(c1), i(0), n(n0) {
00132     cutoff = (*c)();
00133   }
00134   forceinline
00135   CutoffRepeat::~CutoffRepeat(void) {
00136     delete c;
00137   }
00138 
00139 }}
00140 
00141 // STATISTICS: search-other