Generated on Sat Jun 2 2018 07:17:44 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  * 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 
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");
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");
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");
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");
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
NodeType t
Type of node.
Definition: bool-expr.cpp:230
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1653
int arity(void) const
Arity of tuple set.
Definition: tuple-set.hpp:181
int max(void) const
Return maximal value in all tuples.
Definition: tuple-set.hpp:197
bool finalized(void) const
Is tuple set finalized.
Definition: tuple-set.hpp:162
Exception: Tuple set not yet finalized
Definition: exception.hpp:136
int tuples(void) const
Number of tuples.
Definition: tuple-set.hpp:185
Deterministic finite automaton (DFA)
Definition: int.hh:2023
bool same(void) const
Test whether array contains same variable multiply.
Definition: array.hpp:2065
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
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:633
Passing Boolean variables.
Definition: int.hh:687
Class represeting a set of tuples.
Definition: int.hh:2140
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:949
int min(void) const
Return minimal value in all tuples.
Definition: tuple-set.hpp:193
Exception: Arguments contain same variable multiply
Definition: exception.hpp:80
Post propagator for SetVar x
Definition: set.hh:765
Exception: Not 0/1 integer
Definition: exception.hpp:51
void fail(void)
Mark space as failed.
Definition: core.hpp:3958
Gecode toplevel namespace
#define GECODE_POST
Check for failure in a constraint post function.
Definition: macros.hpp:40
Home class for posting propagators
Definition: core.hpp:853
Exception: Arguments are of different size
Definition: exception.hpp:73
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition: macros.hpp:103