main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Jan 10 2020 11:38:25 for Gecode by
doxygen
1.8.16
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
* 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
40
forceinline
41
Cutoff::Cutoff
(
void
) {}
42
forceinline
43
Cutoff::~Cutoff
(
void
) {}
44
45
46
forceinline
47
CutoffConstant::CutoffConstant
(
unsigned
long
int
c0)
48
:
c
(c0) {}
49
50
51
forceinline
52
CutoffLinear::CutoffLinear
(
unsigned
long
int
s)
53
: scale(s),
n
(0) {}
54
55
56
forceinline
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
}
77
GECODE_NEVER
;
78
return
0;
79
}
80
81
82
forceinline
83
CutoffGeometric::CutoffGeometric
(
unsigned
long
int
scale0,
double
base0)
84
:
n
(1.0), scale(static_cast<double>(scale0)),
base
(base0) {}
85
86
87
forceinline
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
99
forceinline
100
CutoffAppend::CutoffAppend
(
Cutoff
*
d1
,
unsigned
long
int
n0,
Cutoff
*
d2
)
101
: c1(
d1
), c2(
d2
),
n
(n0) {}
102
forceinline
103
CutoffAppend::~CutoffAppend
(
void
) {
104
delete
c1
;
delete
c2
;
105
}
106
107
108
forceinline
109
CutoffMerge::CutoffMerge
(
Cutoff
*
d1
,
Cutoff
*
d2
)
110
: c1(
d1
), c2(
d2
) {}
111
forceinline
112
CutoffMerge::~CutoffMerge
(
void
) {
113
delete
c1
;
delete
c2
;
114
}
115
116
117
forceinline
118
CutoffRepeat::CutoffRepeat
(
Cutoff
* c1,
unsigned
long
int
n0)
119
:
c
(c1),
i
(0),
n
(n0) {
120
cutoff
= (*c)();
121
}
122
forceinline
123
CutoffRepeat::~CutoffRepeat
(
void
) {
124
delete
c
;
125
}
126
127
}}
128
129
// STATISTICS: search-other
Test::Float::Arithmetic::step
const Gecode::FloatNum step
Definition:
arithmetic.cpp:785
Gecode::Search::CutoffLuby::luby
static unsigned long int luby(unsigned long int i)
Compute Luby number for step i.
Definition:
cutoff.hpp:68
Gecode::Search::CutoffLuby::i
unsigned long int i
Iteration number.
Definition:
search.hh:564
Gecode::Search::CutoffLuby::start
static unsigned long int start[n_start]
Precomputed luby-values.
Definition:
search.hh:570
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:49
Gecode::Search::CutoffLinear::CutoffLinear
CutoffLinear(unsigned long int scale)
Constructor.
Definition:
cutoff.hpp:52
Gecode::Search::CutoffLuby::n_start
static const unsigned long int n_start
Number of pre-computed luby values.
Definition:
search.hh:568
Gecode::Search::CutoffRepeat::CutoffRepeat
CutoffRepeat(Cutoff *c, unsigned long int n)
Constructor.
Definition:
cutoff.hpp:118
Gecode::Search::CutoffAppend::~CutoffAppend
virtual ~CutoffAppend(void)
Destructor.
Definition:
cutoff.hpp:103
Gecode::Search::CutoffRepeat::cutoff
unsigned int cutoff
Definition:
search.hh:685
Gecode::Search::CutoffLuby::CutoffLuby
CutoffLuby(unsigned long int scale)
Constructor.
Definition:
cutoff.hpp:57
Gecode
Gecode toplevel namespace
Gecode::Search::CutoffMerge::c2
Cutoff * c2
Second cutoff generator.
Definition:
search.hh:664
Gecode::Search::CutoffLuby::log
static unsigned long int log(unsigned long int i)
Compute binary logarithm of i.
Definition:
cutoff.hpp:60
Gecode::Search::Cutoff::~Cutoff
virtual ~Cutoff(void)
Destructor.
Definition:
cutoff.hpp:43
Gecode::Search::CutoffConstant::CutoffConstant
CutoffConstant(unsigned long int c)
Constructor.
Definition:
cutoff.hpp:47
Gecode::Search::CutoffMerge::~CutoffMerge
virtual ~CutoffMerge(void)
Destructor.
Definition:
cutoff.hpp:112
Gecode::Search::CutoffMerge::c1
Cutoff * c1
First cutoff generator.
Definition:
search.hh:662
Gecode::Search::CutoffMerge::CutoffMerge
CutoffMerge(Cutoff *c1, Cutoff *c2)
Constructor.
Definition:
cutoff.hpp:109
Gecode::Search::Config::base
const double base
Base for geometric restart sequence.
Definition:
search.hh:126
Gecode::Search::CutoffRandom::cur
unsigned long int cur
Current value.
Definition:
search.hh:620
Gecode::Search::CutoffAppend::c1
Cutoff * c1
First cutoff generators.
Definition:
search.hh:639
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition:
macros.hpp:56
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:472
l
NNF * l
Left subtree.
Definition:
bool-expr.cpp:240
Test::Int::MiniModelArithmetic::d2
Gecode::IntSet d2(v2, 9)
std
Definition:
flatzinc.cpp:52
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Search::Cutoff::Cutoff
Cutoff(void)
Default constructor.
Definition:
cutoff.hpp:41
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:67
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:100
Gecode::exp
void exp(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
transcendental.cpp:45
Gecode::Search::CutoffGeometric::CutoffGeometric
CutoffGeometric(unsigned long int scale, double base)
Constructor.
Definition:
cutoff.hpp:83
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::Search::CutoffRepeat::c
Cutoff * c
Actual cutoff generator.
Definition:
search.hh:683
Gecode::Search::CutoffAppend::c2
Cutoff * c2
Second cutoff generators.
Definition:
search.hh:641
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::Search::CutoffRepeat::~CutoffRepeat
virtual ~CutoffRepeat(void)
Destructor.
Definition:
cutoff.hpp:123
Gecode::Search::CutoffRandom::CutoffRandom
CutoffRandom(unsigned int seed, unsigned long int min, unsigned long int max, unsigned long int n)
Constructor.
Definition:
cutoff.hpp:88