channel.hh
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.
*
*/
#ifndef __GECODE_INT_CHANNEL_HH__
#define __GECODE_INT_CHANNEL_HH__
#include <gecode/int.hh>
#include <gecode/int/distinct.hh>
namespace Gecode { namespace Int { namespace Channel {
typedef Support::StaticStack<int,Region> ProcessStack;
template<class Info, class Offset, PropCond pc>
class Base : public Propagator {
protected:
int n;
int n_na;
Offset ox;
Offset oy;
Info* xy;
Base(Space& home, Base<Info,Offset,pc>& p);
Base(Home home, int n, Info* xy, Offset& ox, Offset& oy);
public:
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
};
template<class View> class ValInfo;
template<class View, class Offset, bool shared>
class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
protected:
using Base<ValInfo<View>,Offset,PC_INT_VAL>::n;
using Base<ValInfo<View>,Offset,PC_INT_VAL>::n_na;
using Base<ValInfo<View>,Offset,PC_INT_VAL>::xy;
using Base<ValInfo<View>,Offset,PC_INT_VAL>::ox;
using Base<ValInfo<View>,Offset,PC_INT_VAL>::oy;
Val(Space& home, Val& p);
Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, int n, ValInfo<View>* xy,
Offset& ox, Offset& oy);
};
template<class View, class Offset> class DomInfo;
template<class View, class Offset, bool shared>
class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
protected:
using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n;
using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n_na;
using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::xy;
using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::ox;
using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::oy;
Distinct::DomCtrl<View> dc;
Dom(Space& home, Dom& p);
Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
Offset& ox, Offset& oy);
};
class LinkSingle :
public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
private:
using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
LinkSingle(Space& home, LinkSingle& p);
LinkSingle(Home home, BoolView x0, IntView x1);
public:
virtual Actor* copy(Space& home);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, BoolView x0, IntView x1);
};
class LinkMulti :
public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
private:
using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::x;
using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::y;
Council<Advisor> c;
static const int S_NONE = 0;
static const int S_ONE = 1;
static const int S_RUN = 2;
int status;
int o;
LinkMulti(Space& home, LinkMulti& p);
LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
public:
GECODE_INT_EXPORT
virtual Actor* copy(Space& home);
GECODE_INT_EXPORT
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
GECODE_INT_EXPORT
virtual void reschedule(Space& home);
GECODE_INT_EXPORT
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
GECODE_INT_EXPORT
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home,
ViewArray<BoolView>& x, IntView y, int o);
GECODE_INT_EXPORT
virtual size_t dispose(Space& home);
};
}}}
#include <gecode/int/channel/base.hpp>
#include <gecode/int/channel/val.hpp>
#include <gecode/int/channel/dom.hpp>
#include <gecode/int/channel/link-single.hpp>
#include <gecode/int/channel/link-multi.hpp>
#endif
// STATISTICS: int-prop
dom.hpp
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
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::Channel::Base::Base
Base(Space &home, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition base.hpp:47
Gecode::Int::Channel::Base::oy
Offset oy
Offset transformation for y variables.
Definition channel.hh:64
Gecode::Int::Channel::Base::n
int n
Number of views (actually twice as many for both x and y).
Definition channel.hh:58
Gecode::Int::Channel::Base::ox
Offset ox
Offset transformation for x variables.
Definition channel.hh:62
Gecode::Int::Channel::Base::n_na
int n_na
Total number of not assigned views (not known to be assigned).
Definition channel.hh:60
Gecode::Int::Channel::Base::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition base.hpp:71
Gecode::Int::Channel::Base::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Propagation cost (defined as low quadratic).
Definition base.hpp:58
Gecode::Int::Channel::Base::xy
Info * xy
View and information for both x and y.
Definition channel.hh:66
Gecode::Int::Channel::Base::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition base.hpp:64
Gecode::Int::Channel::DomInfo
Combine view with information for domain propagation.
Definition dom.hpp:45
Gecode::Int::Channel::Dom::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition dom.hpp:196
Gecode::Int::Channel::Dom::post
static ExecStatus post(Home home, int n, DomInfo< View, Offset > *xy, Offset &ox, Offset &oy)
Post propagator for channeling on xy.
Definition dom.hpp:307
Gecode::Int::Channel::Dom::Dom
Dom(Space &home, Dom &p)
Constructor for cloning p.
Gecode::Int::Channel::Dom::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition dom.hpp:180
Gecode::Int::Channel::Dom::dc
Distinct::DomCtrl< View > dc
Propagation controller for propagating distinct.
Definition channel.hh:142
Gecode::Int::Channel::Dom::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition dom.hpp:186
Gecode::Int::Channel::LinkMulti::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (low unary if y is assigned, low linear otherwise).
Definition link-multi.cpp:97
Gecode::Int::Channel::LinkMulti::post
static ExecStatus post(Home home, ViewArray< BoolView > &x, IntView y, int o)
Post propagator for .
Definition link-multi.hpp:53
Gecode::Int::Channel::LinkMulti::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition link-multi.cpp:122
Gecode::Int::Channel::LinkMulti::advise
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition link-multi.cpp:112
Gecode::Int::Channel::LinkMulti::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition link-multi.cpp:82
Gecode::Int::Channel::LinkMulti::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition link-multi.cpp:87
Gecode::Int::Channel::LinkMulti::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition link-multi.cpp:105
Gecode::Int::Channel::LinkSingle::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary).
Definition link-single.cpp:49
Gecode::Int::Channel::LinkSingle::post
static ExecStatus post(Home home, BoolView x0, IntView x1)
Post propagator for .
Definition link-single.hpp:42
Gecode::Int::Channel::LinkSingle::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition link-single.cpp:54
Gecode::Int::Channel::LinkSingle::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition link-single.cpp:44
Gecode::Int::Channel::ValInfo
Combine view with information for value propagation.
Definition val.hpp:45
Gecode::Int::Channel::Val::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition val.hpp:193
Gecode::Int::Channel::Val::post
static ExecStatus post(Home home, int n, ValInfo< View > *xy, Offset &ox, Offset &oy)
Post propagator for channeling.
Definition val.hpp:230
Gecode::Int::Channel::Val::Val
Val(Space &home, Val &p)
Constructor for cloning p.
Gecode::Int::Channel::Val::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition val.hpp:199
Gecode::Int::Distinct::DomCtrl
Propagation controller for domain consistent distinct.
Definition distinct.hh:250
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::Int::Offset
Converter with fixed offset.
Definition view.hpp:650
Gecode::MixBinaryPropagator< BoolView, PC_BOOL_VAL, IntView, PC_INT_VAL >::x1
IntView x1
Definition pattern.hpp:209
Gecode::MixBinaryPropagator< BoolView, PC_BOOL_VAL, IntView, PC_INT_VAL >::MixBinaryPropagator
MixBinaryPropagator(Space &home, MixBinaryPropagator &p)
Definition pattern.hpp:597
Gecode::MixBinaryPropagator< BoolView, PC_BOOL_VAL, IntView, PC_INT_VAL >::x0
BoolView x0
Definition pattern.hpp:207
Gecode::MixNaryOnePropagator< BoolView, PC_BOOL_NONE, IntView, PC_INT_DOM >::MixNaryOnePropagator
MixNaryOnePropagator(Space &home, MixNaryOnePropagator &p)
Definition pattern.hpp:733
Gecode::MixNaryOnePropagator< BoolView, PC_BOOL_NONE, IntView, PC_INT_DOM >::x
ViewArray< BoolView > x
Definition pattern.hpp:275
Gecode::MixNaryOnePropagator< BoolView, PC_BOOL_NONE, IntView, PC_INT_DOM >::y
IntView 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::Support::StaticStack
Stack with fixed number of elements.
Definition static-stack.hpp:42
Gecode::ViewArray
View arrays.
Definition array.hpp:253
int.hh
GECODE_INT_EXPORT
#define GECODE_INT_EXPORT
Definition int.hh:81
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
base.hpp
val.hpp
distinct.hh
link-multi.hpp
link-single.hpp
Gecode::Int::Channel
Channel propagators
Gecode::Int::Channel::ProcessStack
Support::StaticStack< int, Region > ProcessStack
Processing stack.
Definition channel.hh:48
Gecode::Int
Finite domain integers.
Gecode::Int::PC_INT_VAL
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:82
Gecode::Int::PC_BOOL_NONE
const Gecode::PropCond PC_BOOL_NONE
Propagation condition to be ignored (convenience).
Definition var-type.hpp:118
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::Int::PC_INT_DOM
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition var-type.hpp:100
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472