Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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  * Last modified:
14  * $Date$ by $Author$
15  * $Revision$
16  *
17  * This file is part of Gecode, the generic constraint
18  * development environment:
19  * http://www.gecode.org
20  *
21  * Permission is hereby granted, free of charge, to any person obtaining
22  * a copy of this software and associated documentation files (the
23  * "Software"), to deal in the Software without restriction, including
24  * without limitation the rights to use, copy, modify, merge, publish,
25  * distribute, sublicense, and/or sell copies of the Software, and to
26  * permit persons to whom the Software is furnished to do so, subject to
27  * the following conditions:
28  *
29  * The above copyright notice and this permission notice shall be
30  * included in all copies or substantial portions of the Software.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39  *
40  */
41 
42 namespace Gecode { namespace Search {
43 
45  Cutoff::Cutoff(void) {}
47  Cutoff::~Cutoff(void) {}
48 
49 
51  CutoffConstant::CutoffConstant(unsigned long int c0)
52  : c(c0) {}
53 
54 
56  CutoffLinear::CutoffLinear(unsigned long int s)
57  : scale(s), n(0) {}
58 
59 
61  CutoffLuby::CutoffLuby(unsigned long int scale0)
62  : i(1U), scale(scale0) {}
63  forceinline unsigned long int
64  CutoffLuby::log(unsigned long int i) {
65  if (i == 1U)
66  return 0U;
67  unsigned long int exp = 0U;
68  while ( (i >> (++exp)) > 1U ) {}
69  return exp;
70  }
71  forceinline unsigned long int
72  CutoffLuby::luby(unsigned long int i) {
73  while (true) {
74  if (i <= n_start)
75  return start[i-1];
76  unsigned long int l = log(i);
77  if (i == (1U<<(l+1))-1)
78  return 1UL<<l;
79  i=i-(1U<<l)+1;
80  }
82  return 0;
83  }
84 
85 
87  CutoffGeometric::CutoffGeometric(unsigned long int scale0, double base0)
88  : n(1.0), scale(static_cast<double>(scale0)), base(base0) {}
89 
90 
92  CutoffRandom::CutoffRandom(unsigned int seed,
93  unsigned long int min0,
94  unsigned long int max0,
95  unsigned long int n0)
96  : rnd(seed), min(min0), n(n0 == 0 ? (max0-min+1U) : n0),
97  step(std::max(1UL,
98  static_cast<unsigned long int>((max0-min0+1U)/n))) {
99  cur = ++(*this);
100  }
101 
102 
104  CutoffAppend::CutoffAppend(Cutoff* d1, unsigned long int n0, Cutoff* d2)
105  : c1(d1), c2(d2), n(n0) {}
108  delete c1; delete c2;
109  }
110 
111 
114  : c1(d1), c2(d2) {}
117  delete c1; delete c2;
118  }
119 
120 
122  CutoffRepeat::CutoffRepeat(Cutoff* c1, unsigned long int n0)
123  : c(c1), i(0), n(n0) {
124  cutoff = (*c)();
125  }
128  delete c;
129  }
130 
131 }}
132 
133 // STATISTICS: search-other
const Gecode::FloatNum step
Definition: arithmetic.cpp:789
Cutoff(void)
Default constructor.
Definition: cutoff.hpp:45
unsigned long int scale
Scale factor.
Definition: search.hh:547
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
static const unsigned long int n_start
Number of pre-computed luby values.
Definition: search.hh:570
virtual ~Cutoff(void)
Destructor.
Definition: cutoff.hpp:47
Cutoff * c1
First cutoff generator.
Definition: search.hh:664
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
static unsigned long int luby(unsigned long int i)
Compute Luby number for step i.
Definition: cutoff.hpp:72
virtual ~CutoffAppend(void)
Destructor.
Definition: cutoff.hpp:107
unsigned long int scale
Scale factor.
Definition: search.hh:568
Definition: flatzinc.cpp:56
Base class for cutoff generators for restart-based meta engine.
Definition: search.hh:474
#define forceinline
Definition: config.hpp:182
unsigned long int n
Random values.
Definition: search.hh:618
CutoffLuby(unsigned long int scale)
Constructor.
Definition: cutoff.hpp:61
Gecode::IntSet d1(v1, 7)
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Gecode::IntSet d2(v2, 9)
virtual ~CutoffRepeat(void)
Destructor.
Definition: cutoff.hpp:127
static Cutoff * rnd(unsigned int seed, unsigned long int min, unsigned long int max, unsigned long int n)
Definition: cutoff.cpp:168
static unsigned long int start[n_start]
Precomputed luby-values.
Definition: search.hh:572
unsigned long int cur
Current value.
Definition: search.hh:622
unsigned long int i
Iteration number.
Definition: search.hh:566
double n
Current cutoff value.
Definition: search.hh:593
Cutoff * c2
Second cutoff generators.
Definition: search.hh:643
static unsigned long int log(unsigned long int i)
Compute binary logarithm of i.
Definition: cutoff.hpp:64
Cutoff * c1
First cutoff generators.
Definition: search.hh:641
virtual ~CutoffMerge(void)
Destructor.
Definition: cutoff.hpp:116
CutoffRandom(unsigned int seed, unsigned long int min, unsigned long int max, unsigned long int n)
Constructor.
Definition: cutoff.hpp:92
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:71
Cutoff * c
Actual cutoff generator.
Definition: search.hh:685
CutoffRepeat(Cutoff *c, unsigned long int n)
Constructor.
Definition: cutoff.hpp:122
const double base
Base for geometric restart sequence.
Definition: search.hh:128
CutoffMerge(Cutoff *c1, Cutoff *c2)
Constructor.
Definition: cutoff.hpp:113
CutoffGeometric(unsigned long int scale, double base)
Constructor.
Definition: cutoff.hpp:87
CutoffConstant(unsigned long int c)
Constructor.
Definition: cutoff.hpp:51
Gecode toplevel namespace
void exp(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Cutoff * c2
Second cutoff generator.
Definition: search.hh:666
CutoffAppend(Cutoff *c1, unsigned long int n, Cutoff *c2)
Constructor.
Definition: cutoff.hpp:104
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
CutoffLinear(unsigned long int scale)
Constructor.
Definition: cutoff.hpp:56