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
worker.hh
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, 2004
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
#ifndef __GECODE_SEARCH_WORKER_HH__
39
#define __GECODE_SEARCH_WORKER_HH__
40
41
#include <
gecode/search.hh
>
42
43
namespace
Gecode
{
namespace
Search {
44
48
class
Worker
:
public
Statistics
{
49
protected
:
51
bool
_stopped
;
53
unsigned
long
int
root_depth
;
54
public
:
56
Worker
(
void
);
58
void
start
(
void
);
60
bool
stop
(
const
Options
& o);
62
bool
stopped
(
void
)
const
;
64
void
reset
(
unsigned
long
int
d
=0);
66
void
stack_depth
(
unsigned
long
int
d
);
68
unsigned
long
int
steal_depth
(
unsigned
long
int
d
)
const
;
69
};
70
71
72
73
forceinline
74
Worker::Worker
(
void
)
75
: _stopped(false), root_depth(0) {}
76
77
forceinline
void
78
Worker::start
(
void
) {
79
_stopped
=
false
;
80
}
81
82
forceinline
bool
83
Worker::stop
(
const
Options
& o) {
84
if
(o.
stop
== NULL)
85
return
false
;
86
_stopped
|= o.
stop
->
stop
(*
this
,o);
87
return
_stopped
;
88
}
89
90
forceinline
bool
91
Worker::stopped
(
void
)
const
{
92
return
_stopped
;
93
}
94
95
forceinline
void
96
Worker::reset
(
unsigned
long
int
d
) {
97
Statistics::reset
();
98
root_depth
=
d
;
99
if
(
depth
<
d
)
100
depth
=
d
;
101
}
102
103
forceinline
void
104
Worker::stack_depth
(
unsigned
long
int
d
) {
105
if
(
depth
<
root_depth
+
d
)
106
depth
=
root_depth
+
d
;
107
}
108
109
forceinline
unsigned
long
int
110
Worker::steal_depth
(
unsigned
long
int
d
)
const
{
111
return
root_depth
+
d
;
112
}
113
114
}}
115
116
#endif
117
118
// STATISTICS: search-other
Gecode::Search::Worker
Search worker statistics
Definition:
worker.hh:48
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Search::Options
Search engine options
Definition:
search.hh:446
Gecode::Search::Worker::stop
bool stop(const Options &o)
Check whether engine must be stopped.
Definition:
worker.hh:83
search.hh
Gecode::Search::Stop::stop
virtual bool stop(const Statistics &s, const Options &o)=0
Stop search, if returns true.
Gecode::Search::Statistics::depth
unsigned long int depth
Maximum depth of search stack.
Definition:
search.hh:147
Gecode
Gecode toplevel namespace
Gecode::Search::Worker::Worker
Worker(void)
Initialize.
Definition:
worker.hh:74
Gecode::Search::Options::stop
Stop * stop
Stop object for stopping search.
Definition:
search.hh:469
Gecode::Search::Worker::root_depth
unsigned long int root_depth
Depth of root node (for work stealing)
Definition:
worker.hh:53
Gecode::Search::Worker::steal_depth
unsigned long int steal_depth(unsigned long int d) const
Return steal depth.
Definition:
worker.hh:110
Gecode::Search::Worker::_stopped
bool _stopped
Whether engine has been stopped.
Definition:
worker.hh:51
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::Search::Worker::stack_depth
void stack_depth(unsigned long int d)
Record stack depth d.
Definition:
worker.hh:104
Gecode::Search::Worker::start
void start(void)
Reset stop information.
Definition:
worker.hh:78
Gecode::Search::Statistics::reset
void reset(void)
Reset.
Definition:
statistics.hpp:43
Gecode::Search::Worker::stopped
bool stopped(void) const
Check whether engine has been stopped.
Definition:
worker.hh:91
Gecode::Search::Statistics
Search engine statistics
Definition:
search.hh:140