main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
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: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
15
* $Revision: 14967 $
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
44
forceinline
45
Cutoff::Cutoff
(
void
) {}
46
forceinline
47
Cutoff::~Cutoff
(
void
) {}
48
49
50
forceinline
51
CutoffConstant::CutoffConstant
(
unsigned
long
int
c0)
52
:
c
(c0) {}
53
54
55
forceinline
56
CutoffLinear::CutoffLinear
(
unsigned
long
int
s)
57
: scale(s),
n
(0) {}
58
59
60
forceinline
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
}
81
GECODE_NEVER
;
82
return
0;
83
}
84
85
86
forceinline
87
CutoffGeometric::CutoffGeometric
(
unsigned
long
int
scale0,
double
base0)
88
:
n
(1.0), scale(static_cast<double>(scale0)),
base
(base0) {}
89
90
91
forceinline
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
103
forceinline
104
CutoffAppend::CutoffAppend
(
Cutoff
*
d1
,
unsigned
long
int
n0,
Cutoff
*
d2
)
105
: c1(
d1
), c2(
d2
),
n
(n0) {}
106
forceinline
107
CutoffAppend::~CutoffAppend
(
void
) {
108
delete
c1
;
delete
c2
;
109
}
110
111
112
forceinline
113
CutoffMerge::CutoffMerge
(
Cutoff
*
d1
,
Cutoff
*
d2
)
114
: c1(
d1
), c2(
d2
) {}
115
forceinline
116
CutoffMerge::~CutoffMerge
(
void
) {
117
delete
c1
;
delete
c2
;
118
}
119
120
121
forceinline
122
CutoffRepeat::CutoffRepeat
(
Cutoff
* c1,
unsigned
long
int
n0)
123
:
c
(c1),
i
(0),
n
(n0) {
124
cutoff
= (*c)();
125
}
126
forceinline
127
CutoffRepeat::~CutoffRepeat
(
void
) {
128
delete
c
;
129
}
130
131
}}
132
133
// STATISTICS: search-other
Test::Float::Arithmetic::step
const Gecode::FloatNum step
Definition:
arithmetic.cpp:789
Gecode::Search::CutoffLuby::luby
static unsigned long int luby(unsigned long int i)
Compute Luby number for step i.
Definition:
cutoff.hpp:72
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Search::CutoffLuby::i
unsigned long int i
Iteration number.
Definition:
search.hh:264
Gecode::Search::CutoffLuby::start
static unsigned long int start[n_start]
Precomputed luby-values.
Definition:
search.hh:270
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:53
Gecode::Search::CutoffLinear::CutoffLinear
CutoffLinear(unsigned long int scale)
Constructor.
Definition:
cutoff.hpp:56
Gecode::Search::CutoffLuby::n_start
static const unsigned long int n_start
Number of pre-computed luby values.
Definition:
search.hh:268
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::Search::CutoffRepeat::CutoffRepeat
CutoffRepeat(Cutoff *c, unsigned long int n)
Constructor.
Definition:
cutoff.hpp:122
Gecode::Search::CutoffAppend::~CutoffAppend
virtual ~CutoffAppend(void)
Destructor.
Definition:
cutoff.hpp:107
Gecode::Search::CutoffRepeat::cutoff
unsigned int cutoff
Definition:
search.hh:385
Gecode::Search::CutoffLuby::CutoffLuby
CutoffLuby(unsigned long int scale)
Constructor.
Definition:
cutoff.hpp:61
Gecode
Gecode toplevel namespace
Gecode::Search::CutoffMerge::c2
Cutoff * c2
Second cutoff generator.
Definition:
search.hh:364
Gecode::Search::CutoffLuby::log
static unsigned long int log(unsigned long int i)
Compute binary logarithm of i.
Definition:
cutoff.hpp:64
Gecode::Search::Cutoff::~Cutoff
virtual ~Cutoff(void)
Destructor.
Definition:
cutoff.hpp:47
Gecode::Search::CutoffConstant::CutoffConstant
CutoffConstant(unsigned long int c)
Constructor.
Definition:
cutoff.hpp:51
Gecode::Search::CutoffMerge::~CutoffMerge
virtual ~CutoffMerge(void)
Destructor.
Definition:
cutoff.hpp:116
Gecode::Search::CutoffMerge::c1
Cutoff * c1
First cutoff generator.
Definition:
search.hh:362
Gecode::Search::CutoffMerge::CutoffMerge
CutoffMerge(Cutoff *c1, Cutoff *c2)
Constructor.
Definition:
cutoff.hpp:113
Gecode::Search::Config::base
const double base
Base for geometric restart sequence.
Definition:
search.hh:122
Gecode::Search::CutoffRandom::cur
unsigned long int cur
Current value.
Definition:
search.hh:320
Gecode::Search::CutoffAppend::c1
Cutoff * c1
First cutoff generators.
Definition:
search.hh:339
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:60
Test::Int::MiniModelArithmetic::d1
Gecode::IntSet d1(v1, 7)
Gecode::Search::Cutoff
Base class for cutoff generators for restart-based meta engine.
Definition:
search.hh:172
l
NNF * l
Left subtree.
Definition:
bool-expr.cpp:244
Test::Int::MiniModelArithmetic::d2
Gecode::IntSet d2(v2, 9)
Gecode::Search::Cutoff::Cutoff
Cutoff(void)
Default constructor.
Definition:
cutoff.hpp:45
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:71
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::Search::CutoffAppend::CutoffAppend
CutoffAppend(Cutoff *c1, unsigned long int n, Cutoff *c2)
Constructor.
Definition:
cutoff.hpp:104
Gecode::exp
void exp(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
transcendental.cpp:49
Gecode::Search::CutoffGeometric::CutoffGeometric
CutoffGeometric(unsigned long int scale, double base)
Constructor.
Definition:
cutoff.hpp:87
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:238
Gecode::Search::CutoffRepeat::c
Cutoff * c
Actual cutoff generator.
Definition:
search.hh:383
Gecode::Search::CutoffAppend::c2
Cutoff * c2
Second cutoff generators.
Definition:
search.hh:341
Gecode::Search::CutoffRepeat::~CutoffRepeat
virtual ~CutoffRepeat(void)
Destructor.
Definition:
cutoff.hpp:127
Gecode::Search::CutoffRandom::CutoffRandom
CutoffRandom(unsigned int seed, unsigned long int min, unsigned long int max, unsigned long int n)
Constructor.
Definition:
cutoff.hpp:92