Generated on Tue May 22 09:40:12 2018 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  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode { namespace Search {
00039 
00040   forceinline
00041   Cutoff::Cutoff(void) {}
00042   forceinline
00043   Cutoff::~Cutoff(void) {}
00044 
00045 
00046   forceinline
00047   CutoffConstant::CutoffConstant(unsigned long int c0)
00048     : c(c0) {}
00049 
00050 
00051   forceinline
00052   CutoffLinear::CutoffLinear(unsigned long int s)
00053     : scale(s), n(0) {}
00054 
00055 
00056   forceinline
00057   CutoffLuby::CutoffLuby(unsigned long int scale0)
00058     : i(1U), scale(scale0) {}
00059   forceinline unsigned long int
00060   CutoffLuby::log(unsigned long int i) {
00061     if (i == 1U)
00062       return 0U;
00063     unsigned long int exp = 0U;
00064     while ( (i >> (++exp)) > 1U ) {}
00065     return exp;
00066   }
00067   forceinline unsigned long int
00068   CutoffLuby::luby(unsigned long int i) {
00069     while (true) {
00070       if (i <= n_start)
00071         return start[i-1];
00072       unsigned long int l = log(i);
00073       if (i == (1U<<(l+1))-1)
00074         return 1UL<<l;
00075       i=i-(1U<<l)+1;
00076     }
00077     GECODE_NEVER;
00078     return 0;
00079   }
00080 
00081 
00082   forceinline
00083   CutoffGeometric::CutoffGeometric(unsigned long int scale0, double base0)
00084     : n(1.0), scale(static_cast<double>(scale0)), base(base0) {}
00085 
00086 
00087   forceinline
00088   CutoffRandom::CutoffRandom(unsigned int seed,
00089                              unsigned long int min0,
00090                              unsigned long int max0,
00091                              unsigned long int n0)
00092       : rnd(seed), min(min0), n(n0 == 0 ? (max0-min+1U) : n0),
00093         step(std::max(1UL,
00094                       static_cast<unsigned long int>((max0-min0+1U)/n))) {
00095     cur = ++(*this);
00096   }
00097 
00098 
00099   forceinline
00100   CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long int n0, Cutoff* d2)
00101     : c1(d1), c2(d2), n(n0) {}
00102   forceinline
00103   CutoffAppend::~CutoffAppend(void) {
00104     delete c1; delete c2;
00105   }
00106 
00107 
00108   forceinline
00109   CutoffMerge::CutoffMerge(Cutoff* d1, Cutoff* d2)
00110     : c1(d1), c2(d2) {}
00111   forceinline
00112   CutoffMerge::~CutoffMerge(void) {
00113     delete c1; delete c2;
00114   }
00115 
00116 
00117   forceinline
00118   CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long int n0)
00119     : c(c1), i(0), n(n0) {
00120     cutoff = (*c)();
00121   }
00122   forceinline
00123   CutoffRepeat::~CutoffRepeat(void) {
00124     delete c;
00125   }
00126 
00127 }}
00128 
00129 // STATISTICS: search-other