Generated on Mon Nov 30 23:53:20 2009 for Gecode by doxygen 1.6.1

int.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Guido Tack, 2004
00009  *     Christian Schulte, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00013  *     $Revision: 9878 $
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_SET_INT_HH__
00041 #define __GECODE_SET_INT_HH__
00042 
00043 #include <gecode/set.hh>
00044 
00045 namespace Gecode { namespace Set { namespace Int {
00046 
00058   template<class View>
00059   class MinElement :
00060     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00061   protected:
00062     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00063     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00065     MinElement(Space& home, bool share,MinElement& p);
00067     MinElement(Home home, View, Gecode::Int::IntView);
00068   public:
00070     virtual Actor* copy(Space& home,bool);
00072     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00074     static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
00075   };
00076 
00083   template<class View>
00084   class NotMinElement :
00085     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00086   protected:
00087     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00088     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00090     NotMinElement(Space& home, bool share,NotMinElement& p);
00092     NotMinElement(Home home, View, Gecode::Int::IntView);
00093   public:
00095     virtual Actor* copy(Space& home,bool);
00097     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00099     static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
00100   };
00101 
00108   template<class View>
00109   class ReMinElement :
00110     public IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00111   protected:
00112     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00113     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00114     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::b;
00116     ReMinElement(Space& home, bool share,ReMinElement& p);
00118     ReMinElement(Home home, View, Gecode::Int::IntView,
00119                  Gecode::Int::BoolView);
00120   public:
00122     virtual Actor* copy(Space& home,bool);
00124     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00126     static ExecStatus post(Home home, View s, Gecode::Int::IntView x,
00127                            Gecode::Int::BoolView b);
00128   };
00129 
00136   template<class View>
00137   class MaxElement :
00138     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00139   protected:
00140     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00141     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00143     MaxElement(Space& home, bool share,MaxElement& p);
00145     MaxElement(Home home, View, Gecode::Int::IntView);
00146   public:
00148     virtual Actor* copy(Space& home,bool);
00150     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00152     static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
00153   };
00154 
00161   template<class View>
00162   class NotMaxElement :
00163     public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00164   protected:
00165     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00166     using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00168     NotMaxElement(Space& home, bool share,NotMaxElement& p);
00170     NotMaxElement(Home home, View, Gecode::Int::IntView);
00171   public:
00173     virtual Actor* copy(Space& home,bool);
00175     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00177     static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
00178   };
00179 
00186   template<class View>
00187   class ReMaxElement :
00188     public IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00189   protected:
00190     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00191     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00192     using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::b;
00194     ReMaxElement(Space& home, bool share,ReMaxElement& p);
00196     ReMaxElement(Home home, View, Gecode::Int::IntView, Gecode::Int::BoolView);
00197   public:
00199     virtual Actor* copy(Space& home,bool);
00201     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00203     static ExecStatus post(Home home, View s, Gecode::Int::IntView x,
00204                            Gecode::Int::BoolView b);
00205   };
00206 
00213   template<class View>
00214   class Card :
00215     public IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND> {
00216   protected:
00217     using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x0;
00218     using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x1;
00220     Card(Space& home, bool share,Card& p);
00222     Card(Home home, View, Gecode::Int::IntView);
00223   public:
00225     virtual Actor* copy(Space& home,bool);
00227     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00229     static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
00230   };
00231 
00232 
00239   template<class View>
00240   class Match : public Propagator {
00241   protected:
00243     View x0;
00245     ViewArray<Gecode::Int::IntView> xs;
00246 
00248     Match(Space& home, bool share,Match& p);
00250     Match(Home home, View, ViewArray<Gecode::Int::IntView>&);
00251   public:
00253     virtual Actor* copy(Space& home,bool);
00255     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00257     virtual size_t dispose(Space& home);
00259     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00261     static ExecStatus post(Home home, View s,
00262                            ViewArray<Gecode::Int::IntView>& x);
00263   };
00264 
00282   template<class View>
00283   class ChannelInt : public Propagator {
00284   protected:
00286     ViewArray<Gecode::Int::IntView> xs;
00288     ViewArray<View> ys;
00289 
00291     ChannelInt(Space& home, bool share,ChannelInt& p);
00293     ChannelInt(Home home,ViewArray<Gecode::Int::IntView>&,
00294                ViewArray<View>&);
00295   public:
00297     virtual Actor*   copy(Space& home,bool);
00299     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00301     virtual size_t dispose(Space& home);
00303     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00305     static ExecStatus post(Home home,ViewArray<Gecode::Int::IntView>& x,
00306                            ViewArray<View>& y);
00307   };
00308 
00320   template<class View>
00321   class ChannelBool
00322     : public MixNaryOnePropagator<Gecode::Int::BoolView,
00323                                   Gecode::Int::PC_BOOL_VAL,
00324                                   View,PC_GEN_NONE> {
00325   protected:
00326     typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00327                                  Gecode::Int::PC_BOOL_VAL,
00328                                  View,PC_GEN_NONE> Super;
00329     using Super::x;
00330     using Super::y;
00331 
00333     ChannelBool(Space& home, bool share,ChannelBool& p);
00335     ChannelBool(Home home,ViewArray<Gecode::Int::BoolView>&,
00336                 View);
00337 
00339     class IndexAdvisor : public Advisor {
00340     protected:
00342       int idx;
00343     public:
00345       template<class A>
00346       IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
00347                    int index);
00349       IndexAdvisor(Space& home, bool share, IndexAdvisor& a);
00351       int index(void) const;
00353       template<class A>
00354       void dispose(Space& home, Council<A>& c);
00355     };
00356 
00358     Council<IndexAdvisor> co;
00360     SetDelta delta;
00362     GLBndSet zeros;
00364     GLBndSet ones;
00366     bool running;
00367   public:
00369     virtual Actor*   copy(Space& home,bool);
00371     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00373     virtual size_t dispose(Space& home);
00375     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00377     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00379     static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
00380                            View y);
00381   };
00382 
00389   template<class View>
00390   class Weights : public Propagator {
00391   protected:
00393     SharedArray<int> elements;
00395     SharedArray<int> weights;
00396 
00398     View x;
00400     Gecode::Int::IntView y;
00401 
00403     Weights(Space& home, bool share,Weights& p);
00405     Weights(Home home, const SharedArray<int>&, const SharedArray<int>&,
00406             View, Gecode::Int::IntView);
00407   public:
00409     virtual Actor* copy(Space& home,bool);
00411     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00413     virtual size_t dispose(Space& home);
00415     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00417     static ExecStatus post(Home home,
00418                            const SharedArray<int>& elements,
00419                            const SharedArray<int>& weights,
00420                            View x, Gecode::Int::IntView y);
00421   };
00422 
00423 }}}
00424 
00425 #include <gecode/set/int/minmax.hpp>
00426 #include <gecode/set/int/card.hpp>
00427 #include <gecode/set/int/match.hpp>
00428 #include <gecode/set/int/channel-int.hpp>
00429 #include <gecode/set/int/channel-bool.hpp>
00430 #include <gecode/set/int/weights.hpp>
00431 
00432 #endif
00433 
00434 // STATISTICS: set-prop