main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Jul 29 2017 12:41:24 for Gecode by
doxygen
1.8.13
gecode
int
extensional.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Mikael Lagerkvist <lagerkvist@gecode.org>
5
* Christian Schulte <schulte@gecode.org>
6
*
7
* Copyright:
8
* Mikael Lagerkvist, 2007
9
* Christian Schulte, 2004
10
*
11
* Last modified:
12
* $Date: 2016-05-23 22:18:23 +0200 (Mon, 23 May 2016) $ by $Author: schulte $
13
* $Revision: 15073 $
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/int/extensional.hh
>
41
42
namespace
Gecode
{
43
44
void
45
extensional
(
Home
home,
const
IntVarArgs
&
x
,
DFA
dfa,
46
IntPropLevel
) {
47
using namespace
Int;
48
if
(x.
same
(home))
49
throw
ArgumentSame
(
"Int::extensional"
);
50
GECODE_POST
;
51
GECODE_ES_FAIL
(
Extensional::post_lgp
(home,x,dfa));
52
}
53
54
void
55
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
DFA
dfa,
56
IntPropLevel
) {
57
using namespace
Int;
58
if
(x.
same
(home))
59
throw
ArgumentSame
(
"Int::extensional"
);
60
GECODE_POST
;
61
GECODE_ES_FAIL
(
Extensional::post_lgp
(home,x,dfa));
62
}
63
64
void
65
extensional
(
Home
home,
const
IntVarArgs
&
x
,
const
TupleSet
&
t
,
66
IntPropLevel
ipl) {
67
using namespace
Int;
68
if
(!t.
finalized
())
69
throw
NotYetFinalized
(
"Int::extensional"
);
70
if
(t.
arity
() != x.
size
())
71
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
72
GECODE_POST
;
73
74
if
(t.
tuples
()==0) {
75
if
(x.
size
()!=0) {
76
home.
fail
();
77
}
78
return
;
79
}
80
81
// Construct view array
82
ViewArray<IntView>
xv(home,x);
83
if
(ipl &
IPL_MEMORY
) {
84
if
(x.
same
(home)) {
85
GECODE_ES_FAIL
((
Extensional::Basic<IntView,true>
86
::
post
(home,xv,t)));
87
}
else
{
88
GECODE_ES_FAIL
((
Extensional::Basic<IntView,false>
89
::
post
(home,xv,t)));
90
}
91
}
else
{
92
GECODE_ES_FAIL
((
Extensional::Incremental<IntView>
93
::
post
(home,xv,t)));
94
}
95
}
96
97
void
98
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
const
TupleSet
&
t
,
99
IntPropLevel
ipl) {
100
using namespace
Int;
101
if
(!t.
finalized
())
102
throw
NotYetFinalized
(
"Int::extensional"
);
103
if
(t.
arity
() != x.
size
())
104
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
105
GECODE_POST
;
106
107
if
(t.
tuples
()==0) {
108
if
(x.
size
()!=0) {
109
home.
fail
();
110
}
111
return
;
112
}
113
114
// Construct view array
115
ViewArray<BoolView>
xv(home,x);
116
if
(ipl &
IPL_MEMORY
) {
117
if
(x.
same
(home)) {
118
GECODE_ES_FAIL
((
Extensional::Basic<BoolView,true>
119
::
post
(home,xv,t)));
120
}
else
{
121
GECODE_ES_FAIL
((
Extensional::Basic<BoolView,false>
122
::
post
(home,xv,t)));
123
}
124
}
else
{
125
GECODE_ES_FAIL
((
Extensional::Incremental<BoolView>
126
::
post
(home,xv,t)));
127
}
128
}
129
130
}
131
132
// STATISTICS: int-post
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:234
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:1669
Gecode::TupleSet::arity
int arity(void) const
Arity of tuple set.
Definition:
tuple-set.hpp:134
extensional.hh
Gecode::TupleSet::finalized
bool finalized(void) const
Is tuple set finalized.
Definition:
tuple-set.hpp:127
Gecode::Int::NotYetFinalized
Exception: Tuple set not yet finalized
Definition:
exception.hpp:133
Gecode::TupleSet::tuples
int tuples(void) const
Number of tuples.
Definition:
tuple-set.hpp:141
Gecode::DFA
Deterministic finite automaton (DFA)
Definition:
int.hh:2034
Gecode::Int::Extensional::Basic
Domain consistent extensional propagator.
Definition:
extensional.hh:297
Gecode::extensional
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition:
extensional.cpp:45
Gecode::Int::Extensional::post_lgp
ExecStatus post_lgp(Home home, const VarArgArray< Var > &x, const DFA &dfa)
Select small types for the layered graph propagator.
Definition:
layered-graph.hpp:858
Gecode::ViewArray< IntView >
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:639
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:693
Gecode::IPL_MEMORY
Prefer to save memory Options: basic versus advanced propagation.
Definition:
int.hh:963
Gecode::TupleSet
Class represeting a set of tuples.
Definition:
int.hh:2161
Gecode::IntPropLevel
IntPropLevel
Propagation levels for integer propagators.
Definition:
int.hh:955
Gecode::Int::Extensional::Incremental
Domain consistent extensional propagator.
Definition:
extensional.hh:345
Gecode::Int::ArgumentSame
Exception: Arguments contain same variable multiply
Definition:
exception.hpp:84
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
Gecode::Home::fail
void fail(void)
Mark space as failed.
Definition:
core.hpp:4090
Gecode
Gecode toplevel namespace
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition:
macros.hpp:44
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::Int::ArgumentSizeMismatch
Exception: Arguments are of different size
Definition:
exception.hpp:77
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:107
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition:
trace-filter.cpp:142
Gecode::VarArgArray::same
bool same(const Space &home) const
Test whether array contains same variable multiply.
Definition:
array.hpp:2081