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

distinct.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  *  Contributing authors:
00008  *     Gabor Szokoli <szokoli@gecode.org>
00009  *
00010  *  Copyright:
00011  *     Christian Schulte, 2002
00012  *     Guido Tack, 2004
00013  *     Gabor Szokoli, 2003
00014  *
00015  *  Last modified:
00016  *     $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00017  *     $Revision: 15137 $
00018  *
00019  *  This file is part of Gecode, the generic constraint
00020  *  development environment:
00021  *     http://www.gecode.org
00022  *
00023  *  Permission is hereby granted, free of charge, to any person obtaining
00024  *  a copy of this software and associated documentation files (the
00025  *  "Software"), to deal in the Software without restriction, including
00026  *  without limitation the rights to use, copy, modify, merge, publish,
00027  *  distribute, sublicense, and/or sell copies of the Software, and to
00028  *  permit persons to whom the Software is furnished to do so, subject to
00029  *  the following conditions:
00030  *
00031  *  The above copyright notice and this permission notice shall be
00032  *  included in all copies or substantial portions of the Software.
00033  *
00034  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00037  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00038  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00039  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00041  *
00042  */
00043 
00044 #ifndef __GECODE_INT_DISTINCT_HH__
00045 #define __GECODE_INT_DISTINCT_HH__
00046 
00047 #include <gecode/int.hh>
00048 
00049 #include <gecode/int/view-val-graph.hh>
00050 #include <gecode/int/rel.hh>
00051 
00057 namespace Gecode { namespace Int { namespace Distinct {
00058 
00067   template<class View>
00068   class Val : public NaryPropagator<View,PC_INT_VAL> {
00069   protected:
00070     using NaryPropagator<View,PC_INT_VAL>::x;
00071 
00073     Val(Home home, ViewArray<View>& x);
00075     Val(Space& home, bool share, Val<View>& p);
00076   public:
00078     virtual Actor*     copy(Space& home, bool share);
00080     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00082     static ExecStatus post(Home home, ViewArray<View>& x);
00083   };
00084 
00098   template<class View, bool complete>
00099   ExecStatus prop_val(Space& home, ViewArray<View>&);
00100 
00101 
00102 
00128   template<class View>
00129   class Bnd : public Propagator {
00130   protected:
00132     ViewArray<View> x;
00134     ViewArray<View> y;
00136     int min_x;
00138     int max_x;
00140     Bnd(Home home, ViewArray<View>& x);
00142     Bnd(Space& home, bool share, Bnd<View>& p);
00143   public:
00145     static ExecStatus post(Home home, ViewArray<View>& x);
00147     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00154     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00156     virtual void reschedule(Space& home);
00158     virtual Actor* copy(Space& home, bool share);
00160     virtual size_t dispose(Space& home);
00161   };
00162 
00171   template<class View>
00172   ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
00173 
00182   template<class View>
00183   ExecStatus prop_bnd(Space& home, ViewArray<View>& x);
00184 
00185 
00187   template<class View>
00188   class Graph : public ViewValGraph::Graph<View> {
00189   public:
00190     using ViewValGraph::Graph<View>::view;
00191     using ViewValGraph::Graph<View>::n_view;
00192     using ViewValGraph::Graph<View>::val;
00193     using ViewValGraph::Graph<View>::n_val;
00194     using ViewValGraph::Graph<View>::count;
00195     using ViewValGraph::Graph<View>::scc;
00196     using ViewValGraph::Graph<View>::match;
00198     Graph(void);
00200     ExecStatus init(Space& home, ViewArray<View>& x);
00202     bool mark(Space& home);
00204     ExecStatus prune(Space& home, bool& assigned);
00206     bool sync(Space& home);
00207   };
00208 
00219   template<class View>
00220   class DomCtrl {
00221   protected:
00223     Graph<View> g;
00224   public:
00226     DomCtrl(void);
00228     bool available(void);
00230     ExecStatus init(Space& home, ViewArray<View>& x);
00232     ExecStatus sync(Space& home);
00234     ExecStatus propagate(Space& home, bool& assigned);
00235   };
00236 
00252   template<class View>
00253   class Dom : public NaryPropagator<View,PC_INT_DOM> {
00254   protected:
00255     using NaryPropagator<View,PC_INT_DOM>::x;
00257     DomCtrl<View> dc;
00259     Dom(Space& home, bool share, Dom<View>& p);
00261     Dom(Home home, ViewArray<View>& x);
00262   public:
00264     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00271     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00273     virtual Actor* copy(Space& home, bool share);
00275     static ExecStatus post(Home home, ViewArray<View>& x);
00276   };
00277 
00284   template<class View>
00285   class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
00286   protected:
00287     using TernaryPropagator<View,PC_INT_DOM>::x0;
00288     using TernaryPropagator<View,PC_INT_DOM>::x1;
00289     using TernaryPropagator<View,PC_INT_DOM>::x2;
00290 
00292     TerDom(Space& home, bool share, TerDom<View>& p);
00294     TerDom(Home home, View x0, View x1, View x2);
00295   public:
00297     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00299     virtual Actor* copy(Space& home, bool share);
00301     static  ExecStatus post(Home home, View x0, View x1, View x2);
00302   };
00303 
00312   class EqIte : public BinaryPropagator<IntView,PC_INT_DOM> {
00313   protected:
00314     using BinaryPropagator<IntView,PC_INT_DOM>::x0;
00315     using BinaryPropagator<IntView,PC_INT_DOM>::x1;
00317     int c0, c1;
00319     EqIte(Space& home, bool share, EqIte& p);
00321     EqIte(Home home, IntView x0, IntView x1, int c0, int c1);
00322   public:
00324     GECODE_INT_EXPORT
00325     virtual Actor* copy(Space& home, bool share);
00327     GECODE_INT_EXPORT
00328     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00330     GECODE_INT_EXPORT
00331     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00333     static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1);
00334   };
00335 
00336 }}}
00337 
00338 #include <gecode/int/distinct/val.hpp>
00339 #include <gecode/int/distinct/bnd.hpp>
00340 #include <gecode/int/distinct/ter-dom.hpp>
00341 #include <gecode/int/distinct/graph.hpp>
00342 #include <gecode/int/distinct/dom-ctrl.hpp>
00343 #include <gecode/int/distinct/dom.hpp>
00344 #include <gecode/int/distinct/eqite.hpp>
00345 
00346 #endif
00347 
00348 // STATISTICS: int-prop
00349