this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Christian Schulte <schulte@gecode.org>
5 *
6 * Copyright:
7 * Christian Schulte, 2004
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34namespace Gecode { namespace Int { namespace Bool {
35
36 /*
37 * Binary Boolean propagators
38 *
39 */
40 template<class BVA, class BVB>
41 forceinline
42 BoolBinary<BVA,BVB>::BoolBinary(Home home, BVA b0, BVB b1)
43 : Propagator(home), x0(b0), x1(b1) {
44 x0.subscribe(home,*this,PC_BOOL_VAL);
45 x1.subscribe(home,*this,PC_BOOL_VAL);
46 }
47
48 template<class BVA, class BVB>
49 forceinline
50 BoolBinary<BVA,BVB>::BoolBinary(Space& home, BoolBinary<BVA,BVB>& p)
51 : Propagator(home,p) {
52 x0.update(home,p.x0);
53 x1.update(home,p.x1);
54 }
55
56 template<class BVA, class BVB>
57 forceinline
58 BoolBinary<BVA,BVB>::BoolBinary(Space& home, Propagator& p,
59 BVA b0, BVB b1)
60 : Propagator(home,p) {
61 x0.update(home,b0);
62 x1.update(home,b1);
63 }
64
65 template<class BVA, class BVB>
66 PropCost
67 BoolBinary<BVA,BVB>::cost(const Space&, const ModEventDelta&) const {
68 return PropCost::unary(PropCost::LO);
69 }
70
71 template<class BVA, class BVB>
72 void
73 BoolBinary<BVA,BVB>::reschedule(Space& home) {
74 x0.reschedule(home,*this,PC_BOOL_VAL);
75 x1.reschedule(home,*this,PC_BOOL_VAL);
76 }
77
78 template<class BVA, class BVB>
79 forceinline size_t
80 BoolBinary<BVA,BVB>::dispose(Space& home) {
81 x0.cancel(home,*this,PC_BOOL_VAL);
82 x1.cancel(home,*this,PC_BOOL_VAL);
83 (void) Propagator::dispose(home);
84 return sizeof(*this);
85 }
86
87 /*
88 * Ternary Boolean propagators
89 *
90 */
91 template<class BVA, class BVB, class BVC>
92 forceinline
93 BoolTernary<BVA,BVB,BVC>::BoolTernary
94 (Home home, BVA b0, BVB b1, BVC b2)
95 : Propagator(home), x0(b0), x1(b1), x2(b2) {
96 x0.subscribe(home,*this,PC_BOOL_VAL);
97 x1.subscribe(home,*this,PC_BOOL_VAL);
98 x2.subscribe(home,*this,PC_BOOL_VAL);
99 }
100
101 template<class BVA, class BVB, class BVC>
102 forceinline
103 BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home,
104 BoolTernary<BVA,BVB,BVC>& p)
105 : Propagator(home,p) {
106 x0.update(home,p.x0);
107 x1.update(home,p.x1);
108 x2.update(home,p.x2);
109 }
110
111 template<class BVA, class BVB, class BVC>
112 forceinline
113 BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, Propagator& p,
114 BVA b0, BVB b1, BVC b2)
115 : Propagator(home,p) {
116 x0.update(home,b0);
117 x1.update(home,b1);
118 x2.update(home,b2);
119 }
120
121 template<class BVA, class BVB, class BVC>
122 PropCost
123 BoolTernary<BVA,BVB,BVC>::cost(const Space&, const ModEventDelta&) const {
124 return PropCost::binary(PropCost::LO);
125 }
126
127 template<class BVA, class BVB, class BVC>
128 void
129 BoolTernary<BVA,BVB,BVC>::reschedule(Space& home) {
130 x0.reschedule(home,*this,PC_BOOL_VAL);
131 x1.reschedule(home,*this,PC_BOOL_VAL);
132 x2.reschedule(home,*this,PC_BOOL_VAL);
133 }
134
135 template<class BVA, class BVB, class BVC>
136 forceinline size_t
137 BoolTernary<BVA,BVB,BVC>::dispose(Space& home) {
138 x0.cancel(home,*this,PC_BOOL_VAL);
139 x1.cancel(home,*this,PC_BOOL_VAL);
140 x2.cancel(home,*this,PC_BOOL_VAL);
141 (void) Propagator::dispose(home);
142 return sizeof(*this);
143 }
144
145}}}
146
147// STATISTICS: int-prop