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
var.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, 2008
8
*
9
* Last modified:
10
* $Date: 2017-02-23 06:10:29 +0100 (Thu, 23 Feb 2017) $ by $Author: schulte $
11
* $Revision: 15476 $
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
{
39
44
class
Var
{};
45
50
template
<
class
VarImp>
51
class
VarImpVar
:
public
Var
{
52
protected
:
54
VarImp
*
x
;
56
VarImpVar
(
void
);
58
VarImpVar
(
VarImp
*
y
);
59
public
:
61
typedef
VarImp
VarImpType
;
63
64
VarImp
*
varimp
(
void
)
const
;
67
unsigned
int
degree
(
void
)
const
;
69
double
afc
(
void
)
const
;
71
73
74
bool
assigned
(
void
)
const
;
77
79
80
void
update
(
Space
& home,
bool
share,
VarImpVar<VarImp>
&
y
);
83
85
86
bool
same
(
const
VarImpVar<VarImp>
&
y
)
const
;
89
bool
before
(
const
VarImpVar<VarImp>
&
y
)
const
;
91
};
92
93
94
/*
95
* Variable: contains a pointer to a variable implementation
96
*
97
*/
98
template
<
class
VarImp>
99
forceinline
100
VarImpVar<VarImp>::VarImpVar
(
void
)
101
:
x
(NULL) {}
102
template
<
class
VarImp>
103
forceinline
104
VarImpVar<VarImp>::VarImpVar
(
VarImp
*
y
)
105
:
x
(
y
) {}
106
template
<
class
VarImp>
107
forceinline
VarImp
*
108
VarImpVar<VarImp>::varimp
(
void
)
const
{
109
return
x
;
110
}
111
template
<
class
VarImp>
112
forceinline
unsigned
int
113
VarImpVar<VarImp>::degree
(
void
)
const
{
114
return
x
->degree();
115
}
116
template
<
class
VarImp>
117
forceinline
double
118
VarImpVar<VarImp>::afc
(
void
)
const
{
119
return
x
->afc();
120
}
121
template
<
class
VarImp>
122
forceinline
bool
123
VarImpVar<VarImp>::assigned
(
void
)
const
{
124
return
x
->assigned();
125
}
126
template
<
class
VarImp>
127
forceinline
void
128
VarImpVar<VarImp>::update
(
Space
& home,
bool
share,
VarImpVar<VarImp>
&
y
) {
129
x
=
y
.
x
->
copy
(home,share);
130
}
131
template
<
class
VarImp>
132
forceinline
bool
133
VarImpVar<VarImp>::same
(
const
VarImpVar<VarImp>
&
y
)
const
{
134
return
varimp() ==
y
.
varimp
();
135
}
136
template
<
class
VarImp>
137
forceinline
bool
138
VarImpVar<VarImp>::before
(
const
VarImpVar<VarImp>
&
y
)
const
{
139
return
varimp() <
y
.
varimp
();
140
}
141
142
}
143
144
// STATISTICS: kernel-var
Gecode::VarImpVar::degree
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition:
var.hpp:113
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:784
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Int::Precede::assigned
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition:
single.hpp:47
Gecode::Set::SetVarImp::copy
SetVarImp * copy(Space &home, bool share)
Return copy of this variable.
Definition:
set.hpp:428
Gecode::Int::BinPacking::same
bool same(const Item &i, const Item &j)
Whether two items are the same.
Definition:
propagate.hpp:76
Gecode::VarImpVar::same
bool same(const VarImpVar< VarImp > &y) const
Test whether variable is the same as y.
Definition:
var.hpp:133
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::VarImpVar::assigned
bool assigned(void) const
Test whether view is assigned.
Definition:
var.hpp:123
Gecode::VarImpVar::update
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition:
var.hpp:128
Gecode::Var
Base class for variables.
Definition:
var.hpp:44
Gecode
Gecode toplevel namespace
Gecode::VarImpVar::x
VarImp * x
Pointer to variable implementation.
Definition:
var.hpp:54
x
Node * x
Pointer to corresponding Boolean expression node.
Definition:
bool-expr.cpp:253
Gecode::VarImpVar::VarImpType
VarImp VarImpType
The variable implementation type corresponding to the variable.
Definition:
var.hpp:61
Gecode::VarImpVar::varimp
VarImp * varimp(void) const
Return variable implementation of variable.
Definition:
var.hpp:108
Gecode::VarImpVar::before
bool before(const VarImpVar< VarImp > &y) const
Test whether variable comes before y (arbitrary order)
Definition:
var.hpp:138
Gecode::VarImpVar::VarImpVar
VarImpVar(void)
Default constructor.
Definition:
var.hpp:100
Test::afc
AFC afc
Definition:
afc.cpp:139
Gecode::Int::BinPacking::before
bool before(const Item &i, const Item &j)
Test whether one item is before another.
Definition:
propagate.hpp:80
Gecode::VarImpVar
Variables as interfaces to variable implementations.
Definition:
var.hpp:51
Gecode::VarImp
Base-class for variable implementations.
Definition:
core.hpp:234
Gecode::VarImpVar::afc
double afc(void) const
Return accumulated failure count.
Definition:
var.hpp:118