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

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: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00013  *     $Revision: 15137 $
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 #include <gecode/int/idx-view.hh>
00046 
00052 namespace Gecode { namespace Int { namespace Element {
00053 
00060   template<class V0, class V1, class Idx, class Val>
00061   class Int : public Propagator {
00062   protected:
00071     class IdxVal  {
00072     public:
00073       Idx idx_next; 
00074       Idx val_next; 
00075       Idx idx; 
00076       Val val; 
00077 
00078       void mark(void);
00080       bool marked(void) const;
00081     };
00088     class IterIdxUnmark {
00089     private:
00090       IdxVal* iv; 
00091       Idx i; 
00092     public:
00094       IterIdxUnmark(IdxVal* iv);
00096       bool operator ()(void) const;
00098       void operator ++(void);
00100       Idx val(void) const;
00101     };
00108     class IterVal {
00109     private:
00110       IdxVal* iv; 
00111       Idx i; 
00112     public:
00114       IterVal(IdxVal* iv);
00116       bool operator ()(void) const;
00118       void operator ++(void);
00120       Val val(void) const;
00121     };
00130     class IterValUnmark {
00131     private:
00132       IdxVal* iv; 
00133       Idx i; 
00134     public:
00136       IterValUnmark(IdxVal* iv);
00138       bool operator ()(void) const;
00140       void operator ++(void);
00142       Val val(void) const;
00143     };
00145     class ByVal {
00146     protected:
00147       const IdxVal* iv; 
00148     public:
00150       ByVal(const IdxVal* iv);
00152       bool operator ()(Idx& i, Idx& j);
00153     };
00154 
00156     V0 x0;
00158     typedef typename Gecode::Support::IntTypeTraits<Idx>::utype IdxSize;
00160     IdxSize s0;
00162     V1 x1;
00164     typedef typename Gecode::Support::IntTypeTraits<Val>::utype ValSize;
00166     ValSize s1;
00168     IntSharedArray c;
00170     IdxVal* iv;
00172     void prune_idx(void);
00174     void prune_val(void);
00176     static ExecStatus assigned_val(Space& home, IntSharedArray& c,
00177                                    V0 x0, V1 x1);
00179     Int(Space& home, bool shared, Int& p);
00181     Int(Home home, IntSharedArray& i, V0 x0, V1 x1);
00182   public:
00184     virtual Actor* copy(Space& home, bool share);
00186     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00188     virtual void reschedule(Space& home);
00190     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00192     static  ExecStatus post(Home home, IntSharedArray& i, V0 x0, V1 x1);
00194     virtual size_t dispose(Space& home);
00195   };
00196 
00198   template<class V0, class V1>
00199   ExecStatus post_int(Home home, IntSharedArray& c, V0 x0, V1 x1);
00200 
00201 
00206   template<class VA, class VB, class VC, PropCond pc_ac>
00207   class View : public Propagator {
00208   protected:
00210     IdxViewArray<VA> iv;
00212     VB x0;
00214     VC x1;
00216     View(Space& home, bool share, View& p);
00218     View(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00219   public:
00220     // Cost function (defined as low linear)
00221     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00223     virtual void reschedule(Space& home);
00225     virtual size_t dispose(Space& home);
00226   };
00227 
00228 
00235   template<class VA, class VB, class VC>
00236   class ViewBnd : public View<VA,VB,VC,PC_INT_BND> {
00237   protected:
00238     using View<VA,VB,VC,PC_INT_BND>::iv;
00239     using View<VA,VB,VC,PC_INT_BND>::x0;
00240     using View<VA,VB,VC,PC_INT_BND>::x1;
00241 
00243     ViewBnd(Space& home, bool share, ViewBnd& p);
00245     ViewBnd(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00246   public:
00248     virtual Actor* copy(Space& home, bool share);
00250     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00252     static  ExecStatus post(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00253   };
00254 
00265   template<class VA, class VB, class VC>
00266   class ViewDom : public View<VA,VB,VC,PC_INT_DOM> {
00267   protected:
00268     using View<VA,VB,VC,PC_INT_DOM>::iv;
00269     using View<VA,VB,VC,PC_INT_DOM>::x0;
00270     using View<VA,VB,VC,PC_INT_DOM>::x1;
00271 
00273     ViewDom(Space& home, bool share, ViewDom& p);
00275     ViewDom(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00276   public:
00278     virtual Actor* copy(Space& home, bool share);
00286     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00288     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00290     static  ExecStatus post(Home home, IdxViewArray<VA>& iv,
00291                             VB x0, VC x1);
00292   };
00293 
00301   class GECODE_VTABLE_EXPORT Pair
00302     : public TernaryPropagator<IntView,PC_INT_DOM> {
00303   protected:
00304     using TernaryPropagator<IntView,PC_INT_DOM>::x0;
00305     using TernaryPropagator<IntView,PC_INT_DOM>::x1;
00306     using TernaryPropagator<IntView,PC_INT_DOM>::x2;
00308     int w;
00310     Pair(Space& home, bool share, Pair& p);
00311   public:
00313     Pair(Home home, IntView x0, IntView x1, IntView x2, int w);
00315     static ExecStatus post(Home home, IntView x0, IntView x1, IntView x2,
00316                            int w, int h);
00318     GECODE_INT_EXPORT virtual Actor* copy(Space& home, bool share);
00320     GECODE_INT_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00321   };
00322 
00323 }}}
00324 
00325 #include <gecode/int/element/int.hpp>
00326 #include <gecode/int/element/view.hpp>
00327 #include <gecode/int/element/pair.hpp>
00328 
00329 #endif
00330 
00331 
00332 // STATISTICS: int-prop
00333