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
int
element
pair.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, 2009
8
*
9
* Last modified:
10
* $Date: 2009-10-29 14:58:00 +0100 (Thu, 29 Oct 2009) $ by $Author: schulte $
11
* $Revision: 10000 $
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 <
gecode/int/rel.hh
>
39
40
namespace
Gecode
{
namespace
Int {
namespace
Element {
41
42
forceinline
43
Pair::Pair
(
Home
home,
IntView
x0,
IntView
x1,
IntView
x2,
int
w0)
44
:
TernaryPropagator
<
IntView
,
PC_INT_DOM
>(home,x0,x1,x2), w(w0) {}
45
46
inline
ExecStatus
47
Pair::post
(
Home
home,
IntView
x0,
IntView
x1,
IntView
x2,
48
int
w,
int
h) {
49
GECODE_ME_CHECK
(
x0
.
gq
(home,0));
GECODE_ME_CHECK
(
x0
.
le
(home,
w
));
50
GECODE_ME_CHECK
(
x1
.
gq
(home,0));
GECODE_ME_CHECK
(
x1
.
le
(home,h));
51
GECODE_ME_CHECK
(
x2
.
gq
(home,0));
GECODE_ME_CHECK
(
x2
.
le
(home,
w
*h));
52
if
(
x0
.
assigned
() &&
x1
.
assigned
()) {
53
GECODE_ME_CHECK
(
x2
.
eq
(home,
x0
.
val
()+
w
*
x1
.
val
()));
54
}
else
if
(
x1
.
assigned
()) {
55
OffsetView
x0x1w(
x0
,
x1
.
val
()*
w
);
56
return
Rel::EqDom<OffsetView,IntView>::post
(home,x0x1w,
x2
);
57
}
else
if
(
x2
.
assigned
()) {
58
GECODE_ME_CHECK
(
x0
.
eq
(home,
x2
.
val
() %
w
));
59
GECODE_ME_CHECK
(
x1
.
eq
(home,
static_cast<
int
>
(
x2
.
val
() /
w
)));
60
}
else
{
61
assert(!
shared
(
x0
,
x2
) && !
shared
(
x1
,
x2
));
62
(void)
new
(home)
Pair
(home,
x0
,
x1
,
x2
,
w
);
63
}
64
return
ES_OK
;
65
}
66
67
forceinline
68
Pair::Pair
(
Space
& home,
bool
share,
Pair
&
p
)
69
:
TernaryPropagator
<
IntView
,
PC_INT_DOM
>(home,share,
p
), w(
p
.w) {}
70
71
}}}
72
73
// STATISTICS: int-prop
74
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::VarImpView::assigned
bool assigned(void) const
Test whether view is assigned.
Gecode::TernaryPropagator< IntView, PC_INT_DOM >::x1
IntView x1
Definition:
propagator.hpp:122
Gecode::Int::Element::Pair::Pair
Pair(Space &home, bool share, Pair &p)
Constructor for cloning p.
Definition:
pair.hpp:68
Gecode::Int::Element::Pair
Domain consistent pair propagator.
Definition:
element.hh:301
Gecode::Int::Rel::EqDom::post
static ExecStatus post(Home home, View0 x0, View1 x1)
Post domain consistent propagator .
Definition:
eq.hpp:180
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Int::Element::Pair::w
int w
Width.
Definition:
element.hh:308
Gecode::Int::Element::Pair::post
static ExecStatus post(Home home, IntView x0, IntView x1, IntView x2, int w, int h)
Post propagator .
Definition:
pair.hpp:47
Gecode::TernaryPropagator< IntView, PC_INT_DOM >::x2
IntView x2
Definition:
propagator.hpp:122
Gecode
Gecode toplevel namespace
Gecode::Int::IntView::val
int val(void) const
Return assigned value (only if assigned)
Definition:
int.hpp:70
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::TernaryPropagator
Ternary propagator.
Definition:
propagator.hpp:119
Gecode::TernaryPropagator< IntView, PC_INT_DOM >::x0
IntView x0
Three views.
Definition:
propagator.hpp:122
Gecode::Int::OffsetView
Offset integer view.
Definition:
view.hpp:422
rel.hh
Gecode::Int::Count::shared
bool shared(const IntSet &, VX)
Definition:
view-base.hpp:122
Gecode::Int::IntView
Integer view for integer variables.
Definition:
view.hpp:129
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:56
Gecode::Int::IntView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition:
int.hpp:133
Gecode::Int::PC_INT_DOM
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition:
var-type.hpp:100
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:544
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236
Gecode::Int::IntView::le
ModEvent le(Space &home, int n)
Restrict domain values to be less than n.
Definition:
int.hpp:124
Gecode::Int::IntView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition:
int.hpp:160
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:540