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
kernel
brancher-print.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, 2017
8
*
9
* Last modified:
10
* $Date: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
11
* $Revision: 15623 $
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
#include <functional>
39
40
namespace
Gecode
{
41
43
template
<
class
Var,
class
Val>
44
using
VarValPrint
= std::function<void(
const
Space& home,
const
Brancher&
b
,
45
unsigned
int
a
,
46
Var
x
,
int
i
,
const
Val& m,
47
std::ostream& o)>;
48
50
template
<
class
View,
class
Val>
51
class
BrancherPrint
{
52
public
:
54
typedef
typename
View::VarType
Var
;
55
protected
:
56
SharedData<VarValPrint<Var,Val>
>
p
;
57
public
:
59
BrancherPrint
(
VarValPrint<Var,Val>
vvp);
61
BrancherPrint
(
Space
& home,
bool
shared
,
BrancherPrint
& bp);
63
operator
bool(
void
)
const
;
65
void
operator ()
(
const
Space
& home,
const
Brancher
&
b
,
66
unsigned
int
a
,
67
View
x
,
int
i
,
const
Val& m,
68
std::ostream& o)
const
;
70
bool
notice
(
void
)
const
;
72
void
dispose
(
Space
& home);
73
};
74
76
template
<
class
View,
class
Val>
77
class
BrancherNoPrint
{
78
public
:
80
typedef
typename
View::VarType
Var
;
81
public
:
83
BrancherNoPrint
(
VarValPrint<Var,Val>
vvp);
85
BrancherNoPrint
(
Space
& home,
bool
shared
,
BrancherNoPrint
& bp);
87
operator
bool(
void
)
const
;
89
void
operator ()
(
const
Space
& home,
const
Brancher
&
b
,
90
unsigned
int
a
,
91
View
x
,
int
i
,
const
Val& m,
92
std::ostream& o)
const
;
94
bool
notice
(
void
)
const
;
96
void
dispose
(
Space
& home);
97
};
98
99
100
101
template
<
class
View,
class
Val>
102
forceinline
103
BrancherPrint<View,Val>::BrancherPrint
(
VarValPrint<Var,Val>
vvp) :
p
(vvp) {
104
if
(!vvp)
105
throw
Gecode::InvalidFunction
(
"BrancherPrint::BrancherPrint"
);
106
}
107
108
template
<
class
View,
class
Val>
109
forceinline
110
BrancherPrint<View,Val>::BrancherPrint
(
Space
& home,
bool
shared
,
111
BrancherPrint<View,Val>
& bp) {
112
p
.update(home,
shared
,bp.
p
);
113
}
114
115
template
<
class
View,
class
Val>
116
forceinline
117
BrancherPrint<View,Val>::operator
bool(
void
)
const
{
118
return
true
;
119
}
120
121
template
<
class
View,
class
Val>
122
forceinline
void
123
BrancherPrint<View,Val>::operator ()
(
const
Space
& home,
const
Brancher
&
b
,
124
unsigned
int
a
,
125
View
x
,
int
i
,
const
Val& m,
126
std::ostream& o)
const
{
127
GECODE_VALID_FUNCTION
(
p
());
128
Var
xv(
x
.
varimp
());
129
p
()(home,
b
,
a
,xv,
i
,m,o);
130
}
131
132
template
<
class
View,
class
Val>
133
forceinline
bool
134
BrancherPrint<View,Val>::notice
(
void
)
const
{
135
return
true
;
136
}
137
138
template
<
class
View,
class
Val>
139
forceinline
void
140
BrancherPrint<View,Val>::dispose
(
Space
&) {
141
p
.~SharedData<
VarValPrint<Var,Val>
>();
142
}
143
144
145
template
<
class
View,
class
Val>
146
forceinline
147
BrancherNoPrint<View,Val>::BrancherNoPrint
(
VarValPrint<Var,Val>
vvp) {
148
assert(!vvp);
149
}
150
151
template
<
class
View,
class
Val>
152
forceinline
153
BrancherNoPrint<View,Val>::BrancherNoPrint
(
Space
&,
bool
,
154
BrancherNoPrint<View,Val>
&) {}
155
156
template
<
class
View,
class
Val>
157
forceinline
158
BrancherNoPrint<View,Val>::operator
bool(
void
)
const
{
159
return
false
;
160
}
161
162
template
<
class
View,
class
Val>
163
forceinline
void
164
BrancherNoPrint<View,Val>::operator ()
(
const
Space
&,
const
Brancher
&,
165
unsigned
int
,
166
View,
int
,
const
Val&,
167
std::ostream&)
const
{}
168
template
<
class
View,
class
Val>
169
forceinline
bool
170
BrancherNoPrint<View,Val>::notice
(
void
)
const
{
171
return
false
;
172
}
173
174
template
<
class
View,
class
Val>
175
forceinline
void
176
BrancherNoPrint<View,Val>::dispose
(
Space
&) {}
177
178
}
179
180
// STATISTICS: kernel-branch
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::BrancherNoPrint::Var
View::VarType Var
The corresponding variable type.
Definition:
brancher-print.hpp:80
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::BrancherPrint::Var
View::VarType Var
The corresponding variable type.
Definition:
brancher-print.hpp:54
Gecode::BrancherNoPrint::operator()
void operator()(const Space &home, const Brancher &b, unsigned int a, View x, int i, const Val &m, std::ostream &o) const
Invoke print function.
Definition:
brancher-print.hpp:164
Gecode::SharedData
Class for sharing data between spaces.
Definition:
shared-data.hpp:42
Gecode::BrancherNoPrint
Class without print function.
Definition:
brancher-print.hpp:77
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::BrancherNoPrint::dispose
void dispose(Space &home)
Delete.
Definition:
brancher-print.hpp:176
GECODE_VALID_FUNCTION
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition:
macros.hpp:98
Gecode::BrancherPrint::BrancherPrint
BrancherPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition:
brancher-print.hpp:103
Gecode::BrancherPrint
Class storing a print function.
Definition:
brancher-print.hpp:51
Gecode
Gecode toplevel namespace
Gecode::BrancherPrint::dispose
void dispose(Space &home)
Delete.
Definition:
brancher-print.hpp:140
Gecode::BrancherPrint::p
SharedData< VarValPrint< Var, Val > > p
Definition:
brancher-print.hpp:56
Gecode::VarImpVar::varimp
VarImp * varimp(void) const
Return variable implementation of variable.
Definition:
var.hpp:108
Gecode::Brancher
Base-class for branchers.
Definition:
core.hpp:1446
a
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
b
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Gecode::BrancherPrint::operator()
void operator()(const Space &home, const Brancher &b, unsigned int a, View x, int i, const Val &m, std::ostream &o) const
Invoke print function.
Definition:
brancher-print.hpp:123
Gecode::BrancherPrint::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition:
brancher-print.hpp:134
Gecode::InvalidFunction
Exception: invalid function
Definition:
exception.hpp:118
Gecode::Int::Count::shared
bool shared(const IntSet &, VX)
Definition:
view-base.hpp:122
Gecode::BrancherNoPrint::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition:
brancher-print.hpp:170
Gecode::VarValPrint
std::function< void(const Space &home, const Brancher &b, unsigned int a, Var x, int i, const Val &m, std::ostream &o)> VarValPrint
Function type for printing variable and value selection.
Definition:
brancher-print.hpp:47
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236
Gecode::BrancherNoPrint::BrancherNoPrint
BrancherNoPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition:
brancher-print.hpp:147