main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:30 for Gecode by
doxygen
1.8.4
gecode
search
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: 2013-10-30 13:25:29 +0100 (Wed, 30 Oct 2013) $ by $Author: schulte $
15
* $Revision: 14036 $
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
);
55
};
56
58
class
CutoffLinear
:
public
Cutoff
{
59
friend
class
Cutoff
;
60
private
:
62
unsigned
long
int
scale;
64
unsigned
long
int
n
;
66
CutoffLinear
(
unsigned
long
int
scale);
67
public
:
69
virtual
unsigned
long
int
operator()
(
void
);
70
};
71
73
class
CutoffLuby
:
public
Cutoff
{
74
friend
class
Cutoff
;
75
private
:
77
unsigned
long
int
i
;
79
unsigned
long
int
scale;
81
static
const
unsigned
long
int
n_start = 63U;
83
static
unsigned
long
int
start[n_start];
85
static
unsigned
long
int
log
(
unsigned
long
int
i
);
87
static
unsigned
long
int
luby(
unsigned
long
int
i
);
89
CutoffLuby
(
unsigned
long
int
scale);
90
public
:
92
virtual
unsigned
long
int
operator()
(
void
);
93
};
94
96
class
CutoffGeometric
:
public
Cutoff
{
97
friend
class
Cutoff
;
98
private
:
100
double
n
;
102
double
base;
104
CutoffGeometric
(
unsigned
long
int
scale,
double
base);
105
public
:
107
virtual
unsigned
long
int
operator ()
(
void
);
108
};
109
111
class
CutoffRandom
:
public
Cutoff
{
112
friend
class
Cutoff
;
113
private
:
115
Support::RandomGenerator
rnd;
117
unsigned
long
int
min
;
119
unsigned
long
int
n
;
121
unsigned
long
int
step
;
123
CutoffRandom
(
unsigned
int
seed,
124
unsigned
long
int
min
,
unsigned
long
int
max
,
125
unsigned
long
int
n
);
126
public
:
128
virtual
unsigned
long
int
operator ()
(
void
);
129
};
130
132
class
CutoffAppend
:
public
Cutoff
{
133
friend
class
Cutoff
;
134
private
:
136
Cutoff
* c1;
138
Cutoff
* c2;
140
unsigned
long
int
n
;
142
CutoffAppend
(
Cutoff
* c1,
unsigned
long
int
n
,
Cutoff
* c2);
143
public
:
145
virtual
unsigned
long
int
operator ()
(
void
);
147
virtual
~CutoffAppend
(
void
);
148
};
149
151
class
CutoffRepeat
:
public
Cutoff
{
152
friend
class
Cutoff
;
153
private
:
155
Cutoff
*
c
;
156
// Current cutoff
157
unsigned
int
cutoff;
158
// Iteration
159
unsigned
long
int
i
;
160
// Number of repetitions
161
unsigned
long
int
n
;
163
CutoffRepeat
(
Cutoff
*
c
,
unsigned
long
int
n
);
164
public
:
166
virtual
unsigned
long
int
operator ()
(
void
);
168
virtual
~CutoffRepeat
(
void
);
169
};
170
171
forceinline
172
Cutoff::Cutoff
(
void
) {}
173
forceinline
174
Cutoff::~Cutoff
(
void
) {}
175
forceinline
void
*
176
Cutoff::operator
new
(
size_t
s) {
177
return
heap
.
ralloc
(s);
178
}
179
forceinline
void
180
Cutoff::operator
delete
(
void
*
p
) {
181
heap
.
rfree
(
p
);
182
}
183
184
}}
185
186
// STATISTICS: search-other