Generated on Sat Feb 7 2015 02:01:29 for Gecode by doxygen 1.8.9.1
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: 2014-10-21 17:09:50 +0200 (Tue, 21 Oct 2014) $ by $Author: schulte $
15  * $Revision: 14258 $
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  class CutoffConstant : public Cutoff {
46  friend class Cutoff;
47  private:
49  unsigned long int c;
51  CutoffConstant(unsigned long int c);
52  public:
54  virtual unsigned long int operator ()(void) const;
56  virtual unsigned long int operator ++(void);
57  };
58 
60  class CutoffLinear : public Cutoff {
61  friend class Cutoff;
62  private:
64  unsigned long int scale;
66  unsigned long int n;
68  CutoffLinear(unsigned long int scale);
69  public:
71  virtual unsigned long int operator ()(void) const;
73  virtual unsigned long int operator ++(void);
74  };
75 
77  class CutoffLuby : public Cutoff {
78  friend class Cutoff;
79  private:
81  unsigned long int i;
83  unsigned long int scale;
85  static const unsigned long int n_start = 63U;
87  static unsigned long int start[n_start];
89  static unsigned long int log(unsigned long int i);
91  static unsigned long int luby(unsigned long int i);
93  CutoffLuby(unsigned long int scale);
94  public:
96  virtual unsigned long int operator ()(void) const;
98  virtual unsigned long int operator ++(void);
99  };
100 
102  class CutoffGeometric : public Cutoff {
103  friend class Cutoff;
104  private:
106  double n;
108  double scale;
110  double base;
112  CutoffGeometric(unsigned long int scale, double base);
113  public:
115  virtual unsigned long int operator ()(void) const;
117  virtual unsigned long int operator ++(void);
118  };
119 
121  class CutoffRandom : public Cutoff {
122  friend class Cutoff;
123  private:
127  unsigned long int min;
129  unsigned long int n;
131  unsigned long int step;
133  unsigned long int cur;
135  CutoffRandom(unsigned int seed,
136  unsigned long int min, unsigned long int max,
137  unsigned long int n);
138  public:
140  virtual unsigned long int operator ()(void) const;
142  virtual unsigned long int operator ++(void);
143  };
144 
146  class CutoffAppend : public Cutoff {
147  friend class Cutoff;
148  private:
150  Cutoff* c1;
152  Cutoff* c2;
154  unsigned long int n;
156  CutoffAppend(Cutoff* c1, unsigned long int n, Cutoff* c2);
157  public:
159  virtual unsigned long int operator ()(void) const;
161  virtual unsigned long int operator ++(void);
163  virtual ~CutoffAppend(void);
164  };
165 
167  class CutoffMerge : public Cutoff {
168  friend class Cutoff;
169  private:
171  Cutoff* c1;
173  Cutoff* c2;
175  CutoffMerge(Cutoff* c1, Cutoff* c2);
176  public:
178  virtual unsigned long int operator ()(void) const;
180  virtual unsigned long int operator ++(void);
182  virtual ~CutoffMerge(void);
183  };
184 
186  class CutoffRepeat : public Cutoff {
187  friend class Cutoff;
188  private:
190  Cutoff* c;
191  // Current cutoff
192  unsigned int cutoff;
193  // Iteration
194  unsigned long int i;
195  // Number of repetitions
196  unsigned long int n;
198  CutoffRepeat(Cutoff* c, unsigned long int n);
199  public:
201  virtual unsigned long int operator ()(void) const;
203  virtual unsigned long int operator ++(void);
205  virtual ~CutoffRepeat(void);
206  };
207 
209  Cutoff::Cutoff(void) {}
212  forceinline void*
213  Cutoff::operator new(size_t s) {
214  return heap.ralloc(s);
215  }
216  forceinline void
217  Cutoff::operator delete(void* p) {
218  heap.rfree(p);
219  }
220 
221 }}
222 
223 // STATISTICS: search-other
const Gecode::FloatNum step
Definition: arithmetic.cpp:789
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:51
Cutoff(void)
Default constructor.
Definition: cutoff.hpp:209
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:55
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:64
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:160
void log(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:151
virtual ~Cutoff(void)
Destructor.
Definition: cutoff.hpp:211
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:152
void rfree(void *p)
Free memory block starting at p.
Definition: heap.hpp:355
Cutoff generator appending two cutoff generators.
Definition: cutoff.hpp:146
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:128
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:108
virtual ~CutoffAppend(void)
Destructor.
Definition: cutoff.cpp:169
void * ralloc(size_t s)
Allocate s bytes from heap.
Definition: heap.hpp:341
Cutoff generator for the Luby sequence.
Definition: cutoff.hpp:77
Base class for cutoff generators for restart-based meta engine.
Definition: search.hh:389
Heap heap
The single global heap.
Definition: heap.cpp:49
Gecode::FloatVal c(-8, 8)
Cutoff generator merging two cutoff generators.
Definition: cutoff.hpp:167
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:203
const FloatNum min
Smallest allowed float value.
Definition: float.hh:833
Gecode::IntArgs i(4, 1, 2, 3, 4)
Cutoff generator for the random sequence.
Definition: cutoff.hpp:121
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:199
virtual ~CutoffRepeat(void)
Destructor.
Definition: cutoff.cpp:212
Template for linear congruential generators.
Definition: random.hpp:50
Cutoff generator for linear sequence.
Definition: cutoff.hpp:60
virtual ~CutoffMerge(void)
Destructor.
Definition: cutoff.cpp:188
Cutoff generator for the geometric sequence.
Definition: cutoff.hpp:102
Cutoff generator for constant sequence.
Definition: cutoff.hpp:45
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:104
#define forceinline
Definition: config.hpp:132
Cutoff generator that repeats a cutoff from another cutoff generator.
Definition: cutoff.hpp:186
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:143
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:178
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:182
virtual unsigned long int operator()(void) const
Return the current cutoff value.
Definition: cutoff.cpp:117
Gecode toplevel namespace
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:121
virtual unsigned long int operator++(void)
Increment and return the next cutoff value.
Definition: cutoff.cpp:68