main page
modules
namespaces
classes
files
Gecode home
Generated on Sat May 25 2013 18:00:40 for Gecode by
doxygen
1.8.3.1
gecode
search
meta
rbs.cpp
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
* Copyright:
7
* Guido Tack, 2012
8
*
9
* Last modified:
10
* $Date: 2013-03-08 09:52:45 +0100 (Fri, 08 Mar 2013) $ by $Author: schulte $
11
* $Revision: 13481 $
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
39
#include <
gecode/search/meta/rbs.hh
>
40
41
namespace
Gecode {
namespace
Search {
namespace
Meta {
42
43
Space
*
44
RBS::next
(
void
) {
45
while
(
true
) {
46
Space
*
n
= e->
next
();
47
unsigned
long
int
i
= stop->m_stat.
restart
;
48
if
(n != NULL) {
49
master->
constrain
(*n);
50
master->
master
(i,n);
51
if
(master->
status
(stop->m_stat) ==
SS_FAILED
) {
52
delete
master;
53
master = NULL;
54
e->
reset
(NULL);
55
}
else
{
56
Space
* slave = master;
57
master = master->
clone
(shared);
58
slave->
slave
(i,n);
59
e->
reset
(slave);
60
}
61
return
n
;
62
}
else
if
(e->
stopped
() && stop->
enginestopped
()) {
63
master->
master
(i,NULL);
64
long
unsigned
int
nl = (*co)();
65
stop->
limit
(e->
statistics
(),nl);
66
if
(master->
status
(stop->m_stat) ==
SS_FAILED
)
67
return
NULL;
68
Space
* slave = master;
69
master = master->
clone
(shared);
70
slave->
slave
(i,n);
71
e->
reset
(slave);
72
}
else
{
73
return
NULL;
74
}
75
}
76
GECODE_NEVER
;
77
return
NULL;
78
}
79
80
Search::Statistics
81
RBS::statistics
(
void
)
const
{
82
return
stop->
metastatistics
()+e->
statistics
();
83
}
84
85
bool
86
RBS::stopped
(
void
)
const
{
87
/*
88
* What might happen during parallel search is that the
89
* engine has been stopped but the meta engine has not, so
90
* the meta engine does not perform a restart. However the
91
* invocation of next will do so and no restart will be
92
* missed.
93
*/
94
return
e->
stopped
();
95
}
96
97
void
98
RBS::reset
(
Space
*) {
99
}
100
101
RBS::~RBS
(
void
) {
102
// Deleting e also deletes stop
103
delete
e;
104
delete
master;
105
delete
co;
106
}
107
108
}}}
109
110
// STATISTICS: search-other