Generated on Mon Aug 25 11:35:37 2008 for Gecode by doxygen 1.5.6

element.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  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2004
00009  *     Guido Tack, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2008-07-11 09:28:48 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00013  *     $Revision: 7285 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_INT_ELEMENT_HH__
00041 #define __GECODE_INT_ELEMENT_HH__
00042 
00043 #include "gecode/int.hh"
00044 #include "gecode/int/rel.hh"
00045 
00051 namespace Gecode { namespace Int { namespace Element {
00052 
00053   /*
00054    * Element constraint for array of integers
00055    *
00056    */
00057 
00058   typedef SharedArray<int> IntSharedArray;
00059 
00061   class IdxValMap;
00062 
00069   template <class ViewA, class ViewB>
00070   class Int : public Propagator {
00071   protected:
00073     ViewA          x0;
00075     ViewB          x1;
00077     IntSharedArray c;
00079     IdxValMap*     ivm;
00081     Int(Space* home, bool shared, Int& p);
00083     Int(Space* home, IntSharedArray& i, ViewA x0, ViewB x1);
00084   public:
00086     virtual Actor* copy(Space* home, bool share);
00088     virtual PropCost cost(ModEventDelta med) const;
00090     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00092     virtual Reflection::ActorSpec spec(const Space* home,
00093                                         Reflection::VarMap& m) const;
00095     static void post(Space* home, Reflection::VarMap& vars,
00096                      const Reflection::ActorSpec& spec);
00098     static Support::Symbol ati(void);
00100     static  ExecStatus post(Space* home, IntSharedArray& i,
00101                             ViewA x0, ViewB x1);
00103     virtual size_t allocated(void) const;
00105     virtual size_t dispose(Space* home);
00106   };
00107 
00108 
00109 
00114   template <class ViewB> class IdxView;
00115 
00120   template <class VA, class VB, class VC, PropCond pc_ac>
00121   class View : public Propagator {
00122   protected:
00124     IdxView<VA>* iv;
00126     int n;
00128     VB x0;
00130     VC x1;
00132     View(Space* home, bool share, View& p);
00134     View(Space* home, IdxView<VA>* iv, int n, VB x0, VC x1);
00136     Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00137                                 const Support::Symbol& name) const;
00138   public:
00139     // Cost function (defined as dynamic PC_LINEAR_LO)
00140     virtual PropCost cost(ModEventDelta med) const;
00142     virtual size_t dispose(Space* home);
00143   };
00144 
00145 
00152   template <class VA, class VB, class VC>
00153   class ViewBnd : public View<VA,VB,VC,PC_INT_BND> {
00154   protected:
00155     using View<VA,VB,VC,PC_INT_BND>::iv;
00156     using View<VA,VB,VC,PC_INT_BND>::n;
00157     using View<VA,VB,VC,PC_INT_BND>::x0;
00158     using View<VA,VB,VC,PC_INT_BND>::x1;
00159 
00161     ViewBnd(Space* home, bool share, ViewBnd& p);
00163     ViewBnd(Space* home, IdxView<VA>* iv, int n, VB x0, VC x1);
00164   public:
00166     virtual Actor* copy(Space* home, bool share);
00168     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00170     virtual Reflection::ActorSpec spec(const Space* home,
00171                                         Reflection::VarMap& m) const;
00173     static void post(Space* home, Reflection::VarMap& vars,
00174                      const Reflection::ActorSpec& spec);
00176     static Support::Symbol ati(void);
00178     static  ExecStatus post(Space* home, IdxView<VA>* iv, int n,
00179                             VB x0, VC x1);
00180   };
00181 
00192   template <class VA, class VB, class VC>
00193   class ViewDom : public View<VA,VB,VC,PC_INT_DOM> {
00194   protected:
00195     using View<VA,VB,VC,PC_INT_DOM>::iv;
00196     using View<VA,VB,VC,PC_INT_DOM>::n;
00197     using View<VA,VB,VC,PC_INT_DOM>::x0;
00198     using View<VA,VB,VC,PC_INT_DOM>::x1;
00199 
00201     ViewDom(Space* home, bool share, ViewDom& p);
00203     ViewDom(Space* home, IdxView<VA>* iv, int n, VB x0, VC x1);
00204   public:
00206     virtual Actor* copy(Space* home, bool share);
00214     virtual PropCost cost(ModEventDelta med) const;
00216     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00218     virtual Reflection::ActorSpec spec(const Space* home,
00219                                         Reflection::VarMap& m) const;
00221     static void post(Space* home, Reflection::VarMap& vars,
00222                      const Reflection::ActorSpec& spec);
00224     static Support::Symbol ati(void);
00226     static  ExecStatus post(Space* home, IdxView<VA>* iv, int n,
00227                             VB x0, VC x1);
00228   };
00229 
00230 }}}
00231 
00232 #include "gecode/int/element/int.icc"
00233 #include "gecode/int/element/view.icc"
00234 
00235 #endif
00236 
00237 
00238 // STATISTICS: int-prop
00239