main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:31 for Gecode by
doxygen
1.8.4
gecode
search
stop.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2006
8
*
9
* Last modified:
10
* $Date: 2013-10-30 15:42:34 +0100 (Wed, 30 Oct 2013) $ by $Author: schulte $
11
* $Revision: 14037 $
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
/*
41
* Base class
42
*
43
*/
44
forceinline
45
Stop::Stop
(
void
) {}
46
forceinline
47
Stop::~Stop
(
void
) {}
48
forceinline
void
*
49
Stop::operator
new
(
size_t
s) {
50
return
heap
.
ralloc
(s);
51
}
52
forceinline
void
53
Stop::operator
delete
(
void
*
p
) {
54
heap
.
rfree
(
p
);
55
}
56
57
58
59
60
/*
61
* Stopping for node limit
62
*
63
*/
64
65
forceinline
66
NodeStop::NodeStop
(
unsigned
long
int
l0) :
l
(l0) {}
67
68
forceinline
unsigned
long
int
69
NodeStop::limit
(
void
)
const
{
70
return
l
;
71
}
72
73
forceinline
void
74
NodeStop::limit
(
unsigned
long
int
l0) {
75
l
=l0;
76
}
77
78
79
/*
80
* Stopping for failure limit
81
*
82
*/
83
84
forceinline
85
FailStop::FailStop
(
unsigned
long
int
l0) :
l
(l0) {}
86
87
forceinline
unsigned
long
int
88
FailStop::limit
(
void
)
const
{
89
return
l
;
90
}
91
92
forceinline
void
93
FailStop::limit
(
unsigned
long
int
l0) {
94
l
=l0;
95
}
96
97
98
/*
99
* Stopping for time limit
100
*
101
*/
102
103
forceinline
104
TimeStop::TimeStop
(
unsigned
long
int
l0)
105
:
l
(l0) {
106
t
.
start
();
107
}
108
109
forceinline
unsigned
long
int
110
TimeStop::limit
(
void
)
const
{
111
return
l
;
112
}
113
114
forceinline
void
115
TimeStop::limit
(
unsigned
long
int
l0) {
116
l
=l0;
117
}
118
119
forceinline
void
120
TimeStop::reset
(
void
) {
121
t
.
start
();
122
}
123
124
125
/*
126
* Stopping for meta search engines
127
*
128
*/
129
130
forceinline
131
MetaStop::MetaStop
(
Stop
* s)
132
: e_stop(new
FailStop
(0)), m_stop(s), e_stopped(false) {}
133
134
forceinline
void
135
MetaStop::limit
(
const
Search::Statistics
& s,
unsigned
long
int
l
) {
136
m_stat += s;
137
e_stopped =
false
;
138
e_stop->
limit
(l);
139
}
140
141
forceinline
void
142
MetaStop::update
(
const
Search::Statistics
& s) {
143
m_stat += s;
144
}
145
146
forceinline
Stop
*
147
MetaStop::enginestop
(
void
)
const
{
148
return
e_stop;
149
}
150
151
forceinline
bool
152
MetaStop::enginestopped
(
void
)
const
{
153
return
e_stopped;
154
}
155
156
forceinline
Statistics
157
MetaStop::metastatistics
(
void
)
const
{
158
return
m_stat;
159
}
160
161
forceinline
162
MetaStop::~MetaStop
(
void
) {
163
delete
e_stop;
164
delete
m_stop;
165
}
166
167
}}
168
169
// STATISTICS: search-other