Generated on Thu Feb 21 2013 23:11:44 for Gecode by doxygen 1.8.3.1
view.hpp
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  *
6  * Contributing authors:
7  * Christian Schulte <schulte@gecode.org>
8  *
9  * Copyright:
10  * Guido Tack, 2004
11  * Christian Schulte, 2004
12  *
13  * Last modified:
14  * $Date: 2011-08-20 00:47:28 +1000 (Sat, 20 Aug 2011) $ by $Author: tack $
15  * $Revision: 12318 $
16  *
17  * This file is part of Gecode, the generic constraint
18  * development environment:
19  * http://www.gecode.org
20  *
21  * Permission is hereby granted, free of charge, to any person obtaining
22  * a copy of this software and associated documentation files (the
23  * "Software"), to deal in the Software without restriction, including
24  * without limitation the rights to use, copy, modify, merge, publish,
25  * distribute, sublicense, and/or sell copies of the Software, and to
26  * permit persons to whom the Software is furnished to do so, subject to
27  * the following conditions:
28  *
29  * The above copyright notice and this permission notice shall be
30  * included in all copies or substantial portions of the Software.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39  *
40  */
41 
42 #include <iostream>
43 
44 namespace Gecode { namespace Set {
45 
60  class SetView : public VarImpView<SetVar> {
61  protected:
63  public:
65 
66 
67  SetView(void);
69  SetView(const SetVar& y);
71  SetView(SetVarImp* y);
73 
75 
76 
78  unsigned int cardMin(void) const;
80  unsigned int cardMax(void) const;
82  int lubMin(void) const;
84  int lubMax(void) const;
86  int lubMinN(unsigned int n) const;
88  int glbMin(void) const;
90  int glbMax(void) const;
91 
93  unsigned int glbSize(void) const;
95  unsigned int lubSize(void) const;
97  unsigned int unknownSize(void) const;
99 
101 
102 
103  bool contains(int i) const;
105  bool notContains(int i) const;
107 
108 
110 
111 
112  ModEvent cardMin(Space& home, unsigned int m);
114  ModEvent cardMax(Space& home, unsigned int m);
119  ModEvent include(Space& home,int i,int j);
124  ModEvent exclude(Space& home,int i,int j);
126  ModEvent include(Space& home,int i);
128  ModEvent exclude(Space& home,int i);
133  ModEvent intersect(Space& home,int i,int j);
135  ModEvent intersect(Space& home,int i);
137 
139 
140 
142  template<class I> ModEvent excludeI(Space& home, I& i);
144  template<class I> ModEvent includeI(Space& home, I& i);
146  template<class I> ModEvent intersectI(Space& home, I& iter);
148 
150 
151 
152  static ModEvent modevent(const Delta& d);
154  int glbMin(const Delta& d) const;
156  int glbMax(const Delta& d) const;
158  bool glbAny(const Delta& d) const;
160  int lubMin(const Delta& d) const;
162  int lubMax(const Delta& d) const;
164  bool lubAny(const Delta& d) const;
166  };
167 
172  template<class Char, class Traits>
173  std::basic_ostream<Char,Traits>&
174  operator <<(std::basic_ostream<Char,Traits>& os, const SetView& x);
175 
176 
177 
178  // Forward declarations for friends
179  class ConstSetView;
180  bool same(const ConstSetView&, const ConstSetView&);
181  bool before(const ConstSetView&, const ConstSetView&);
182 
190  class ConstSetView : public ConstView<SetView> {
191  friend class LubRanges<ConstSetView>;
192  friend class GlbRanges<ConstSetView>;
193  friend bool Gecode::Set::same(const Gecode::Set::ConstSetView&,
197  private:
198  int *ranges;
199  int size;
200  unsigned int domSize;
201  public:
203 
204 
205  ConstSetView(void);
207  ConstSetView(Space& home, const IntSet& s);
209 
211 
212 
213  unsigned int cardMin(void) const;
215  unsigned int cardMax(void) const;
217  int lubMin(void) const;
219  int lubMax(void) const;
221  int lubMinN(unsigned int n) const;
223  int glbMin(void) const;
225  int glbMax(void) const;
226 
228  unsigned int glbSize(void) const;
230  unsigned int lubSize(void) const;
232  unsigned int unknownSize(void) const;
234 
236 
237 
238  bool contains(int i) const;
240  bool notContains(int i) const;
242 
243 
245 
246 
247  ModEvent cardMin(Space& home, unsigned int m);
249  ModEvent cardMax(Space& home, unsigned int m);
254  ModEvent include(Space& home,int i,int j);
259  ModEvent exclude(Space& home,int i,int j);
261  ModEvent include(Space& home,int i);
263  ModEvent exclude(Space& home,int i);
268  ModEvent intersect(Space& home,int i,int j);
270  ModEvent intersect(Space& home,int i);
272 
274 
275 
277  template<class I> ModEvent excludeI(Space& home, I& i);
279  template<class I> ModEvent includeI(Space& home, I& i);
281  template<class I> ModEvent intersectI(Space& home, I& iter);
283 
285 
286 
287  void update(Space& home, bool share, ConstSetView& y);
289 
291 
292 
293  int glbMin(const Delta& d) const;
295  int glbMax(const Delta& d) const;
297  bool glbAny(const Delta& d) const;
299  int lubMin(const Delta& d) const;
301  int lubMax(const Delta& d) const;
303  bool lubAny(const Delta& d) const;
305 
306  };
307 
312  template<class Char, class Traits>
313  std::basic_ostream<Char,Traits>&
314  operator <<(std::basic_ostream<Char,Traits>& os, const ConstSetView& x);
315 
320 
321  bool same(const ConstSetView& x, const ConstSetView& y);
323  bool before(const ConstSetView& x, const ConstSetView& y);
325 
326 
335  class EmptyView : public ConstView<SetView> {
336  public:
338 
339 
340  EmptyView(void);
342 
344 
345 
346  unsigned int cardMin(void) const;
348  unsigned int cardMax(void) const;
350  int lubMin(void) const;
352  int lubMax(void) const;
354  int lubMinN(unsigned int n) const;
356  int glbMin(void) const;
358  int glbMax(void) const;
359 
361  unsigned int glbSize(void) const;
363  unsigned int lubSize(void) const;
365  unsigned int unknownSize(void) const;
367 
369 
370 
371  bool contains(int i) const;
373  bool notContains(int i) const;
375 
376 
378 
379 
380  ModEvent cardMin(Space& home, unsigned int m);
382  ModEvent cardMax(Space& home, unsigned int m);
387  ModEvent include(Space& home,int i,int j);
392  ModEvent exclude(Space& home,int i,int j);
394  ModEvent include(Space& home,int i);
396  ModEvent exclude(Space& home,int i);
401  ModEvent intersect(Space& home,int i,int j);
403  ModEvent intersect(Space& home,int i);
405 
407 
408 
410  template<class I> ModEvent excludeI(Space& home, I& i);
412  template<class I> ModEvent includeI(Space& home, I& i);
414  template<class I> ModEvent intersectI(Space& home, I& iter);
416 
418 
419 
420  int glbMin(const Delta& d) const;
422  int glbMax(const Delta& d) const;
424  bool glbAny(const Delta& d) const;
426  int lubMin(const Delta& d) const;
428  int lubMax(const Delta& d) const;
430  bool lubAny(const Delta& d) const;
432 
433  };
434 
439  template<class Char, class Traits>
440  std::basic_ostream<Char,Traits>&
441  operator <<(std::basic_ostream<Char,Traits>& os, const EmptyView& x);
442 
443 
448 
449  bool same(const EmptyView& x, const EmptyView& y);
451 
452 
461  class UniverseView : public ConstView<SetView> {
462  public:
464 
465 
466  UniverseView(void);
468 
470 
471 
473  unsigned int cardMin(void) const;
475  unsigned int cardMax(void) const;
477  int lubMin(void) const;
479  int lubMax(void) const;
481  int lubMinN(unsigned int n) const;
483  int glbMin(void) const;
485  int glbMax(void) const;
486 
488  unsigned int glbSize(void) const;
490  unsigned int lubSize(void) const;
492  unsigned int unknownSize(void) const;
494 
496 
497 
498  bool contains(int i) const;
500  bool notContains(int i) const;
502 
503 
505 
506 
507  ModEvent cardMin(Space& home, unsigned int m);
509  ModEvent cardMax(Space& home, unsigned int m);
514  ModEvent include(Space& home,int i,int j);
519  ModEvent exclude(Space& home,int i,int j);
521  ModEvent include(Space& home,int i);
523  ModEvent exclude(Space& home,int i);
528  ModEvent intersect(Space& home,int i,int j);
530  ModEvent intersect(Space& home,int i);
532 
534 
535 
537  template<class I> ModEvent excludeI(Space& home, I& i);
539  template<class I> ModEvent includeI(Space& home, I& i);
541  template<class I> ModEvent intersectI(Space& home, I& iter);
543 
545 
546 
547  int glbMin(const Delta& d) const;
549  int glbMax(const Delta& d) const;
551  bool glbAny(const Delta& d) const;
553  int lubMin(const Delta& d) const;
555  int lubMax(const Delta& d) const;
557  bool lubAny(const Delta& d) const;
559 
560  };
561 
566  template<class Char, class Traits>
567  std::basic_ostream<Char,Traits>&
568  operator <<(std::basic_ostream<Char,Traits>& os, const UniverseView& x);
569 
570 
575 
576  bool same(const UniverseView& x, const UniverseView& y);
578 
579 
580 
590  public DerivedView<Gecode::Int::IntView> {
591  protected:
593 
595  static PropCond pc_settoint(PropCond pc);
599  static ModEvent me_settoint(ModEvent me);
600 
601  public:
603 
604 
605  SingletonView(void);
609  SingletonView(const Gecode::IntVar& y);
611 
613 
614 
616  unsigned int cardMin(void) const;
618  unsigned int cardMax(void) const;
620  int lubMin(void) const;
622  int lubMax(void) const;
624  int lubMinN(unsigned int n) const;
626  int glbMin(void) const;
628  int glbMax(void) const;
629 
631  unsigned int glbSize(void) const;
633  unsigned int lubSize(void) const;
635  unsigned int unknownSize(void) const;
637 
639 
640 
641  bool contains(int i) const;
643  bool notContains(int i) const;
645 
646 
648 
649 
650  ModEvent cardMin(Space& home, unsigned int m);
652  ModEvent cardMax(Space& home, unsigned int m);
657  ModEvent include(Space& home,int i,int j);
662  ModEvent exclude(Space& home,int i,int j);
664  ModEvent include(Space& home,int i);
666  ModEvent exclude(Space& home,int i);
671  ModEvent intersect(Space& home,int i,int j);
673  ModEvent intersect(Space& home,int i);
675 
677 
678 
680  template<class I> ModEvent excludeI(Space& home, I& i);
682  template<class I> ModEvent includeI(Space& home, I& i);
684  template<class I> ModEvent intersectI(Space& home, I& iter);
686 
688 
689 
690  static void schedule(Space& home, Propagator& p, ModEvent me);
692  static ModEvent me(const ModEventDelta& med);
694  static ModEventDelta med(ModEvent);
696 
698 
699 
706  void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
708  void cancel(Space& home, Propagator& p, PropCond pc);
710  void subscribe(Space& home, Advisor& a);
712  void cancel(Space& home, Advisor& a);
714 
716 
717 
718  static ModEvent modevent(const Delta& d);
720  int glbMin(const Delta& d) const;
722  int glbMax(const Delta& d) const;
724  bool glbAny(const Delta& d) const;
726  int lubMin(const Delta& d) const;
728  int lubMax(const Delta& d) const;
730  bool lubAny(const Delta& d) const;
732 
733  };
734 
739  template<class Char, class Traits>
740  std::basic_ostream<Char,Traits>&
741  operator <<(std::basic_ostream<Char,Traits>& os, const SingletonView& x);
742 
743 
753  template<class View>
755  : public DerivedView<View> {
756  protected:
757  using DerivedView<View>::x;
758 
759  public:
761  static PropCond pc_negateset(PropCond pc);
764 
766 
767 
768  ComplementView(void);
770  explicit ComplementView(View& y);
772 
774 
775 
777  unsigned int cardMin(void) const;
779  unsigned int cardMax(void) const;
781  int lubMin(void) const;
783  int lubMax(void) const;
785  int lubMinN(unsigned int n) const;
787  int glbMin(void) const;
789  int glbMax(void) const;
790 
792  unsigned int glbSize(void) const;
794  unsigned int lubSize(void) const;
796  unsigned int unknownSize(void) const;
798 
800 
801 
802  bool contains(int i) const;
804  bool notContains(int i) const;
806 
807 
809 
810 
811  ModEvent cardMin(Space& home, unsigned int m);
813  ModEvent cardMax(Space& home, unsigned int m);
818  ModEvent include(Space& home,int i,int j);
823  ModEvent exclude(Space& home,int i,int j);
825  ModEvent include(Space& home,int i);
827  ModEvent exclude(Space& home,int i);
832  ModEvent intersect(Space& home,int i,int j);
834  ModEvent intersect(Space& home,int i);
836 
838 
839 
841  template<class I> ModEvent excludeI(Space& home, I& i);
843  template<class I> ModEvent includeI(Space& home, I& i);
845  template<class I> ModEvent intersectI(Space& home, I& iter);
847 
849 
850 
851  static void schedule(Space& home, Propagator& p, ModEvent me);
853  static ModEvent me(const ModEventDelta& med);
855  static ModEventDelta med(ModEvent);
857 
859 
860 
867  void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
869  void cancel(Space& home, Propagator& p, PropCond pc);
871  void subscribe(Space& home, Advisor& a);
873  void cancel(Space& home, Advisor& a);
875 
877 
878 
879  static ModEvent modevent(const Delta& d);
881  int glbMin(const Delta& d) const;
883  int glbMax(const Delta& d) const;
885  bool glbAny(const Delta& d) const;
887  int lubMin(const Delta& d) const;
889  int lubMax(const Delta& d) const;
891  bool lubAny(const Delta& d) const;
893 
894  };
895 
900  template<class Char, class Traits, class View>
901  std::basic_ostream<Char,Traits>&
902  operator <<(std::basic_ostream<Char,Traits>& os,
903  const ComplementView<View>& x);
904 
905 
906  template<class View> class LubDiffRanges;
907  template<class View> class GlbDiffRanges;
908 
920  template<class View>
922  : public DerivedView<View> {
923  friend class LubDiffRanges<View>;
924  friend class GlbDiffRanges<View>;
925  protected:
926  using DerivedView<View>::x;
927 
932 
933  public:
934 
936 
937 
938  CachedView(void);
940  explicit CachedView(const View& y);
942 
944 
945 
947  unsigned int cardMin(void) const;
949  unsigned int cardMax(void) const;
951  int lubMin(void) const;
953  int lubMax(void) const;
955  int lubMinN(unsigned int n) const;
957  int glbMin(void) const;
959  int glbMax(void) const;
960 
962  unsigned int glbSize(void) const;
964  unsigned int lubSize(void) const;
966  unsigned int unknownSize(void) const;
968 
970 
971 
972  bool contains(int i) const;
974  bool notContains(int i) const;
976 
977 
979 
980 
981  ModEvent cardMin(Space& home, unsigned int m);
983  ModEvent cardMax(Space& home, unsigned int m);
988  ModEvent include(Space& home,int i,int j);
993  ModEvent exclude(Space& home,int i,int j);
995  ModEvent include(Space& home,int i);
997  ModEvent exclude(Space& home,int i);
1002  ModEvent intersect(Space& home,int i,int j);
1004  ModEvent intersect(Space& home,int i);
1006 
1008 
1009 
1011  template<class I> ModEvent excludeI(Space& home, I& i);
1013  template<class I> ModEvent includeI(Space& home, I& i);
1015  template<class I> ModEvent intersectI(Space& home, I& iter);
1017 
1019 
1020 
1021  static void schedule(Space& home, Propagator& p, ModEvent me);
1023  static ModEvent me(const ModEventDelta& med);
1025  static ModEventDelta med(ModEvent);
1027 
1029 
1030 
1037  void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
1039  void cancel(Space& home, Propagator& p, PropCond pc);
1041  void subscribe(Space& home, Advisor& a);
1043  void cancel(Space& home, Advisor& a);
1045 
1047 
1048 
1049  static ModEvent modevent(const Delta& d);
1051  int glbMin(const Delta& d) const;
1053  int glbMax(const Delta& d) const;
1055  bool glbAny(const Delta& d) const;
1057  int lubMin(const Delta& d) const;
1059  int lubMax(const Delta& d) const;
1061  bool lubAny(const Delta& d) const;
1063 
1065 
1066 
1067  void initCache(Space& home, const IntSet& glb, const IntSet& lub);
1069  void cacheGlb(Space& home);
1071  void cacheLub(Space& home);
1073  bool glbModified(void) const;
1075  bool lubModified(void) const;
1077 
1079 
1080 
1081  void update(Space& home, bool share, CachedView<View>& y);
1083  };
1084 
1089  template<class Char, class Traits, class View>
1090  std::basic_ostream<Char,Traits>&
1091  operator <<(std::basic_ostream<Char,Traits>& os,
1092  const CachedView<View>& x);
1093 
1098  template<class View>
1099  class GlbDiffRanges
1100  : public Iter::Ranges::Diff<GlbRanges<View>,BndSetRanges> {
1101  protected:
1106  public:
1108  GlbDiffRanges(const CachedView<View>& x);
1109  };
1110 
1115  template<class View>
1116  class LubDiffRanges
1117  : public Iter::Ranges::Diff<BndSetRanges,LubRanges<View> > {
1118  protected:
1123  public:
1125  LubDiffRanges(const CachedView<View>& x);
1126  };
1127 
1128 }}
1129 
1130 #include <gecode/set/var/set.hpp>
1131 
1132 #include <gecode/set/view/set.hpp>
1133 
1134 #include <gecode/set/view/const.hpp>
1137 #include <gecode/set/view/cached.hpp>
1138 
1139 #include <gecode/set/view/print.hpp>
1140 #include <gecode/set/var/print.hpp>
1141 
1142 // STATISTICS: set-var