Generated on Sat Feb 7 2015 02:01:19 for Gecode by doxygen 1.8.9.1
int.hh
Go to the documentation of this file.
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  * Last modified:
12  * $Date: 2013-01-29 21:09:15 +0100 (Tue, 29 Jan 2013) $ by $Author: schulte $
13  * $Revision: 13247 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #ifndef __GECODE_SET_INT_HH__
41 #define __GECODE_SET_INT_HH__
42 
43 #include <gecode/set.hh>
44 
45 namespace Gecode { namespace Set { namespace Int {
46 
58  template<class View>
59  class MinElement :
60  public MixBinaryPropagator<View,PC_SET_ANY,
61  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> {
62  protected:
66  Gecode::Int::IntView,Gecode::Int::PC_INT_BND>::x1;
68  MinElement(Space& home, bool share,MinElement& p);
70  MinElement(Home home, View, Gecode::Int::IntView);
71  public:
73  virtual Actor* copy(Space& home,bool);
75  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
77  static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
78  };
79 
86  template<class View>
87  class NotMinElement :
88  public MixBinaryPropagator<View,PC_SET_ANY,
89  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM> {
90  protected:
94  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM>::x1;
96  NotMinElement(Space& home, bool share,NotMinElement& p);
98  NotMinElement(Home home, View, Gecode::Int::IntView);
99  public:
101  virtual Actor* copy(Space& home,bool);
103  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
105  static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
106  };
107 
114  template<class View, ReifyMode rm>
115  class ReMinElement :
116  public Gecode::Int::ReMixBinaryPropagator<View,PC_SET_ANY,
117  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM,Gecode::Int::BoolView> {
118  protected:
126  ReMinElement(Space& home, bool share,ReMinElement& p);
128  ReMinElement(Home home, View, Gecode::Int::IntView,
130  public:
132  virtual Actor* copy(Space& home,bool);
134  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
136  static ExecStatus post(Home home, View s, Gecode::Int::IntView x,
138  };
139 
146  template<class View>
147  class MaxElement :
148  public MixBinaryPropagator<View,PC_SET_ANY,Gecode::Int::IntView,Gecode::Int::PC_INT_BND> {
149  protected:
150  using MixBinaryPropagator<View,PC_SET_ANY,
152  using MixBinaryPropagator<View,PC_SET_ANY,
153  Gecode::Int::IntView,Gecode::Int::PC_INT_BND>::x1;
155  MaxElement(Space& home, bool share,MaxElement& p);
157  MaxElement(Home home, View, Gecode::Int::IntView);
158  public:
160  virtual Actor* copy(Space& home,bool);
162  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
164  static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
165  };
166 
173  template<class View>
175  public MixBinaryPropagator<View,PC_SET_ANY,
176  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM> {
177  protected:
178  using MixBinaryPropagator<View,PC_SET_ANY,
180  using MixBinaryPropagator<View,PC_SET_ANY,
181  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM>::x1;
183  NotMaxElement(Space& home, bool share,NotMaxElement& p);
185  NotMaxElement(Home home, View, Gecode::Int::IntView);
186  public:
188  virtual Actor* copy(Space& home,bool);
190  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
192  static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
193  };
194 
201  template<class View, ReifyMode rm>
202  class ReMaxElement :
203  public Gecode::Int::ReMixBinaryPropagator<View,PC_SET_ANY,
204  Gecode::Int::IntView,Gecode::Int::PC_INT_DOM,Gecode::Int::BoolView> {
205  protected:
213  ReMaxElement(Space& home, bool share,ReMaxElement& p);
215  ReMaxElement(Home home, View, Gecode::Int::IntView, Gecode::Int::BoolView);
216  public:
218  virtual Actor* copy(Space& home,bool);
220  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
222  static ExecStatus post(Home home, View s, Gecode::Int::IntView x,
224  };
225 
232  template<class View>
233  class Card :
234  public MixBinaryPropagator<View,PC_SET_CARD,
235  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> {
236  protected:
237  using MixBinaryPropagator<View,PC_SET_CARD,
239  using MixBinaryPropagator<View,PC_SET_CARD,
240  Gecode::Int::IntView,Gecode::Int::PC_INT_BND>::x1;
242  Card(Space& home, bool share,Card& p);
244  Card(Home home, View, Gecode::Int::IntView);
245  public:
247  virtual Actor* copy(Space& home,bool);
249  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
251  static ExecStatus post(Home home, View s, Gecode::Int::IntView x);
252  };
253 
260  template<class View>
261  class Weights : public Propagator {
262  protected:
267 
269  View x;
272 
274  Weights(Space& home, bool share,Weights& p);
276  Weights(Home home, const SharedArray<int>&, const SharedArray<int>&,
277  View, Gecode::Int::IntView);
278  public:
280  virtual Actor* copy(Space& home,bool);
282  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
284  virtual size_t dispose(Space& home);
286  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
288  static ExecStatus post(Home home,
289  const SharedArray<int>& elements,
290  const SharedArray<int>& weights,
291  View x, Gecode::Int::IntView y);
292  };
293 
294 }}}
295 
296 #include <gecode/set/int/minmax.hpp>
297 #include <gecode/set/int/card.hpp>
299 
300 #endif
301 
302 // STATISTICS: set-prop
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for x is the minimal element of s.
Definition: minmax.hpp:57
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: weights.hpp:246
const Gecode::PropCond PC_SET_CARD
Propagate when the cardinality of a view changes.
Definition: var-type.hpp:216
SharedArray< int > weights
Weights for the elements in the upper bound.
Definition: int.hh:266
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:419
Propagator for not maximum element
Definition: int.hh:174
ReMinElement(Space &home, bool share, ReMinElement &p)
Constructor for cloning p.
Definition: minmax.hpp:278
Reified mixed binary propagator.
Definition: propagator.hpp:124
Base-class for propagators.
Definition: core.hpp:755
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: weights.hpp:197
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for x is not the minimal element of s.
Definition: minmax.hpp:143
Computation spaces.
Definition: core.hpp:1362
Base-class for both propagators and branchers.
Definition: core.hpp:666
Propagator for reified minimum element
Definition: int.hh:115
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for .
Definition: card.hpp:55
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: weights.hpp:209
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:292
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:467
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:584
Propagator for not minimum element
Definition: int.hh:87
Weights(Space &home, bool share, Weights &p)
Constructor for cloning p.
Definition: weights.hpp:163
static ExecStatus post(Home home, View s, Gecode::Int::IntView x, Gecode::Int::BoolView b)
Post reified propagator for b iff x is the minimal element of s.
Definition: minmax.hpp:270
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:764
static ExecStatus post(Home home, const SharedArray< int > &elements, const SharedArray< int > &weights, View x, Gecode::Int::IntView y)
Post propagator for .
Definition: weights.hpp:173
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
MaxElement(Space &home, bool share, MaxElement &p)
Constructor for cloning p.
Definition: minmax.hpp:404
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for x is the largest element of s.
Definition: minmax.hpp:410
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:286
Gecode::Int::IntView y
The integer view.
Definition: int.hh:271
ReMaxElement(Space &home, bool share, ReMaxElement &p)
Constructor for cloning p.
Definition: minmax.hpp:561
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO)
Definition: weights.hpp:191
View x
The set view.
Definition: int.hh:269
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:163
const Gecode::PropCond PC_SET_ANY
Propagate when any bound or the cardinality of a view changes.
Definition: var-type.hpp:248
NotMaxElement(Space &home, bool share, NotMaxElement &p)
Constructor for cloning p.
Definition: minmax.hpp:453
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:76
Propagator for maximum element
Definition: int.hh:147
Integer view for integer variables.
Definition: view.hpp:129
Card(Space &home, bool share, Card &p)
Constructor for cloning p.
Definition: card.hpp:64
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Mixed binary propagator.
Definition: propagator.hpp:203
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: card.hpp:70
Propagation cost.
Definition: core.hpp:537
ExecStatus
Definition: core.hpp:523
Reified propagator for maximum element
Definition: int.hh:202
MinElement(Space &home, bool share, MinElement &p)
Constructor for cloning p.
Definition: minmax.hpp:65
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:157
Propagator for weight of a set
Definition: int.hh:261
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: card.hpp:76
NotMinElement(Space &home, bool share, NotMinElement &p)
Constructor for cloning p.
Definition: minmax.hpp:150
Gecode toplevel namespace
SharedArray< int > elements
List of elements in the upper bound.
Definition: int.hh:264
static ExecStatus post(Home home, View s, Gecode::Int::IntView x, Gecode::Int::BoolView b)
Post reified propagator for b iff x is the largest element of s.
Definition: minmax.hpp:569
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:70
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:473
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
Home class for posting propagators
Definition: core.hpp:717
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for x is not the largest element of s.
Definition: minmax.hpp:460
Propagator for cardinality
Definition: int.hh:233
Propagator for minimum element
Definition: int.hh:59
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: minmax.hpp:425
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: minmax.hpp:578
Boolean view for Boolean variables.
Definition: view.hpp:1315