this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Guido Tack <tack@gecode.org> 5 * Christian Schulte <schulte@gecode.org> 6 * 7 * Copyright: 8 * Guido Tack, 2004 9 * Christian Schulte, 2004 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36#ifndef GECODE_SET_SELECT_HH 37#define GECODE_SET_SELECT_HH 38 39#include <gecode/set.hh> 40 41#include <gecode/int/idx-view.hh> 42#include <gecode/int/element.hh> 43#include <gecode/set/rel.hh> 44#include <gecode/set/rel-op.hh> 45 46namespace Gecode { namespace Int { 47 48 /// VarArg type for %Set views 49 template<> 50 class ViewToVarArg<Gecode::Set::SetView> { 51 public: 52 typedef Gecode::SetVarArgs argtype; 53 }; 54 55 /// VarArg type for singleton views 56 template<> 57 class ViewToVarArg<Gecode::Set::SingletonView> { 58 public: 59 typedef Gecode::IntVarArgs argtype; 60 }; 61 62}} 63 64namespace Gecode { namespace Set { namespace Element { 65 66 /** 67 * \namespace Gecode::Set::Element 68 * \brief %Set element propagators 69 */ 70 71 /** 72 * \brief %Propagator for element with intersection 73 * 74 * Requires \code #include <gecode/set/element.hh> \endcode 75 * \ingroup FuncSetProp 76 */ 77 template<class View, class View0, class View1> 78 class ElementIntersection : public Propagator { 79 public: 80 typedef Gecode::Int::IdxViewArray<View> IdxViewArray; 81 protected: 82 IntSet universe; 83 IdxViewArray iv; 84 View0 x0; 85 View1 x1; 86 87 /// Constructor for cloning \a p 88 ElementIntersection(Space& home, ElementIntersection& p); 89 /// Constructor for posting 90 ElementIntersection(Home home, IdxViewArray&,View0,View1, 91 const IntSet& universe); 92 public: 93 /// Copy propagator during cloning 94 virtual Actor* copy(Space& home); 95 /// Cost function 96 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 97 /// Schedule function 98 virtual void reschedule(Space& home); 99 /// Delete propagator and return its size 100 virtual size_t dispose(Space& home); 101 /// Perform propagation 102 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 103 /** Post propagator for \f$ z=\bigcap\langle x_0,\dots,x_{n-1}\rangle[y] \f$ using \a u as universe 104 * 105 * If \a y is empty, \a z will be constrained to be the given universe 106 * \a u (as an empty intersection is the universe). 107 */ 108 static ExecStatus post(Home home,IdxViewArray& x, View0 y, 109 View1 z, const IntSet& u); 110 }; 111 112 /** 113 * \brief %Propagator for element with union 114 * 115 * Requires \code #include <gecode/set/element.hh> \endcode 116 * \ingroup FuncSetProp 117 */ 118 template<class View, class View0, class View1> 119 class ElementUnion : public Propagator { 120 public: 121 typedef Gecode::Int::IdxViewArray<View> IdxViewArray; 122 protected: 123 IdxViewArray iv; 124 View0 x0; 125 View1 x1; 126 127 /// Constructor for cloning \a p 128 ElementUnion(Space& home, ElementUnion& p); 129 /// Constructor for posting 130 ElementUnion(Home home,IdxViewArray&,View0,View1); 131 public: 132 /// Copy propagator during cloning 133 virtual Actor* copy(Space& home); 134 /// Cost function 135 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 136 /// Schedule function 137 virtual void reschedule(Space& home); 138 /// Delete propagator and return its size 139 virtual size_t dispose(Space& home); 140 /// Perform propagation 141 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 142 /** Post propagator for \f$ z=\bigcup\langle x_0,\dots,x_{n-1}\rangle[y] \f$ 143 * 144 * If \a y is empty, \a z will be constrained to be empty 145 * (as an empty union is the empty set). 146 */ 147 static ExecStatus post(Home home,IdxViewArray& x,View0 y, View1 z); 148 }; 149 150 /** 151 * \brief %Propagator for element with union of constant sets 152 * 153 * Requires \code #include <gecode/set/element.hh> \endcode 154 * \ingroup FuncSetProp 155 */ 156 template<class SView, class RView> 157 class ElementUnionConst : public Propagator { 158 protected: 159 SView x0; 160 IntSet* iv; 161 int n_iv; 162 RView x1; 163 164 /// Constructor for cloning \a p 165 ElementUnionConst(Space& home, ElementUnionConst& p); 166 /// Constructor for posting 167 ElementUnionConst(Home home, SView, const IntSetArgs&, RView); 168 public: 169 /// Copy propagator during cloning 170 virtual Actor* copy(Space& home); 171 /// Cost function 172 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 173 /// Schedule function 174 virtual void reschedule(Space& home); 175 /// Delete propagator and return its size 176 virtual size_t dispose(Space& home); 177 /// Perform propagation 178 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 179 /** Post propagator for \f$ z=\bigcup\langle s_0,\dots,s_{n-1}\rangle[y] \f$ 180 * 181 * If \a y is empty, \a z will be constrained to be empty 182 * (as an empty union is the empty set). 183 */ 184 static ExecStatus post(Home home,SView z,const IntSetArgs& x,RView y); 185 }; 186 187 /** 188 * \brief %Propagator for element with disjointness 189 * 190 * Requires \code #include <gecode/set/element.hh> \endcode 191 * \ingroup FuncSetProp 192 */ 193 template<class SView, class RView> 194 class ElementDisjoint : public Propagator { 195 public: 196 typedef Gecode::Int::IdxViewArray<SView> IdxViewArray; 197 protected: 198 IdxViewArray iv; 199 RView x1; 200 201 /// Constructor for cloning \a p 202 ElementDisjoint(Space& home, ElementDisjoint& p); 203 /// Constructor for posting 204 ElementDisjoint(Home home,IdxViewArray&,RView); 205 public: 206 /// Copy propagator during cloning 207 virtual Actor* copy(Space& home); 208 /// Cost function 209 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 210 /// Schedule function 211 virtual void reschedule(Space& home); 212 /// Delete propagator and return its size 213 virtual size_t dispose(Space& home); 214 /// Perform propagation 215 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 216 /// Post propagator for \f$ \parallel\langle x_0,\dots,x_{n-1}\rangle[y] \f$ 217 static ExecStatus post(Home home,IdxViewArray& x,RView y); 218 }; 219 220}}} 221 222#include <gecode/set/element/inter.hpp> 223#include <gecode/set/element/union.hpp> 224#include <gecode/set/element/unionConst.hpp> 225#include <gecode/set/element/disjoint.hpp> 226 227#endif 228 229// STATISTICS: set-prop 230