Generated on Tue Apr 18 10:22:09 2017 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: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
00015  *     $Revision: 14967 $
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 
00049 
00050   forceinline
00051   CutoffConstant::CutoffConstant(unsigned long int c0)
00052     : c(c0) {}
00053 
00054 
00055   forceinline
00056   CutoffLinear::CutoffLinear(unsigned long int s)
00057     : scale(s), n(0) {}
00058 
00059 
00060   forceinline
00061   CutoffLuby::CutoffLuby(unsigned long int scale0)
00062     : i(1U), scale(scale0) {}
00063   forceinline unsigned long int
00064   CutoffLuby::log(unsigned long int i) {
00065     if (i == 1U)
00066       return 0U;
00067     unsigned long int exp = 0U;
00068     while ( (i >> (++exp)) > 1U ) {}
00069     return exp;
00070   }
00071   forceinline unsigned long int
00072   CutoffLuby::luby(unsigned long int i) {
00073     while (true) {
00074       if (i <= n_start)
00075         return start[i-1];
00076       unsigned long int l = log(i);
00077       if (i == (1U<<(l+1))-1)
00078         return 1UL<<l;
00079       i=i-(1U<<l)+1;
00080     }
00081     GECODE_NEVER;
00082     return 0;
00083   }
00084 
00085 
00086   forceinline
00087   CutoffGeometric::CutoffGeometric(unsigned long int scale0, double base0)
00088     : n(1.0), scale(static_cast<double>(scale0)), base(base0) {}
00089 
00090 
00091   forceinline
00092   CutoffRandom::CutoffRandom(unsigned int seed,
00093                              unsigned long int min0,
00094                              unsigned long int max0,
00095                              unsigned long int n0)
00096       : rnd(seed), min(min0), n(n0 == 0 ? (max0-min+1U) : n0),
00097         step(std::max(1UL,
00098                       static_cast<unsigned long int>((max0-min0+1U)/n))) {
00099     cur = ++(*this);
00100   }
00101 
00102 
00103   forceinline
00104   CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long int n0, Cutoff* d2)
00105     : c1(d1), c2(d2), n(n0) {}
00106   forceinline
00107   CutoffAppend::~CutoffAppend(void) {
00108     delete c1; delete c2;
00109   }
00110 
00111 
00112   forceinline
00113   CutoffMerge::CutoffMerge(Cutoff* d1, Cutoff* d2)
00114     : c1(d1), c2(d2) {}
00115   forceinline
00116   CutoffMerge::~CutoffMerge(void) {
00117     delete c1; delete c2;
00118   }
00119 
00120 
00121   forceinline
00122   CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long int n0)
00123     : c(c1), i(0), n(n0) {
00124     cutoff = (*c)();
00125   }
00126   forceinline
00127   CutoffRepeat::~CutoffRepeat(void) {
00128     delete c;
00129   }
00130 
00131 }}
00132 
00133 // STATISTICS: search-other