main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Feb 8 2021 00:00:00 for Gecode by
doxygen
1.8.20
gecode
search
support.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, 2008
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#ifndef __GECODE_SEARCH_SUPPORT_HH__
35
#define __GECODE_SEARCH_SUPPORT_HH__
36
37
#include <
gecode/search.hh
>
38
39
namespace
Gecode
{
namespace
Search {
40
42
forceinline
Space*
43
snapshot
(Space* s,
const
Options& o);
44
46
template
<
class
Worker>
47
class
WorkerToEngine
:
public
Engine
{
48
protected
:
50
Worker
w
;
51
public
:
53
WorkerToEngine
(
Space
* s,
const
Options
& o);
55
virtual
Space
*
next
(
void
);
57
virtual
Search::Statistics
statistics
(
void
)
const
;
59
virtual
bool
stopped
(
void
)
const
;
61
virtual
void
constrain
(
const
Space
&
b
);
63
virtual
void
reset
(
Space
* s);
65
virtual
NoGoods
&
nogoods
(
void
);
66
};
67
68
69
70
forceinline
Space
*
71
snapshot
(
Space
* s,
const
Options
& o) {
72
return
o.
clone
? s->
clone
() : s;
73
}
74
75
76
template
<
class
Worker>
77
WorkerToEngine<Worker>::WorkerToEngine
(
Space
* s,
const
Options
& o)
78
: w(s,o) {}
79
template
<
class
Worker>
80
Space
*
81
WorkerToEngine<Worker>::next
(
void
) {
82
return
w.next();
83
}
84
template
<
class
Worker>
85
Search::Statistics
86
WorkerToEngine<Worker>::statistics
(
void
)
const
{
87
return
w.statistics();
88
}
89
template
<
class
Worker>
90
bool
91
WorkerToEngine<Worker>::stopped
(
void
)
const
{
92
return
w.stopped();
93
}
94
template
<
class
Worker>
95
void
96
WorkerToEngine<Worker>::reset
(
Space
* s) {
97
w.reset(s);
98
}
99
template
<
class
Worker>
100
void
101
WorkerToEngine<Worker>::constrain
(
const
Space
&
b
) {
102
w.constrain(
b
);
103
}
104
template
<
class
Worker>
105
NoGoods
&
106
WorkerToEngine<Worker>::nogoods
(
void
) {
107
return
w.nogoods();
108
}
109
110
}}
111
112
#endif
113
114
// STATISTICS: search-other
Gecode::Search::Worker
Search worker statistics
Definition:
worker.hh:44
Gecode::Search::WorkerToEngine::statistics
virtual Search::Statistics statistics(void) const
Return statistics.
Definition:
support.hh:86
Gecode::Search::Options
Search engine options
Definition:
search.hh:746
Gecode::Search::WorkerToEngine::reset
virtual void reset(Space *s)
Reset engine to restart at space s.
Definition:
support.hh:96
Gecode::Search::snapshot
Space * snapshot(Space *s, const Options &o)
Clone space s dependening on options o.
Definition:
support.hh:71
search.hh
Gecode::Search::WorkerToEngine::w
Worker w
The worker to wrap into an engine.
Definition:
support.hh:50
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode
Gecode toplevel namespace
Gecode::Search::WorkerToEngine::next
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped)
Definition:
support.hh:81
Gecode::Space::clone
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
Definition:
core.hpp:3224
Gecode::NoGoods
No-goods recorded from restarts.
Definition:
core.hpp:1588
Gecode::Search::WorkerToEngine
Virtualize a worker to an engine.
Definition:
support.hh:47
Gecode::Search::Engine
Search engine implementation interface
Definition:
search.hh:899
Gecode::Search::WorkerToEngine::WorkerToEngine
WorkerToEngine(Space *s, const Options &o)
Initialization.
Definition:
support.hh:77
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Gecode::Search::WorkerToEngine::stopped
virtual bool stopped(void) const
Check whether engine has been stopped.
Definition:
support.hh:91
forceinline
#define forceinline
Definition:
config.hpp:192
Gecode::Search::Options::clone
bool clone
Whether engines create a clone when being initialized.
Definition:
search.hh:749
Gecode::Search::WorkerToEngine::constrain
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition:
support.hh:101
Gecode::Search::Statistics
Search engine statistics
Definition:
search.hh:147
Gecode::Search::WorkerToEngine::nogoods
virtual NoGoods & nogoods(void)
Return no-goods.
Definition:
support.hh:106