int-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, 2006
*
* 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 Count {
template<class VX, class VY>
forceinline
IntBase<VX,VY>::IntBase(Home home,
ViewArray<VX>& x0, int n_s0, VY y0, int c0)
: Propagator(home), x(x0), n_s(n_s0), y(y0), c(c0) {
if (isintset(y))
home.notice(*this,AP_DISPOSE);
for (int i=0; i<n_s; i++)
x[i].subscribe(home,*this,PC_INT_DOM);
subscribe(home,*this,y);
}
template<class VX, class VY>
forceinline size_t
IntBase<VX,VY>::dispose(Space& home) {
if (isintset(y))
home.ignore(*this,AP_DISPOSE);
for (int i=0; i<n_s; i++)
x[i].cancel(home,*this,PC_INT_DOM);
cancel(home,*this,y);
(void) Propagator::dispose(home);
return sizeof(*this);
}
template<class VX, class VY>
forceinline
IntBase<VX,VY>::IntBase(Space& home, IntBase<VX,VY>& p)
: Propagator(home,p), n_s(p.n_s), c(p.c) {
x.update(home,p.x);
update(y,home,p.y);
}
template<class VX, class VY>
PropCost
IntBase<VX,VY>::cost(const Space&, const ModEventDelta&) const {
return PropCost::linear(PropCost::LO,x.size());
}
template<class VX, class VY>
void
IntBase<VX,VY>::reschedule(Space& home) {
for (int i=0; i<n_s; i++)
x[i].reschedule(home,*this,PC_INT_DOM);
Gecode::Int::Count::reschedule(home,*this,y);
}
}}}
// STATISTICS: int-prop
Gecode::Actor::dispose
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3252
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Home::notice
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition core.hpp:3219
Gecode::Int::Count::IntBase::IntBase
IntBase(Space &home, IntBase &p)
Constructor for cloning p.
Definition int-base.hpp:62
Gecode::Int::Count::IntBase::n_s
int n_s
Views from x[0] ... x[n_s-1] have subscriptions.
Definition count.hh:143
Gecode::Int::Count::IntBase::x
ViewArray< VX > x
Views still to count.
Definition count.hh:141
Gecode::Int::Count::IntBase::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear).
Definition int-base.hpp:70
Gecode::Int::Count::IntBase::c
int c
Number of views which are equal and have been eliminated.
Definition count.hh:147
Gecode::Int::Count::IntBase::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition int-base.hpp:50
Gecode::Int::Count::IntBase::y
VY y
View to compare to.
Definition count.hh:145
Gecode::Int::Count::IntBase::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition int-base.hpp:76
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::PropCost::linear
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Definition core.hpp:4796
Gecode::PropCost::LO
@ LO
Cheap.
Definition core.hpp:513
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Propagator::Propagator
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3498
Gecode::ViewArray
View arrays.
Definition array.hpp:253
Gecode::Space::ignore
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition core.hpp:4074
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Gecode::AP_DISPOSE
@ AP_DISPOSE
Actor must always be disposed.
Definition core.hpp:562
Gecode::Int::Count
Counting propagators.
Gecode::Int::Count::cancel
void cancel(Space &home, Propagator &p, VY y)
Cancel propagator p for view y.
Definition rel.hpp:87
Gecode::Int::Count::update
void update(VY &y, Space &home, bool shared, VY py)
Update view y from py.
Gecode::Int::Count::isintset
bool isintset(VY y)
Return whether y is an integer set.
Definition rel.hpp:45
Gecode::Int::Count::subscribe
void subscribe(Space &home, Propagator &p, VY y)
Subscribe propagator p to view y.
Definition rel.hpp:76
Gecode::Int::Count::reschedule
void reschedule(Space &home, Propagator &p, VY y)
Schedule propagator p for view y.
Definition rel.hpp:97
Gecode::Int
Finite domain integers.
Gecode::Int::PC_INT_DOM
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition var-type.hpp:100
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition config.hpp:187