Generated on Thu Mar 7 2013 10:21:32 for Gecode by doxygen 1.8.3.1
bool-base.hpp
Go to the documentation of this file.
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, 2011
8  *
9  * Last modified:
10  * $Date: 2011-08-11 19:59:30 +1000 (Thu, 11 Aug 2011) $ by $Author: schulte $
11  * $Revision: 12270 $
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 namespace Gecode { namespace Int { namespace NValues {
39 
40  template<class VY>
43  int status0, ViewArray<BoolView>& x, VY y0)
44  : Propagator(home), status(status0), c(home), y(y0) {
45  y.subscribe(home,*this,PC_INT_BND);
46  for (int i=x.size(); i--; ) {
47  assert(!x[i].assigned());
48  (void) new (home) ViewAdvisor<BoolView>(home, *this, c, x[i]);
49  }
50  }
51 
52  template<class VY>
54  BoolBase<VY>::BoolBase(Space& home, bool share, BoolBase<VY>& p)
55  : Propagator(home,share,p), status(p.status) {
56  c.update(home,share,p.c);
57  y.update(home,share,p.y);
58  }
59 
60  template<class VY>
61  PropCost
62  BoolBase<VY>::cost(const Space&, const ModEventDelta&) const {
64  }
65 
66  template<class VY>
69  ViewAdvisor<BoolView>& a(static_cast<ViewAdvisor<BoolView>&>(_a));
70  ExecStatus es;
71  if (status == (VS_ZERO | VS_ONE)) {
72  // Everything is already decided
73  es = ES_FIX;
74  } else {
75  if (a.view().zero())
76  status |= VS_ZERO;
77  else
78  status |= VS_ONE;
79  es = ES_NOFIX;
80  }
81  a.dispose(home,c);
82  if (c.empty())
83  es = ES_NOFIX;
84  return es;
85  }
86 
87  template<class VY>
88  forceinline size_t
90  c.dispose(home);
91  y.cancel(home,*this,PC_INT_BND);
92  (void) Propagator::dispose(home);
93  return sizeof(*this);
94  }
95 
96 }}}
97 
98 // STATISTICS: int-prop