Generated on Wed Jul 27 2011 15:08:39 for Gecode by doxygen 1.7.4
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  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00011  *     $Revision: 9878 $
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_INT_CHANNEL_HH__
00039 #define __GECODE_INT_CHANNEL_HH__
00040 
00041 #include <gecode/int.hh>
00042 #include <gecode/int/distinct.hh>
00043 
00049 namespace Gecode { namespace Int { namespace Channel {
00050 
00052   typedef Support::StaticStack<int,Region> ProcessStack;
00053 
00058   template<class Info, PropCond pc>
00059   class Base : public Propagator {
00060   protected:
00062     int n;
00064     int n_na;
00066     Info* xy;
00068     Base(Space& home, bool share, Base<Info,pc>& p);
00070     Base(Home home, int n, Info* xy);
00071   public:
00073     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00075     virtual size_t dispose(Space& home);
00076   };
00077 
00078 
00083   template<class View> class ValInfo;
00084 
00094   template<class View, bool shared>
00095   class Val : public Base<ValInfo<View>,PC_INT_VAL> {
00096  protected:
00097     using Base<ValInfo<View>,PC_INT_VAL>::n;
00098     using Base<ValInfo<View>,PC_INT_VAL>::n_na;
00099     using Base<ValInfo<View>,PC_INT_VAL>::xy;
00101     Val(Space& home, bool share, Val& p);
00103     Val(Home home, int n, ValInfo<View>* xy);
00104   public:
00106     virtual Actor* copy(Space& home, bool share);
00108     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00110     static  ExecStatus post(Home home, int n, ValInfo<View>* xy);
00111   };
00112 
00117   template<class View> class DomInfo;
00118 
00128   template<class View, bool shared>
00129   class Dom : public Base<DomInfo<View>,PC_INT_DOM> {
00130   protected:
00131     using Base<DomInfo<View>,PC_INT_DOM>::n;
00132     using Base<DomInfo<View>,PC_INT_DOM>::n_na;
00133     using Base<DomInfo<View>,PC_INT_DOM>::xy;
00135     Distinct::DomCtrl<View> dc;
00137     Dom(Space& home, bool share, Dom& p);
00139     Dom(Home home, int n, DomInfo<View>* xy);
00140   public:
00142     virtual Actor* copy(Space& home, bool share);
00149     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00151     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00153     static  ExecStatus post(Home home, int n, DomInfo<View>* xy);
00154   };
00155 
00162   class LinkSingle :
00163     public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
00164   private:
00165     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
00166     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
00167 
00169     LinkSingle(Space& home, bool share, LinkSingle& p);
00171     LinkSingle(Home home, BoolView x0, IntView x1);
00172   public:
00174     virtual Actor* copy(Space& home, bool share);
00176     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00178     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00180     static  ExecStatus post(Home home, BoolView x0, IntView x1);
00181   };
00182 
00189   class LinkMulti :
00190     public MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM> {
00191   private:
00192     using MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM>::x;
00193     using MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM>::y;
00195     int o;
00197     LinkMulti(Space& home, bool share, LinkMulti& p);
00199     LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
00200   public:
00202     virtual Actor* copy(Space& home, bool share);
00204     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00206     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00208     GECODE_INT_EXPORT
00209     static  ExecStatus post(Home home,
00210                             ViewArray<BoolView>& x, IntView y, int o);
00211   };
00212 
00213 }}}
00214 
00215 #include <gecode/int/channel/base.hpp>
00216 #include <gecode/int/channel/val.hpp>
00217 #include <gecode/int/channel/dom.hpp>
00218 
00219 #include <gecode/int/channel/link-single.hpp>
00220 #include <gecode/int/channel/link-multi.hpp>
00221 
00222 #endif
00223 
00224 // STATISTICS: int-prop
00225