Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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  * Last modified:
14  * $Date$ by $Author$
15  * $Revision$
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 
43 
44 namespace Gecode {
45 
46  void
47  extensional(Home home, const IntVarArgs& x, DFA dfa,
48  IntPropLevel) {
49  using namespace Int;
50  if (x.same())
51  throw ArgumentSame("Int::extensional");
54  }
55 
56  void
57  extensional(Home home, const BoolVarArgs& x, DFA dfa,
58  IntPropLevel) {
59  using namespace Int;
60  if (x.same())
61  throw ArgumentSame("Int::extensional");
64  }
65 
66  void
67  extensional(Home home, const IntVarArgs& x, const TupleSet& t,
68  IntPropLevel) {
69  using namespace Int;
70  if (!t.finalized())
71  throw NotYetFinalized("Int::extensional");
72  if (t.arity() != x.size())
73  throw ArgumentSizeMismatch("Int::extensional");
75 
76  if (t.tuples()==0) {
77  if (x.size()!=0) {
78  home.fail();
79  }
80  return;
81  }
82 
83  // Construct view array
84  ViewArray<IntView> xv(home,x);
85  GECODE_ES_FAIL(Extensional::postcompact<IntView>(home,xv,t));
86  }
87 
88  void
89  extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
90  IntPropLevel) {
91  using namespace Int;
92  if (!t.finalized())
93  throw NotYetFinalized("Int::extensional");
94  if (t.arity() != x.size())
95  throw ArgumentSizeMismatch("Int::extensional");
96  if ((t.min() < 0) || (t.max() > 1))
97  throw NotZeroOne("Int::extensional");
99 
100  if (t.tuples()==0) {
101  if (x.size()!=0) {
102  home.fail();
103  }
104  return;
105  }
106 
107  // Construct view array
108  ViewArray<BoolView> xv(home,x);
109  GECODE_ES_FAIL(Extensional::postcompact<BoolView>(home,xv,t));
110  }
111 
112 }
113 
114 // STATISTICS: int-post
NodeType t
Type of node.
Definition: bool-expr.cpp:234
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1657
int arity(void) const
Arity of tuple set.
Definition: tuple-set.hpp:185
int max(void) const
Return maximal value in all tuples.
Definition: tuple-set.hpp:201
bool finalized(void) const
Is tuple set finalized.
Definition: tuple-set.hpp:166
Exception: Tuple set not yet finalized
Definition: exception.hpp:140
int tuples(void) const
Number of tuples.
Definition: tuple-set.hpp:189
Deterministic finite automaton (DFA)
Definition: int.hh:2027
bool same(void) const
Test whether array contains same variable multiply.
Definition: array.hpp:2069
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition: extensional.cpp:47
ExecStatus post_lgp(Home home, const VarArgArray< Var > &x, const DFA &dfa)
Select small types for the layered graph propagator.
Passing integer variables.
Definition: int.hh:637
Passing Boolean variables.
Definition: int.hh:691
Class represeting a set of tuples.
Definition: int.hh:2144
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:953
int min(void) const
Return minimal value in all tuples.
Definition: tuple-set.hpp:197
Exception: Arguments contain same variable multiply
Definition: exception.hpp:84
Post propagator for SetVar x
Definition: set.hh:769
Exception: Not 0/1 integer
Definition: exception.hpp:55
void fail(void)
Mark space as failed.
Definition: core.hpp:3909
Gecode toplevel namespace
#define GECODE_POST
Check for failure in a constraint post function.
Definition: macros.hpp:44
Home class for posting propagators
Definition: core.hpp:846
Exception: Arguments are of different size
Definition: exception.hpp:77
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition: macros.hpp:107