Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
nvalues.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2011
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_INT_NVALUES_HH__
39 #define __GECODE_INT_NVALUES_HH__
40 
41 #include <gecode/int.hh>
42 #include <gecode/int/val-set.hh>
43 
49 namespace Gecode { namespace Int { namespace NValues {
50 
54  RET_FST = 0,
56  RET_LST = 1,
58  RET_END = 2
59  };
60 
62  class RangeEvent {
63  public:
67  int val;
69  int view;
71  bool operator <(RangeEvent re) const;
72  };
73 
75  class SymBitMatrix : public Support::BitSet<Region> {
76  protected:
78  int n;
80  int pos(int x, int y) const;
81  public:
83  SymBitMatrix(Region& r, int n);
85  bool get(int x, int y) const;
87  void set(int x, int y);
88  };
89 
90 }}}
91 
94 
96 
97 namespace Gecode { namespace Int { namespace NValues {
98 
100  class Graph : public ViewValGraph::Graph<IntView> {
101  protected:
104  public:
106  Graph(void);
108  int size(void) const;
110  void init(Space& home, const ValSet& vs, const ViewArray<IntView>& x);
112  void sync(void);
113  /*
114  * \brief Mark all edges used that can appear in some maximal matching
115  *
116  * Return true, if any edge can be in fact pruned.
117  */
118  bool mark(void);
120  ExecStatus prune(Space& home);
121  };
122 
123 }}}
124 
126 
127 namespace Gecode { namespace Int { namespace NValues {
128 
135  template<class VY>
136  class IntBase
137  : public MixNaryOnePropagator<IntView,PC_INT_DOM,VY,PC_INT_BND> {
138  protected:
144  IntBase(Home home, ValSet& vs, ViewArray<IntView>& x, VY y);
146  IntBase(Space& home, IntBase<VY>& p);
148  void add(Space& home);
154  void disjoint(Space& home, Region& r, int*& dis, int& n_dis);
156  void eliminate(Space& home);
158  ExecStatus all_in_valset(Space& home);
167  ExecStatus prune_lower(Space& home, int* dis, int n_dis);
174  ExecStatus prune_upper(Space& home, Graph& g);
175  public:
177  virtual PropCost cost(const Space&, const ModEventDelta&) const;
179  virtual size_t dispose(Space& home);
180  };
181 
188  template<class VY>
189  class EqInt : public IntBase<VY> {
190  protected:
191  using IntBase<VY>::x;
192  using IntBase<VY>::y;
193  using IntBase<VY>::vs;
194  using IntBase<VY>::add;
196  using IntBase<VY>::disjoint;
202  EqInt(Home home, ValSet& vs, ViewArray<IntView>& x, VY y);
204  EqInt(Space& home, EqInt<VY>& p);
205  public:
207  virtual Propagator* copy(Space& home);
209  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
211  static ExecStatus post(Home home, ViewArray<IntView>& x, VY y);
213  virtual size_t dispose(Space& home);
214  };
215 
222  template<class VY>
223  class LqInt : public IntBase<VY> {
224  protected:
225  using IntBase<VY>::x;
226  using IntBase<VY>::y;
227  using IntBase<VY>::vs;
228  using IntBase<VY>::add;
230  using IntBase<VY>::disjoint;
234  LqInt(Home home, ValSet& vs, ViewArray<IntView>& x, VY y);
236  LqInt(Space& home, LqInt<VY>& p);
237  public:
239  virtual Propagator* copy(Space& home);
241  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
243  static ExecStatus post(Home home, ViewArray<IntView>& x, VY y);
245  virtual size_t dispose(Space& home);
246  };
247 
254  template<class VY>
255  class GqInt : public IntBase<VY> {
256  protected:
257  using IntBase<VY>::x;
258  using IntBase<VY>::y;
259  using IntBase<VY>::vs;
260  using IntBase<VY>::add;
262  using IntBase<VY>::disjoint;
269  GqInt(Home home, ValSet& vs, ViewArray<IntView>& x, VY y);
271  GqInt(Space& home, GqInt<VY>& p);
272  public:
274  virtual Propagator* copy(Space& home);
276  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
278  static ExecStatus post(Home home, ViewArray<IntView>& x, VY y);
279  };
280 
281 }}}
282 
287 
288 namespace Gecode { namespace Int { namespace NValues {
289 
296  template<class VY>
297  class BoolBase : public Propagator {
298  protected:
300  static const int VS_ZERO = 1 << 0;
302  static const int VS_ONE = 1 << 1;
304  int status;
308  VY y;
310  BoolBase(Home home, int status, ViewArray<BoolView>& x, VY y);
312  BoolBase(Space& home, BoolBase<VY>& p);
313  public:
315  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
317  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
319  virtual void reschedule(Space& home);
321  virtual size_t dispose(Space& home);
322  };
323 
330  template<class VY>
331  class EqBool : public BoolBase<VY> {
332  protected:
333  using BoolBase<VY>::VS_ZERO;
334  using BoolBase<VY>::VS_ONE;
335  using BoolBase<VY>::status;
336  using BoolBase<VY>::c;
337  using BoolBase<VY>::y;
339  EqBool(Home home, int status, ViewArray<BoolView>& x, VY y);
341  EqBool(Space& home, EqBool<VY>& p);
342  public:
344  virtual Actor* copy(Space& home);
346  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
353  static ExecStatus post(Home home, ViewArray<BoolView>& x, VY y);
354  };
355 
362  template<class VY>
363  class LqBool : public BoolBase<VY> {
364  protected:
365  using BoolBase<VY>::VS_ZERO;
366  using BoolBase<VY>::VS_ONE;
367  using BoolBase<VY>::status;
368  using BoolBase<VY>::c;
369  using BoolBase<VY>::y;
371  LqBool(Home home, int status, ViewArray<BoolView>& x, VY y);
373  LqBool(Space& home, LqBool<VY>& p);
374  public:
376  virtual Actor* copy(Space& home);
378  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
385  static ExecStatus post(Home home, ViewArray<BoolView>& x, VY y);
386  };
387 
394  template<class VY>
395  class GqBool : public BoolBase<VY> {
396  protected:
397  using BoolBase<VY>::VS_ZERO;
398  using BoolBase<VY>::VS_ONE;
399  using BoolBase<VY>::status;
400  using BoolBase<VY>::c;
401  using BoolBase<VY>::y;
403  GqBool(Home home, int status, ViewArray<BoolView>& x, VY y);
405  GqBool(Space& home, GqBool<VY>& p);
406  public:
408  virtual Actor* copy(Space& home);
410  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
417  static ExecStatus post(Home home, ViewArray<BoolView>& x, VY y);
418  };
419 
420 }}}
421 
426 
427 #endif
428 
429 // STATISTICS: int-prop
Council of advisors
Definition: core.hpp:156
Greater or equal to number of values propagator for integer views.
Definition: nvalues.hh:255
Graph g
View-value graph.
Definition: nvalues.hh:267
Event for range-based overlap analysis.
Definition: nvalues.hh:62
int n_matched
Number of matched edges.
Definition: nvalues.hh:103
void eliminate(Term< BoolView > *t, int &n, long long int &d)
Eliminate assigned views.
Definition: bool-post.cpp:47
Less or equal to number of values propagator for Boolean views.
Definition: nvalues.hh:363
bool pos(const View &x)
Test whether x is postive.
Definition: mult.hpp:45
Mixed (n+1)-ary propagator.
Definition: pattern.hpp:276
Equal to number of values propagator for integer views.
Definition: nvalues.hh:189
Base-class for propagators.
Definition: core.hpp:1016
int val
The value for the range (first or last value, depending on type)
Definition: nvalues.hh:67
Base-class for advisors.
Definition: core.hpp:1218
No further events.
Definition: nvalues.hh:58
Handle to region.
Definition: region.hpp:57
void * mark(void *p)
Return marked pointer for unmarked pointer p.
Computation spaces.
Definition: core.hpp:1668
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:268
Graph g
View-value graph.
Definition: nvalues.hh:200
Base-class for both propagators and branchers.
Definition: core.hpp:620
int status
Status information about the views.
Definition: nvalues.hh:304
Gecode::IntSet d(v, 7)
VY y
The view for counting the number of values.
Definition: nvalues.hh:308
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
int view
Which view does this range belong to.
Definition: nvalues.hh:69
Number of values propagator for Boolean views base class.
Definition: nvalues.hh:297
unsigned int size(I &i)
Size of all ranges of range iterator i.
View-value graph for propagation of upper bound.
Definition: nvalues.hh:100
View-value graph base class.
ValSet vs
Value set storing the values of already assigned views.
Definition: nvalues.hh:142
RangeEventType
Event type for range-based overlap analysis.
Definition: nvalues.hh:52
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
Less or equal to number of values propagator for integer views.
Definition: nvalues.hh:223
bool operator<(RangeEvent re) const
Order events: first by val, then by event type.
Definition: range-event.hpp:41
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:769
RangeEventType ret
The event type.
Definition: nvalues.hh:65
Generic domain change information to be supplied to advisors.
Definition: core.hpp:205
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Propagation cost.
Definition: core.hpp:478
ExecStatus
Definition: core.hpp:464
Symmetric diagonal bit matrix.
Definition: nvalues.hh:75
bool disjoint(I &i, J &j)
Check whether range iterators i and j are disjoint.
Greater or equal to number of values propagator for Boolean views.
Definition: nvalues.hh:395
A range starts.
Definition: nvalues.hh:54
Simple bitsets.
Definition: bitset.hpp:49
Post propagator for SetVar x
Definition: set.hh:769
Class for storing values of already assigned views.
Definition: val-set.hh:48
Equal to number of values propagator for Boolean views.
Definition: nvalues.hh:331
Gecode toplevel namespace
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:96
Number of values propagator for integer views base class.
Definition: nvalues.hh:136
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
Council< ViewAdvisor< BoolView > > c
The advisor council.
Definition: nvalues.hh:306
Home class for posting propagators
Definition: core.hpp:846
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition: filter.cpp:142