main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Jun 2 2018 07:17:44 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
* Linnea Ingmar <linnea.ingmar@hotmail.com>
5
* Mikael Lagerkvist <lagerkvist@gecode.org>
6
* Christian Schulte <schulte@gecode.org>
7
*
8
* Copyright:
9
* Linnea Ingmar, 2017
10
* Mikael Lagerkvist, 2007
11
* Christian Schulte, 2004
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/extensional.hh
>
39
40
namespace
Gecode
{
41
42
void
43
extensional
(
Home
home,
const
IntVarArgs
&
x
,
DFA
dfa,
44
IntPropLevel
) {
45
using namespace
Int;
46
if
(x.
same
())
47
throw
ArgumentSame
(
"Int::extensional"
);
48
GECODE_POST
;
49
GECODE_ES_FAIL
(
Extensional::post_lgp
(home,x,dfa));
50
}
51
52
void
53
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
DFA
dfa,
54
IntPropLevel
) {
55
using namespace
Int;
56
if
(x.
same
())
57
throw
ArgumentSame
(
"Int::extensional"
);
58
GECODE_POST
;
59
GECODE_ES_FAIL
(
Extensional::post_lgp
(home,x,dfa));
60
}
61
62
void
63
extensional
(
Home
home,
const
IntVarArgs
&
x
,
const
TupleSet
&
t
,
64
IntPropLevel
) {
65
using namespace
Int;
66
if
(!t.
finalized
())
67
throw
NotYetFinalized
(
"Int::extensional"
);
68
if
(t.
arity
() != x.
size
())
69
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
70
GECODE_POST
;
71
72
if
(t.
tuples
()==0) {
73
if
(x.
size
()!=0) {
74
home.
fail
();
75
}
76
return
;
77
}
78
79
// Construct view array
80
ViewArray<IntView>
xv(home,x);
81
GECODE_ES_FAIL
(Extensional::postcompact<IntView>(home,xv,t));
82
}
83
84
void
85
extensional
(
Home
home,
const
BoolVarArgs
&
x
,
const
TupleSet
&
t
,
86
IntPropLevel
) {
87
using namespace
Int;
88
if
(!t.
finalized
())
89
throw
NotYetFinalized
(
"Int::extensional"
);
90
if
(t.
arity
() != x.
size
())
91
throw
ArgumentSizeMismatch
(
"Int::extensional"
);
92
if
((t.
min
() < 0) || (t.
max
() > 1))
93
throw
NotZeroOne
(
"Int::extensional"
);
94
GECODE_POST
;
95
96
if
(t.
tuples
()==0) {
97
if
(x.
size
()!=0) {
98
home.
fail
();
99
}
100
return
;
101
}
102
103
// Construct view array
104
ViewArray<BoolView>
xv(home,x);
105
GECODE_ES_FAIL
(Extensional::postcompact<BoolView>(home,xv,t));
106
}
107
108
}
109
110
// STATISTICS: int-post
t
NodeType t
Type of node.
Definition:
bool-expr.cpp:230
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:1653
Gecode::TupleSet::arity
int arity(void) const
Arity of tuple set.
Definition:
tuple-set.hpp:181
extensional.hh
Gecode::TupleSet::max
int max(void) const
Return maximal value in all tuples.
Definition:
tuple-set.hpp:197
Gecode::TupleSet::finalized
bool finalized(void) const
Is tuple set finalized.
Definition:
tuple-set.hpp:162
Gecode::Int::NotYetFinalized
Exception: Tuple set not yet finalized
Definition:
exception.hpp:136
Gecode::TupleSet::tuples
int tuples(void) const
Number of tuples.
Definition:
tuple-set.hpp:185
Gecode::DFA
Deterministic finite automaton (DFA)
Definition:
int.hh:2023
Gecode::VarArgArray::same
bool same(void) const
Test whether array contains same variable multiply.
Definition:
array.hpp:2065
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:43
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:852
Gecode::ViewArray< IntView >
Gecode::IntVarArgs
Passing integer variables.
Definition:
int.hh:633
Gecode::BoolVarArgs
Passing Boolean variables.
Definition:
int.hh:687
Gecode::TupleSet
Class represeting a set of tuples.
Definition:
int.hh:2140
Gecode::IntPropLevel
IntPropLevel
Propagation levels for integer propagators.
Definition:
int.hh:949
Gecode::TupleSet::min
int min(void) const
Return minimal value in all tuples.
Definition:
tuple-set.hpp:193
Gecode::Int::ArgumentSame
Exception: Arguments contain same variable multiply
Definition:
exception.hpp:80
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:765
Gecode::Int::NotZeroOne
Exception: Not 0/1 integer
Definition:
exception.hpp:51
Gecode::Home::fail
void fail(void)
Mark space as failed.
Definition:
core.hpp:3958
Gecode
Gecode toplevel namespace
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition:
macros.hpp:40
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:853
Gecode::Int::ArgumentSizeMismatch
Exception: Arguments are of different size
Definition:
exception.hpp:73
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition:
macros.hpp:103