bool-base.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2011
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode { namespace Int { namespace NValues {
template<class VY>
forceinline
BoolBase<VY>::BoolBase(Home home,
int status0, ViewArray<BoolView>& x, VY y0)
: Propagator(home), status(status0), c(home), y(y0) {
y.subscribe(home,*this,PC_INT_BND);
for (int i=0; i<x.size(); i++) {
assert(!x[i].assigned());
(void) new (home) ViewAdvisor<BoolView>(home, *this, c, x[i]);
}
}
template<class VY>
forceinline
BoolBase<VY>::BoolBase(Space& home, BoolBase<VY>& p)
: Propagator(home,p), status(p.status) {
c.update(home,p.c);
y.update(home,p.y);
}
template<class VY>
PropCost
BoolBase<VY>::cost(const Space&, const ModEventDelta&) const {
return PropCost::unary(PropCost::LO);
}
template<class VY>
void
BoolBase<VY>::reschedule(Space& home) {
y.reschedule(home,*this,PC_INT_BND);
}
template<class VY>
ExecStatus
BoolBase<VY>::advise(Space& home, Advisor& _a, const Delta&) {
ViewAdvisor<BoolView>& a(static_cast<ViewAdvisor<BoolView>&>(_a));
ExecStatus es;
if (status == (VS_ZERO | VS_ONE)) {
// Everything is already decided
es = ES_FIX;
} else {
if (a.view().zero())
status |= VS_ZERO;
else
status |= VS_ONE;
es = ES_NOFIX;
}
a.dispose(home,c);
if (c.empty())
es = ES_NOFIX;
return es;
}
template<class VY>
forceinline size_t
BoolBase<VY>::dispose(Space& home) {
c.dispose(home);
y.cancel(home,*this,PC_INT_BND);
(void) Propagator::dispose(home);
return sizeof(*this);
}
}}}
// STATISTICS: int-prop
Gecode::Actor::dispose
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3252
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Int::NValues::BoolBase::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition bool-base.hpp:91
Gecode::Int::NValues::BoolBase::c
Council< ViewAdvisor< BoolView > > c
The advisor council.
Definition nvalues.hh:302
Gecode::Int::NValues::BoolBase::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary).
Definition bool-base.hpp:58
Gecode::Int::NValues::BoolBase::BoolBase
BoolBase(Home home, int status, ViewArray< BoolView > &x, VY y)
Constructor for posting.
Definition bool-base.hpp:38
Gecode::Int::NValues::BoolBase::VS_ONE
static const int VS_ONE
View status: a one has already been encountered.
Definition nvalues.hh:298
Gecode::Int::NValues::BoolBase::y
VY y
The view for counting the number of values.
Definition nvalues.hh:304
Gecode::Int::NValues::BoolBase::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition bool-base.hpp:64
Gecode::Int::NValues::BoolBase::VS_ZERO
static const int VS_ZERO
View status: a zero has already been encountered.
Definition nvalues.hh:296
Gecode::Int::NValues::BoolBase::advise
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition bool-base.hpp:70
Gecode::Int::NValues::BoolBase::status
int status
Status information about the views.
Definition nvalues.hh:300
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::PropCost::unary
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition core.hpp:4813
Gecode::PropCost::LO
@ LO
Cheap.
Definition core.hpp:513
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Propagator::Advisor
friend class Advisor
Definition core.hpp:1068
Gecode::Propagator::Propagator
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3498
Gecode::ViewAdvisor
Advisor storing a single view
Definition advisor.hpp:43
Gecode::ViewArray
View arrays.
Definition array.hpp:253
Gecode::ViewArray::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1156
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Gecode::Int::NValues
Number of values propagators.
Gecode::Int
Finite domain integers.
Gecode::Int::PC_INT_BND
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:91
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition core.hpp:477
Gecode::ES_NOFIX
@ ES_NOFIX
Propagation has not computed fixpoint.
Definition core.hpp:475
forceinline
#define forceinline
Definition config.hpp:187