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
set
precede.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christopher Mears <Chris.Mears@monash.edu>
5
*
6
* Contributing authors:
7
* Christian Schulte <schulte@gecode.org>
8
* Guido Tack <tack@gecode.org>
9
*
10
* Copyright:
11
* Christopher Mears, 2011
12
* Christian Schulte, 2011
13
* Guido Tack, 2011
14
*
15
* This file is part of Gecode, the generic constraint
16
* development environment:
17
* http://www.gecode.org
18
*
19
* Permission is hereby granted, free of charge, to any person obtaining
20
* a copy of this software and associated documentation files (the
21
* "Software"), to deal in the Software without restriction, including
22
* without limitation the rights to use, copy, modify, merge, publish,
23
* distribute, sublicense, and/or sell copies of the Software, and to
24
* permit persons to whom the Software is furnished to do so, subject to
25
* the following conditions:
26
*
27
* The above copyright notice and this permission notice shall be
28
* included in all copies or substantial portions of the Software.
29
*
30
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
*
38
*/
39
40
#include <
gecode/set/precede.hh
>
41
42
namespace
Gecode
{
43
44
void
45
precede
(
Home
home,
const
SetVarArgs
&
x
,
int
s,
int
t
) {
46
using namespace
Set;
47
Limits::check
(s,
"Set::precede"
);
48
Limits::check
(
t
,
"Set::precede"
);
49
GECODE_POST
;
50
51
ViewArray<SetView>
y
(home,
x
);
52
GECODE_ES_FAIL
(
Precede::Single<SetView>::post
(home,
y
, s,
t
));
53
}
54
55
void
56
precede
(
Home
home,
const
SetVarArgs
&
x
,
const
IntArgs
&
c
) {
57
using namespace
Set;
58
if
(
c
.
size
() < 2)
59
return
;
60
for
(
int
i
=
c
.
size
();
i
--; )
61
Limits::check
(
c
[
i
],
"Set::precede"
);
62
GECODE_POST
;
63
64
for
(
int
i
=
c
.
size
()-1;
i
--; ) {
65
ViewArray<SetView>
y
(home,
x
);
66
GECODE_ES_FAIL
(
Precede::Single<SetView>::post
(home,
y
,
c
[
i
],
c
[
i
+1]));
67
}
68
}
69
70
}
71
72
// STATISTICS: set-post
precede.hh
Gecode::Int::Precede::Single
Single value precedence propagator.
Definition:
precede.hh:61
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:767
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:103
Gecode::SetVarArgs
Passing set variables.
Definition:
set.hh:488
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode
Gecode toplevel namespace
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::FloatVal::size
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
Definition:
val.hpp:78
Gecode::Set::Limits::check
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l.
Definition:
limits.hpp:37
Gecode::precede
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel)
Post propagator that s precedes t in x.
Definition:
precede.cpp:43
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition:
macros.hpp:40
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::ViewArray< SetView >
Gecode::IntArgs
Passing integer arguments.
Definition:
int.hh:628
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})