this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Guido Tack <tack@gecode.org> 5 * 6 * Contributing authors: 7 * Christian Schulte <schulte@gecode.org> 8 * 9 * Copyright: 10 * Christian Schulte, 2013 11 * Guido Tack, 2013 12 * 13 * This file is part of Gecode, the generic constraint 14 * development environment: 15 * http://www.gecode.org 16 * 17 * Permission is hereby granted, free of charge, to any person obtaining 18 * a copy of this software and associated documentation files (the 19 * "Software"), to deal in the Software without restriction, including 20 * without limitation the rights to use, copy, modify, merge, publish, 21 * distribute, sublicense, and/or sell copies of the Software, and to 22 * permit persons to whom the Software is furnished to do so, subject to 23 * the following conditions: 24 * 25 * The above copyright notice and this permission notice shall be 26 * included in all copies or substantial portions of the Software. 27 * 28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 29 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 31 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 32 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 33 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 34 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 35 * 36 */ 37 38namespace Gecode { namespace Search { 39 40 forceinline 41 Cutoff::Cutoff(void) {} 42 forceinline 43 Cutoff::~Cutoff(void) {} 44 45 46 forceinline 47 CutoffConstant::CutoffConstant(unsigned long long int c0) 48 : c(c0) {} 49 50 51 forceinline 52 CutoffLinear::CutoffLinear(unsigned long long int s) 53 : scale(s), n(s) {} 54 55 56 forceinline 57 CutoffLuby::CutoffLuby(unsigned long long int scale0) 58 : i(1U), scale(scale0) {} 59 forceinline unsigned long long int 60 CutoffLuby::log(unsigned long long int i) { 61 if (i == 1ULL) 62 return 0U; 63 unsigned long long int exp = 0U; 64 while ( (i >> (++exp)) > 1U ) {} 65 return exp; 66 } 67 forceinline unsigned long long int 68 CutoffLuby::luby(unsigned long long int i) { 69 while (true) { 70 if (i <= n_start) 71 return static_cast<unsigned long long int>(start[i-1]); 72 unsigned long long int l = log(i); 73 if (i == (1ULL<<(l+1))-1) 74 return 1ULL<<l; 75 i=i-(1ULL<<l)+1; 76 } 77 GECODE_NEVER; 78 return 0ULL; 79 } 80 81 82 forceinline 83 CutoffGeometric::CutoffGeometric(unsigned long long int scale0, double base0) 84 : n(1.0), scale(static_cast<double>(scale0)), base(base0) {} 85 86 87 forceinline 88 CutoffRandom::CutoffRandom(unsigned int seed, 89 unsigned long long int min0, 90 unsigned long long int max0, 91 unsigned long long int n0) 92 : rnd(seed), min(min0), n(n0), 93 step(std::max(1ULL, 94 static_cast<unsigned long long int>((max0-min0+1U)/n))) { 95 cur = ++(*this); 96 } 97 98 99 forceinline 100 CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long long int n0, Cutoff* d2) 101 : c1(d1), c2(d2), n(n0) {} 102 forceinline 103 CutoffAppend::~CutoffAppend(void) { 104 delete c1; delete c2; 105 } 106 107 108 forceinline 109 CutoffMerge::CutoffMerge(Cutoff* d1, Cutoff* d2) 110 : c1(d1), c2(d2) {} 111 forceinline 112 CutoffMerge::~CutoffMerge(void) { 113 delete c1; delete c2; 114 } 115 116 117 forceinline 118 CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long long int n0) 119 : c(c1), i(0), n(n0) { 120 cutoff = (*c)(); 121 } 122 forceinline 123 CutoffRepeat::~CutoffRepeat(void) { 124 delete c; 125 } 126 127}} 128 129// STATISTICS: search-other