Generated on Fri Mar 20 15:56:06 2015 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: 2011-11-03 11:52:07 +0100 (Thu, 03 Nov 2011) $ by $Author: tack $
00015  *     $Revision: 12452 $
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 size_t dispose(Space& home);
00083     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00085     static ExecStatus post(Home home, View s,
00086                            ViewArray<Gecode::Int::IntView>& x);
00087   };
00088 
00106   template<class View>
00107   class ChannelInt : public Propagator {
00108   protected:
00110     ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> > xs;
00112     ViewArray<CachedView<View> > ys;
00113 
00115     ChannelInt(Space& home, bool share,ChannelInt& p);
00117     ChannelInt(Home home,
00118                ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> >&,
00119                ViewArray<CachedView<View> >&);
00120   public:
00122     virtual Actor*   copy(Space& home,bool);
00124     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
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, bool share,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, bool share, 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,bool);
00198     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00200     virtual size_t dispose(Space& home);
00202     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00204     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00206     static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
00207                            View y);
00208   };
00209 
00223   template<typename View>
00224   class ChannelSet: public Propagator {
00225   protected:
00227     ViewArray<CachedView<View> > xs;
00229     ViewArray<CachedView<View> > ys;
00230 
00232     ChannelSet(Space& home, bool share, ChannelSet& p);
00234     ChannelSet(Home home,
00235                ViewArray<CachedView<View> >&,
00236                ViewArray<CachedView<View> >&);
00237   public:
00239     virtual Actor* copy(Space& home, bool);
00241     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00243     virtual size_t dispose(Space& home);
00245     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00247     static ExecStatus post(Home home,
00248                            ViewArray<CachedView<View> >& x,
00249                            ViewArray<CachedView<View> >& y);
00250   };
00251 
00252 }}}
00253 
00254 #include <gecode/set/channel/sorted.hpp>
00255 #include <gecode/set/channel/int.hpp>
00256 #include <gecode/set/channel/bool.hpp>
00257 #include <gecode/set/channel/set.hpp>
00258 
00259 #endif
00260 
00261 // STATISTICS: set-prop