channel.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Denys Duchier <denys.duchier@univ-orleans.fr>
* Guido Tack <tack@gecode.org>
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Denys Duchier, 2011
* Guido Tack, 2011
* Christian Schulte, 2004
*
* 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.
*
*/
#ifndef __GECODE_SET_CHANNEL_HH__
#define __GECODE_SET_CHANNEL_HH__
#include <gecode/set.hh>
namespace Gecode { namespace Set { namespace Channel {
template<class View>
class ChannelSorted : public Propagator {
protected:
View x0;
ViewArray<Gecode::Int::IntView> xs;
ChannelSorted(Space& home, ChannelSorted& p);
ChannelSorted(Home home, View, ViewArray<Gecode::Int::IntView>&);
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, View s,
ViewArray<Gecode::Int::IntView>& x);
};
template<class View>
class ChannelInt : public Propagator {
protected:
ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> > xs;
ViewArray<CachedView<View> > ys;
ChannelInt(Space& home, ChannelInt& p);
ChannelInt(Home home,
ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> >&,
ViewArray<CachedView<View> >&);
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home,
ViewArray<Gecode::Int::CachedView<
Gecode::Int::IntView> >& x,
ViewArray<CachedView<View> >& y);
};
template<class View>
class ChannelBool
: public MixNaryOnePropagator<Gecode::Int::BoolView,
Gecode::Int::PC_BOOL_VAL,
View,PC_GEN_NONE> {
protected:
typedef MixNaryOnePropagator<Gecode::Int::BoolView,
Gecode::Int::PC_BOOL_VAL,
View,PC_GEN_NONE> Super;
using Super::x;
using Super::y;
ChannelBool(Space& home, ChannelBool& p);
ChannelBool(Home home,ViewArray<Gecode::Int::BoolView>&,
View);
class IndexAdvisor : public Advisor {
protected:
int idx;
public:
template<class A>
IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
int index);
IndexAdvisor(Space& home, IndexAdvisor& a);
int index(void) const;
template<class A>
void dispose(Space& home, Council<A>& c);
};
Council<IndexAdvisor> co;
SetDelta delta;
GLBndSet zeros;
GLBndSet ones;
bool running;
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
View y);
};
template<typename View>
class ChannelSet: public Propagator {
protected:
ViewArray<CachedView<View> > xs;
ViewArray<CachedView<View> > ys;
ChannelSet(Space& home, ChannelSet& p);
ChannelSet(Home home,
ViewArray<CachedView<View> >&,
ViewArray<CachedView<View> >&);
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home,
ViewArray<CachedView<View> >& x,
ViewArray<CachedView<View> >& y);
};
}}}
#include <gecode/set/channel/sorted.hpp>
#include <gecode/set/channel/int.hpp>
#include <gecode/set/channel/bool.hpp>
#include <gecode/set/channel/set.hpp>
#endif
// STATISTICS: set-prop
Gecode::ActorLink::Space
friend class Space
Definition core.hpp:595
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::Advisor::Advisor
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
Definition core.hpp:3831
Gecode::Advisor::Council
friend class Council
Definition core.hpp:1294
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::BoolView
Boolean view for Boolean variables.
Definition view.hpp:1380
Gecode::Int::CachedView
Cached integer view.
Definition view.hpp:1166
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::MixNaryOnePropagator< Gecode::Int::BoolView, Gecode::Int::PC_BOOL_VAL, View, PC_GEN_NONE >::MixNaryOnePropagator
MixNaryOnePropagator(Space &home, MixNaryOnePropagator &p)
Gecode::MixNaryOnePropagator< Gecode::Int::BoolView, Gecode::Int::PC_BOOL_VAL, View, PC_GEN_NONE >::x
ViewArray< Gecode::Int::BoolView > x
Definition pattern.hpp:275
Gecode::MixNaryOnePropagator< Gecode::Int::BoolView, Gecode::Int::PC_BOOL_VAL, View, PC_GEN_NONE >::y
View y
Definition pattern.hpp:277
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Propagator::Advisor
friend class Advisor
Definition core.hpp:1068
Gecode::Propagator::Council
friend class Council
Definition core.hpp:1069
Gecode::Propagator::med
ModEventDelta med
A set of modification events (used during propagation).
Definition core.hpp:1075
Gecode::Propagator::Propagator
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3498
Gecode::Set::Channel::ChannelBool::IndexAdvisor::IndexAdvisor
IndexAdvisor(Space &home, ChannelBool< View > &p, Council< A > &c, int index)
Constructor for creation.
Definition bool.hpp:41
Gecode::Set::Channel::ChannelBool::IndexAdvisor::index
int index(void) const
Access index.
Definition bool.hpp:59
Gecode::Set::Channel::ChannelBool::IndexAdvisor::idx
int idx
The single index.
Definition channel.hh:169
Gecode::Set::Channel::ChannelBool::IndexAdvisor::dispose
void dispose(Space &home, Council< A > &c)
Delete advisor.
Definition bool.hpp:66
Gecode::Set::Channel::ChannelBool::zeros
GLBndSet zeros
Accumulated zero Booleans.
Definition channel.hh:189
Gecode::Set::Channel::ChannelBool::ChannelBool
ChannelBool(Space &home, ChannelBool &p)
Constructor for cloning p.
Definition bool.hpp:111
Gecode::Set::Channel::ChannelBool::advise
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition bool.hpp:204
Gecode::Set::Channel::ChannelBool::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition bool.hpp:133
Gecode::Set::Channel::ChannelBool::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition bool.hpp:140
Gecode::Set::Channel::ChannelBool::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition bool.hpp:154
Gecode::Set::Channel::ChannelBool::y
View y
Single view.
Definition pattern.hpp:277
Gecode::Set::Channel::ChannelBool::co
Council< IndexAdvisor > co
Council for managing advisors.
Definition channel.hh:185
Gecode::Set::Channel::ChannelBool::delta
SetDelta delta
Accumulated delta information.
Definition channel.hh:187
Gecode::Set::Channel::ChannelBool::ones
GLBndSet ones
Accumulated one Booleans.
Definition channel.hh:191
Gecode::Set::Channel::ChannelBool::running
bool running
Flag whether propagation is currently running.
Definition channel.hh:193
Gecode::Set::Channel::ChannelBool::Super
MixNaryOnePropagator< Gecode::Int::BoolView, Gecode::Int::PC_BOOL_VAL, View, PC_GEN_NONE > Super
Definition channel.hh:155
Gecode::Set::Channel::ChannelBool::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition bool.hpp:148
Gecode::Set::Channel::ChannelBool::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_LO).
Definition bool.hpp:127
Gecode::Set::Channel::ChannelBool::post
static ExecStatus post(Home home, ViewArray< Gecode::Int::BoolView > &x, View y)
Post propagator for .
Definition bool.hpp:118
Gecode::Set::Channel::ChannelBool::x
ViewArray< Gecode::Int::BoolView > x
Array of views.
Definition pattern.hpp:275
Gecode::Set::Channel::ChannelInt::post
static ExecStatus post(Home home, ViewArray< Gecode::Int::CachedView< Gecode::Int::IntView > > &x, ViewArray< CachedView< View > > &y)
Post propagator for .
Definition int.hpp:67
Gecode::Set::Channel::ChannelInt::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_LO).
Definition int.hpp:93
Gecode::Set::Channel::ChannelInt::ChannelInt
ChannelInt(Space &home, ChannelInt &p)
Constructor for cloning p.
Definition int.hpp:59
Gecode::Set::Channel::ChannelInt::xs
ViewArray< Gecode::Int::CachedView< Gecode::Int::IntView > > xs
IntViews, reflects which set contains element .
Definition channel.hh:108
Gecode::Set::Channel::ChannelInt::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition int.hpp:121
Gecode::Set::Channel::ChannelInt::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition int.hpp:99
Gecode::Set::Channel::ChannelInt::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition int.hpp:115
Gecode::Set::Channel::ChannelInt::ys
ViewArray< CachedView< View > > ys
SetViews that are constrained to be disjoint.
Definition channel.hh:110
Gecode::Set::Channel::ChannelInt::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition int.hpp:106
Gecode::Set::Channel::ChannelSet::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition set.hpp:92
Gecode::Set::Channel::ChannelSet::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition set.hpp:85
Gecode::Set::Channel::ChannelSet::post
static ExecStatus post(Home home, ViewArray< CachedView< View > > &x, ViewArray< CachedView< View > > &y)
Post propagator for .
Definition set.hpp:60
Gecode::Set::Channel::ChannelSet::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_QUADRATIC_HI).
Definition set.hpp:79
Gecode::Set::Channel::ChannelSet::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition set.hpp:101
Gecode::Set::Channel::ChannelSet::ChannelSet
ChannelSet(Space &home, ChannelSet &p)
Constructor for cloning p.
Definition set.hpp:52
Gecode::Set::Channel::ChannelSet::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition set.hpp:107
Gecode::Set::Channel::ChannelSet::xs
ViewArray< CachedView< View > > xs
SetViews, reflects the successors of .
Definition channel.hh:229
Gecode::Set::Channel::ChannelSet::ys
ViewArray< CachedView< View > > ys
SetViews, reflects the predecessors of .
Definition channel.hh:231
Gecode::Set::Channel::ChannelSorted::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition sorted.hpp:90
Gecode::Set::Channel::ChannelSorted::ChannelSorted
ChannelSorted(Space &home, ChannelSorted &p)
Constructor for cloning p.
Definition sorted.hpp:57
Gecode::Set::Channel::ChannelSorted::post
static ExecStatus post(Home home, View s, ViewArray< Gecode::Int::IntView > &x)
Post propagator that propagates that s contains the , which are sorted in non-descending order.
Definition sorted.hpp:65
Gecode::Set::Channel::ChannelSorted::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition sorted.hpp:106
Gecode::Set::Channel::ChannelSorted::dispose
virtual size_t dispose(Space &home)
Delete Propagator.
Definition sorted.hpp:97
Gecode::Set::Channel::ChannelSorted::x0
View x0
SetView for the match.
Definition channel.hh:63
Gecode::Set::Channel::ChannelSorted::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sorted.hpp:112
Gecode::Set::Channel::ChannelSorted::xs
ViewArray< Gecode::Int::IntView > xs
IntViews that together form the set x0.
Definition channel.hh:65
Gecode::Set::Channel::ChannelSorted::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO).
Definition sorted.hpp:84
Gecode::Set::GLBndSet
Growing sets of integers.
Definition var-imp.hpp:205
Gecode::Set::SetDelta
Finite set delta information for advisors.
Definition var-imp.hpp:52
Gecode::View
Gecode::ViewArray
View arrays.
Definition array.hpp:253
int.hpp
set.hpp
set.hh
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Gecode::Int::Channel
Channel propagators
Gecode::Int::PC_BOOL_VAL
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:126
Gecode::Set
Finite integer sets.
Definition var-imp.hpp:137
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
Gecode::PC_GEN_NONE
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience).
Definition core.hpp:74
bool.hpp
sorted.hpp