Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
34namespace 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>
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>
71 ViewAdvisor<BoolView>& a(static_cast<ViewAdvisor<BoolView>&>(_a));
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
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3256
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Home class for posting propagators
Definition core.hpp:856
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
static const int VS_ONE
View status: a one has already been encountered.
Definition nvalues.hh:298
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
static const int VS_ZERO
View status: a zero has already been encountered.
Definition nvalues.hh:296
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition bool-base.hpp:70
int status
Status information about the views.
Definition nvalues.hh:300
Propagation cost.
Definition core.hpp:486
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition core.hpp:4820
friend class Space
Definition core.hpp:1068
friend class Advisor
Definition core.hpp:1070
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3505
Advisor storing a single view
Definition advisor.hpp:43
View arrays.
Definition array.hpp:253
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Number of values propagators.
Finite domain integers.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:91
Gecode toplevel namespace
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 x
Definition set.hh:773
#define forceinline
Definition config.hpp:194