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
set
channel.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Denys Duchier <denys.duchier@univ-orleans.fr>
5
* Guido Tack <tack@gecode.org>
6
* Christian Schulte <schulte@gecode.org>
7
*
8
* Copyright:
9
* Denys Duchier, 2011
10
* Guido Tack, 2004
11
* Christian Schulte, 2004
12
*
13
* Last modified:
14
* $Date: 2016-05-23 22:18:23 +0200 (Mon, 23 May 2016) $ by $Author: schulte $
15
* $Revision: 15073 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
#include <
gecode/set.hh
>
43
44
#include <
gecode/set/channel.hh
>
45
46
namespace
Gecode
{
47
48
void
49
channelSorted
(
Home
home,
const
IntVarArgs
&
x
,
SetVar
y
) {
50
GECODE_POST
;
51
ViewArray<Int::IntView>
xa(home,
x
);
52
GECODE_ES_FAIL
(
Set::Channel::ChannelSorted<Set::SetView>::post
(home,
y
,xa));
53
}
54
55
void
56
channel
(
Home
home,
const
IntVarArgs
&
x
,
const
SetVarArgs
&
y
) {
57
GECODE_POST
;
58
ViewArray<Int::CachedView<Int::IntView>
> xa(home,
x
.size());
59
for
(
int
i
=
x
.size();
i
--;)
60
new
(&xa[
i
])
Int::CachedView<Int::IntView>
(
x
[
i
]);
61
ViewArray<Set::CachedView<Set::SetView>
> ya(home,
y
.size());
62
for
(
int
i
=
y
.size();
i
--;)
63
new
(&ya[
i
])
Set::CachedView<Set::SetView>
(
y
[
i
]);
64
GECODE_ES_FAIL
((
Set::Channel::ChannelInt<Set::SetView>::post
(home,xa,ya)));
65
}
66
67
void
68
channel
(
Home
home,
const
BoolVarArgs
&
x
,
SetVar
y
) {
69
GECODE_POST
;
70
ViewArray<Int::BoolView>
xv(home,
x
);
71
GECODE_ES_FAIL
((
Set::Channel::ChannelBool<Set::SetView>
72
::
post
(home,xv,
y
)));
73
}
74
75
void
76
channel
(
Home
home,
const
SetVarArgs
&
x
,
const
SetVarArgs
&
y
)
77
{
78
GECODE_POST
;
79
ViewArray<Set::CachedView<Set::SetView>
> xa(home,
x
.size());
80
for
(
int
i
=
x
.size();
i
--;)
81
new
(&xa[
i
])
Int::CachedView<Set::SetView>
(
x
[
i
]);
82
ViewArray<Set::CachedView<Set::SetView>
> ya(home,
y
.size());
83
for
(
int
i
=
y
.size();
i
--;)
84
new
(&ya[
i
])
Set::CachedView<Set::SetView>
(
y
[
i
]);
85
GECODE_ES_FAIL
((
Set::Channel::ChannelSet<Set::SetView>::post
(home,xa,ya)));
86
}
87
88
}
89
90
// STATISTICS: set-post
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:784
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:107
Gecode::Set::Channel::ChannelSorted
Propagator for the sorted channel constraint
Definition:
channel.hh:64
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:639
Gecode::channelSorted
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
Definition:
channel.cpp:49
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::SetVarArgs
Passing set variables.
Definition:
set.hh:492
Gecode
Gecode toplevel namespace
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:693
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::Set::Channel::ChannelInt
Propagator for channelling between variable-value-dual models
Definition:
channel.hh:109
Gecode::Set::Channel::ChannelSet
Propagator for successors/predecessors channelling
Definition:
channel.hh:230
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
trace-filter.cpp:142
Gecode::SetVar
Set variables
Definition:
set.hh:131
Gecode::Set::Channel::ChannelBool
Propagator for channelling between set variable and its characteristic function
Definition:
channel.hh:152
Gecode::channel
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition:
channel.cpp:45
channel.hh
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition:
macros.hpp:44
set.hh
Gecode::Int::CachedView
Cached integer view.
Definition:
view.hpp:1107
Gecode::ViewArray< Int::IntView >