Generated on Tue Apr 18 10:21:38 2017 for Gecode by doxygen 1.6.3

channel.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Denys Duchier <denys.duchier@univ-orleans.fr>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Christian Schulte <schulte@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Denys Duchier, 2011
00010  *     Guido Tack, 2011
00011  *     Christian Schulte, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00015  *     $Revision: 15137 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #ifndef __GECODE_SET_CHANNEL_HH__
00043 #define __GECODE_SET_CHANNEL_HH__
00044 
00045 #include <gecode/set.hh>
00046 
00047 namespace Gecode { namespace Set { namespace Channel {
00048 
00063   template<class View>
00064   class ChannelSorted : public Propagator {
00065   protected:
00067     View x0;
00069     ViewArray<Gecode::Int::IntView> xs;
00070 
00072     ChannelSorted(Space& home, bool share,ChannelSorted& p);
00074     ChannelSorted(Home home, View, ViewArray<Gecode::Int::IntView>&);
00075   public:
00077     virtual Actor* copy(Space& home,bool);
00079     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00081     virtual void reschedule(Space& home);
00083     virtual size_t dispose(Space& home);
00085     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00087     static ExecStatus post(Home home, View s,
00088                            ViewArray<Gecode::Int::IntView>& x);
00089   };
00090 
00108   template<class View>
00109   class ChannelInt : public Propagator {
00110   protected:
00112     ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> > xs;
00114     ViewArray<CachedView<View> > ys;
00115 
00117     ChannelInt(Space& home, bool share,ChannelInt& p);
00119     ChannelInt(Home home,
00120                ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> >&,
00121                ViewArray<CachedView<View> >&);
00122   public:
00124     virtual Actor* copy(Space& home, bool share);
00126     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00128     virtual void reschedule(Space& home);
00130     virtual size_t dispose(Space& home);
00132     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00134     static ExecStatus post(Home home,
00135                            ViewArray<Gecode::Int::CachedView<
00136                             Gecode::Int::IntView> >& x,
00137                            ViewArray<CachedView<View> >& y);
00138   };
00139 
00151   template<class View>
00152   class ChannelBool
00153     : public MixNaryOnePropagator<Gecode::Int::BoolView,
00154                                   Gecode::Int::PC_BOOL_VAL,
00155                                   View,PC_GEN_NONE> {
00156   protected:
00157     typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00158                                  Gecode::Int::PC_BOOL_VAL,
00159                                  View,PC_GEN_NONE> Super;
00160     using Super::x;
00161     using Super::y;
00162 
00164     ChannelBool(Space& home, bool share,ChannelBool& p);
00166     ChannelBool(Home home,ViewArray<Gecode::Int::BoolView>&,
00167                 View);
00168 
00170     class IndexAdvisor : public Advisor {
00171     protected:
00173       int idx;
00174     public:
00176       template<class A>
00177       IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
00178                    int index);
00180       IndexAdvisor(Space& home, bool share, IndexAdvisor& a);
00182       int index(void) const;
00184       template<class A>
00185       void dispose(Space& home, Council<A>& c);
00186     };
00187 
00189     Council<IndexAdvisor> co;
00191     SetDelta delta;
00193     GLBndSet zeros;
00195     GLBndSet ones;
00197     bool running;
00198   public:
00200     virtual Actor*   copy(Space& home,bool);
00202     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00204     virtual void reschedule(Space& home);
00206     virtual size_t dispose(Space& home);
00208     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00210     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00212     static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
00213                            View y);
00214   };
00215 
00229   template<typename View>
00230   class ChannelSet: public Propagator {
00231   protected:
00233     ViewArray<CachedView<View> > xs;
00235     ViewArray<CachedView<View> > ys;
00236 
00238     ChannelSet(Space& home, bool share, ChannelSet& p);
00240     ChannelSet(Home home,
00241                ViewArray<CachedView<View> >&,
00242                ViewArray<CachedView<View> >&);
00243   public:
00245     virtual Actor* copy(Space& home, bool);
00247     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00249     virtual void reschedule(Space& home);
00251     virtual size_t dispose(Space& home);
00253     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00255     static ExecStatus post(Home home,
00256                            ViewArray<CachedView<View> >& x,
00257                            ViewArray<CachedView<View> >& y);
00258   };
00259 
00260 }}}
00261 
00262 #include <gecode/set/channel/sorted.hpp>
00263 #include <gecode/set/channel/int.hpp>
00264 #include <gecode/set/channel/bool.hpp>
00265 #include <gecode/set/channel/set.hpp>
00266 
00267 #endif
00268 
00269 // STATISTICS: set-prop