Generated on Wed Jul 21 2021 00:00:00 for Gecode by doxygen 1.9.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  * 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 
34 namespace Gecode { namespace Int { namespace NValues {
35 
36  template<class VY>
39  int status0, ViewArray<BoolView>& x, VY y0)
40  : Propagator(home), status(status0), c(home), y(y0) {
41  y.subscribe(home,*this,PC_INT_BND);
42  for (int i=0; i<x.size(); i++) {
43  assert(!x[i].assigned());
44  (void) new (home) ViewAdvisor<BoolView>(home, *this, c, x[i]);
45  }
46  }
47 
48  template<class VY>
51  : Propagator(home,p), status(p.status) {
52  c.update(home,p.c);
53  y.update(home,p.y);
54  }
55 
56  template<class VY>
57  PropCost
58  BoolBase<VY>::cost(const Space&, const ModEventDelta&) const {
60  }
61 
62  template<class VY>
63  void
65  y.reschedule(home,*this,PC_INT_BND);
66  }
67 
68  template<class VY>
72  ExecStatus es;
73  if (status == (VS_ZERO | VS_ONE)) {
74  // Everything is already decided
75  es = ES_FIX;
76  } else {
77  if (a.view().zero())
78  status |= VS_ZERO;
79  else
80  status |= VS_ONE;
81  es = ES_NOFIX;
82  }
83  a.dispose(home,c);
84  if (c.empty())
85  es = ES_NOFIX;
86  return es;
87  }
88 
89  template<class VY>
90  forceinline size_t
92  c.dispose(home);
93  y.cancel(home,*this,PC_INT_BND);
94  (void) Propagator::dispose(home);
95  return sizeof(*this);
96  }
97 
98 }}}
99 
100 // STATISTICS: int-prop
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition: core.hpp:3252
Base-class for advisors.
Definition: core.hpp:1292
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
Home class for posting propagators
Definition: core.hpp:856
Number of values propagator for Boolean views base class.
Definition: nvalues.hh:293
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: bool-base.hpp:91
Council< ViewAdvisor< BoolView > > c
The advisor council.
Definition: nvalues.hh:302
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Definition: bool-base.hpp:58
BoolBase(Home home, int status, ViewArray< BoolView > &x, VY y)
Constructor for posting.
Definition: bool-base.hpp:38
VY y
The view for counting the number of values.
Definition: nvalues.hh:304
virtual void reschedule(Space &home)
Schedule function.
Definition: bool-base.hpp:64
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: bool-base.hpp:70
Propagation cost.
Definition: core.hpp:486
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4813
@ LO
Cheap.
Definition: core.hpp:513
Base-class for propagators.
Definition: core.hpp:1064
Computation spaces.
Definition: core.hpp:1742
Advisor storing a single view
Definition: advisor.hpp:43
View arrays.
Definition: array.hpp:253
ExecStatus
Definition: core.hpp:472
@ ES_FIX
Propagation has computed fixpoint.
Definition: core.hpp:477
@ ES_NOFIX
Propagation has not computed fixpoint.
Definition: core.hpp:475
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:43
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})
Single _a(2, 3)
#define forceinline
Definition: config.hpp:192