Generated on Sat Feb 7 2015 02:01:22 for Gecode by doxygen 1.8.9.1
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: 2012-09-07 17:31:22 +0200 (Fri, 07 Sep 2012) $ by $Author: schulte $
13  * $Revision: 13068 $
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 
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;
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;
62  }
63 
64  void
65  extensional(Home home, const IntVarArgs& x, const TupleSet& t,
67  using namespace Int;
68  if (!t.finalized())
69  throw NotYetFinalized("Int::extensional");
70  if (t.tuples()==0) {
71  if (x.size()!=0) {
72  home.fail();
73  }
74  return;
75  }
76 
77  if (t.arity() != x.size())
78  throw ArgumentSizeMismatch("Int::extensional");
79  if (home.failed()) return;
80 
81  // Construct view array
82  ViewArray<IntView> xv(home,x);
83  switch (epk) {
84  case EPK_SPEED:
86  ::post(home,xv,t)));
87  break;
88  default:
89  if (x.same(home)) {
91  ::post(home,xv,t)));
92  } else {
94  ::post(home,xv,t)));
95  }
96  break;
97  }
98  }
99 
100  void
101  extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
103  using namespace Int;
104  if (!t.finalized())
105  throw NotYetFinalized("Int::extensional");
106 
107  if (t.tuples()==0) {
108  if (x.size()!=0) {
109  home.fail();
110  }
111  return;
112  }
113 
114  if (t.arity() != x.size())
115  throw ArgumentSizeMismatch("Int::extensional");
116  if (home.failed()) return;
117 
118  // Construct view array
119  ViewArray<BoolView> xv(home,x);
120  switch (epk) {
121  case EPK_SPEED:
123  ::post(home,xv,t)));
124  break;
125  default:
126  if (x.same(home)) {
128  ::post(home,xv,t)));
129  } else {
131  ::post(home,xv,t)));
132  }
133  break;
134  }
135  }
136 
137 }
138 
139 // STATISTICS: int-post
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3446
NodeType t
Type of node.
Definition: bool-expr.cpp:234
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:937
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:228
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
int arity(void) const
Arity of tuple set.
Definition: tuple-set.hpp:134
Exception: Tuple set not yet finalized
Definition: exception.hpp:133
int tuples(void) const
Number of tuples.
Definition: tuple-set.hpp:141
Deterministic finite automaton (DFA)
Definition: int.hh:1881
Domain consistent extensional propagator.
Definition: extensional.hh:295
Prefer speed over memory consumption.
Definition: int.hh:1984
ExecStatus post_lgp(Home home, const VarArgArray< Var > &x, const DFA &dfa)
Select small types for the layered graph propagator.
ExtensionalPropKind
Extensional propagation kind.
Definition: int.hh:1982
Passing integer variables.
Definition: int.hh:636
Passing Boolean variables.
Definition: int.hh:690
Class represeting a set of tuples.
Definition: int.hh:2022
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntConLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition: extensional.cpp:45
bool finalized(void) const
Is tuple set finalized.
Definition: tuple-set.hpp:127
Domain consistent extensional propagator.
Definition: extensional.hh:343
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Exception: Arguments contain same variable multiply
Definition: exception.hpp:84
void fail(void)
Mark space as failed.
Definition: core.hpp:3437
Gecode toplevel namespace
Home class for posting propagators
Definition: core.hpp:717
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:96
bool same(const Space &home) const
Test whether array contains same variable multiply.
Definition: array.hpp:2085