Generated on Wed Jan 1 2020 10:37:59 for Gecode by doxygen 1.8.16
cutoff.hpp
Go to the documentation of this file.
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 
38 namespace Gecode { namespace Search {
39 
41  Cutoff::Cutoff(void) {}
43  Cutoff::~Cutoff(void) {}
44 
45 
47  CutoffConstant::CutoffConstant(unsigned long int c0)
48  : c(c0) {}
49 
50 
52  CutoffLinear::CutoffLinear(unsigned long int s)
53  : scale(s), n(0) {}
54 
55 
57  CutoffLuby::CutoffLuby(unsigned long int scale0)
58  : i(1U), scale(scale0) {}
59  forceinline unsigned long int
60  CutoffLuby::log(unsigned long int i) {
61  if (i == 1U)
62  return 0U;
63  unsigned long int exp = 0U;
64  while ( (i >> (++exp)) > 1U ) {}
65  return exp;
66  }
67  forceinline unsigned long int
68  CutoffLuby::luby(unsigned long int i) {
69  while (true) {
70  if (i <= n_start)
71  return start[i-1];
72  unsigned long int l = log(i);
73  if (i == (1U<<(l+1))-1)
74  return 1UL<<l;
75  i=i-(1U<<l)+1;
76  }
78  return 0;
79  }
80 
81 
83  CutoffGeometric::CutoffGeometric(unsigned long int scale0, double base0)
84  : n(1.0), scale(static_cast<double>(scale0)), base(base0) {}
85 
86 
88  CutoffRandom::CutoffRandom(unsigned int seed,
89  unsigned long int min0,
90  unsigned long int max0,
91  unsigned long int n0)
92  : rnd(seed), min(min0), n(n0 == 0 ? (max0-min+1U) : n0),
93  step(std::max(1UL,
94  static_cast<unsigned long int>((max0-min0+1U)/n))) {
95  cur = ++(*this);
96  }
97 
98 
100  CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long int n0, Cutoff* d2)
101  : c1(d1), c2(d2), n(n0) {}
104  delete c1; delete c2;
105  }
106 
107 
110  : c1(d1), c2(d2) {}
113  delete c1; delete c2;
114  }
115 
116 
118  CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long int n0)
119  : c(c1), i(0), n(n0) {
120  cutoff = (*c)();
121  }
124  delete c;
125  }
126 
127 }}
128 
129 // STATISTICS: search-other
const Gecode::FloatNum step
Definition: arithmetic.cpp:785
static unsigned long int luby(unsigned long int i)
Compute Luby number for step i.
Definition: cutoff.hpp:68
unsigned long int i
Iteration number.
Definition: search.hh:564
static unsigned long int start[n_start]
Precomputed luby-values.
Definition: search.hh:570
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:49
CutoffLinear(unsigned long int scale)
Constructor.
Definition: cutoff.hpp:52
static const unsigned long int n_start
Number of pre-computed luby values.
Definition: search.hh:568
CutoffRepeat(Cutoff *c, unsigned long int n)
Constructor.
Definition: cutoff.hpp:118
virtual ~CutoffAppend(void)
Destructor.
Definition: cutoff.hpp:103
unsigned int cutoff
Definition: search.hh:685
CutoffLuby(unsigned long int scale)
Constructor.
Definition: cutoff.hpp:57
Gecode toplevel namespace
Cutoff * c2
Second cutoff generator.
Definition: search.hh:664
static unsigned long int log(unsigned long int i)
Compute binary logarithm of i.
Definition: cutoff.hpp:60
virtual ~Cutoff(void)
Destructor.
Definition: cutoff.hpp:43
CutoffConstant(unsigned long int c)
Constructor.
Definition: cutoff.hpp:47
virtual ~CutoffMerge(void)
Destructor.
Definition: cutoff.hpp:112
Cutoff * c1
First cutoff generator.
Definition: search.hh:662
CutoffMerge(Cutoff *c1, Cutoff *c2)
Constructor.
Definition: cutoff.hpp:109
const double base
Base for geometric restart sequence.
Definition: search.hh:126
unsigned long int cur
Current value.
Definition: search.hh:620
Cutoff * c1
First cutoff generators.
Definition: search.hh:639
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56
Gecode::IntSet d1(v1, 7)
Base class for cutoff generators for restart-based meta engine.
Definition: search.hh:472
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
Gecode::IntSet d2(v2, 9)
Definition: flatzinc.cpp:52
#define forceinline
Definition: config.hpp:185
Cutoff(void)
Default constructor.
Definition: cutoff.hpp:41
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:67
Gecode::FloatVal c(-8, 8)
CutoffAppend(Cutoff *c1, unsigned long int n, Cutoff *c2)
Constructor.
Definition: cutoff.hpp:100
void exp(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
CutoffGeometric(unsigned long int scale, double base)
Constructor.
Definition: cutoff.hpp:83
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Cutoff * c
Actual cutoff generator.
Definition: search.hh:683
Cutoff * c2
Second cutoff generators.
Definition: search.hh:641
Gecode::IntArgs i({1, 2, 3, 4})
virtual ~CutoffRepeat(void)
Destructor.
Definition: cutoff.hpp:123
CutoffRandom(unsigned int seed, unsigned long int min, unsigned long int max, unsigned long int n)
Constructor.
Definition: cutoff.hpp:88