Generated on Thu Apr 11 13:58:58 2019 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  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #ifndef __GECODE_SET_CHANNEL_HH__
00039 #define __GECODE_SET_CHANNEL_HH__
00040 
00041 #include <gecode/set.hh>
00042 
00043 namespace Gecode { namespace Set { namespace Channel {
00044 
00059   template<class View>
00060   class ChannelSorted : public Propagator {
00061   protected:
00063     View x0;
00065     ViewArray<Gecode::Int::IntView> xs;
00066 
00068     ChannelSorted(Space& home, ChannelSorted& p);
00070     ChannelSorted(Home home, View, ViewArray<Gecode::Int::IntView>&);
00071   public:
00073     virtual Actor* copy(Space& home);
00075     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00077     virtual void reschedule(Space& home);
00079     virtual size_t dispose(Space& home);
00081     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00083     static ExecStatus post(Home home, View s,
00084                            ViewArray<Gecode::Int::IntView>& x);
00085   };
00086 
00104   template<class View>
00105   class ChannelInt : public Propagator {
00106   protected:
00108     ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> > xs;
00110     ViewArray<CachedView<View> > ys;
00111 
00113     ChannelInt(Space& home, ChannelInt& p);
00115     ChannelInt(Home home,
00116                ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> >&,
00117                ViewArray<CachedView<View> >&);
00118   public:
00120     virtual Actor* copy(Space& home);
00122     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00124     virtual void reschedule(Space& home);
00126     virtual size_t dispose(Space& home);
00128     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00130     static ExecStatus post(Home home,
00131                            ViewArray<Gecode::Int::CachedView<
00132                             Gecode::Int::IntView> >& x,
00133                            ViewArray<CachedView<View> >& y);
00134   };
00135 
00147   template<class View>
00148   class ChannelBool
00149     : public MixNaryOnePropagator<Gecode::Int::BoolView,
00150                                   Gecode::Int::PC_BOOL_VAL,
00151                                   View,PC_GEN_NONE> {
00152   protected:
00153     typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00154                                  Gecode::Int::PC_BOOL_VAL,
00155                                  View,PC_GEN_NONE> Super;
00156     using Super::x;
00157     using Super::y;
00158 
00160     ChannelBool(Space& home, ChannelBool& p);
00162     ChannelBool(Home home,ViewArray<Gecode::Int::BoolView>&,
00163                 View);
00164 
00166     class IndexAdvisor : public Advisor {
00167     protected:
00169       int idx;
00170     public:
00172       template<class A>
00173       IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
00174                    int index);
00176       IndexAdvisor(Space& home, IndexAdvisor& a);
00178       int index(void) const;
00180       template<class A>
00181       void dispose(Space& home, Council<A>& c);
00182     };
00183 
00185     Council<IndexAdvisor> co;
00187     SetDelta delta;
00189     GLBndSet zeros;
00191     GLBndSet ones;
00193     bool running;
00194   public:
00196     virtual Actor* copy(Space& home);
00198     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00200     virtual void reschedule(Space& home);
00202     virtual size_t dispose(Space& home);
00204     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00206     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00208     static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
00209                            View y);
00210   };
00211 
00225   template<typename View>
00226   class ChannelSet: public Propagator {
00227   protected:
00229     ViewArray<CachedView<View> > xs;
00231     ViewArray<CachedView<View> > ys;
00232 
00234     ChannelSet(Space& home, ChannelSet& p);
00236     ChannelSet(Home home,
00237                ViewArray<CachedView<View> >&,
00238                ViewArray<CachedView<View> >&);
00239   public:
00241     virtual Actor* copy(Space& home);
00243     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00245     virtual void reschedule(Space& home);
00247     virtual size_t dispose(Space& home);
00249     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00251     static ExecStatus post(Home home,
00252                            ViewArray<CachedView<View> >& x,
00253                            ViewArray<CachedView<View> >& y);
00254   };
00255 
00256 }}}
00257 
00258 #include <gecode/set/channel/sorted.hpp>
00259 #include <gecode/set/channel/int.hpp>
00260 #include <gecode/set/channel/bool.hpp>
00261 #include <gecode/set/channel/set.hpp>
00262 
00263 #endif
00264 
00265 // STATISTICS: set-prop