main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Aug 25 2012 03:32:48 for Gecode by
doxygen
1.8.1.2
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: 2010-03-04 03:40:32 +1100 (Thu, 04 Mar 2010) $ by $Author: schulte $
13
* $Revision: 10365 $
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
IntConLevel
) {
47
using namespace
Int;
48
if
(x.
same
(home))
49
throw
ArgumentSame
(
"Int::extensional"
);
50
if
(home.
failed
())
return
;
51
GECODE_ES_FAIL
(
Extensional::post_lgp
(home,x,dfa));
52
}
53
54
void
55
extensional
(
Home
home,
const
BoolVarArgs
& x,
DFA
dfa,
56
IntConLevel
) {
57
using namespace
Int;
58
if
(x.
same
(home))
59
throw
ArgumentSame
(
"Int::extensional"
);
60
if
(home.
failed
())
return
;
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
ExtensionalPropKind
epk,
IntConLevel
) {
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
if
(home.
failed
())
return
;
73
74
// Construct view array
75
ViewArray<IntView>
xv(home,x);
76
switch
(epk) {
77
case
EPK_SPEED
:
78
GECODE_ES_FAIL
((
Extensional::Incremental<IntView>
79
::
post
(home,xv,t)));
80
break
;
81
default
:
82
if
(x.
same
(home)) {
83
GECODE_ES_FAIL
((
Extensional::Basic<IntView,true>
84
::
post
(home,xv,t)));
85
}
else
{
86
GECODE_ES_FAIL
((
Extensional::Basic<IntView,false>
87
::
post
(home,xv,t)));
88
}
89
break
;
90
}
91
}
92
93
void
94
extensional
(
Home
home,
const
BoolVarArgs
& x,
const
TupleSet
& t,
95
ExtensionalPropKind
epk,
IntConLevel
) {
96
using namespace
Int;
97
if
(!t.
finalized
())
98
throw
NotYetFinalized
(
"Int::extensional"
);
99
if
(t.
arity
() != x.
size
())
100
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
101
if
(home.
failed
())
return
;
102
103
// Construct view array
104
ViewArray<BoolView>
xv(home,x);
105
switch
(epk) {
106
case
EPK_SPEED
:
107
GECODE_ES_FAIL
((
Extensional::Incremental<BoolView>
108
::
post
(home,xv,t)));
109
break
;
110
default
:
111
if
(x.
same
(home)) {
112
GECODE_ES_FAIL
((
Extensional::Basic<BoolView,true>
113
::
post
(home,xv,t)));
114
}
else
{
115
GECODE_ES_FAIL
((
Extensional::Basic<BoolView,false>
116
::
post
(home,xv,t)));
117
}
118
break
;
119
}
120
}
121
122
}
123
124
// STATISTICS: int-post