Generated on Sat Oct 20 2018 12:43:45 for Gecode by doxygen 1.8.13
linear.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  * Guido Tack <tack@gecode.org>
6  * Tias Guns <tias.guns@cs.kuleuven.be>
7  *
8  * Copyright:
9  * Christian Schulte, 2002
10  * Guido Tack, 2004
11  * Tias Guns, 2009
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_LINEAR_HH__
39 #define __GECODE_INT_LINEAR_HH__
40 
41 #include <gecode/int.hh>
42 
48 namespace Gecode { namespace Int { namespace Linear {
49 
50  /*
51  * Binary propagators
52  *
53  */
54 
64  template<class Val, class A, class B, PropCond pc>
65  class LinBin : public Propagator {
66  protected:
68  A x0;
70  B x1;
72  Val c;
74  LinBin(Space& home, LinBin& p);
76  LinBin(Space& home, Propagator& p, A x0, B x1, Val c);
78  LinBin(Home home, A x0, B x1, Val c);
79  public:
81  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
83  virtual void reschedule(Space& home);
85  virtual size_t dispose(Space& home);
86  };
87 
97  template<class Val, class A, class B, PropCond pc, class Ctrl>
98  class ReLinBin : public Propagator {
99  protected:
101  A x0;
103  B x1;
105  Val c;
107  Ctrl b;
109  ReLinBin(Space& home, ReLinBin& p);
111  ReLinBin(Home home, A x0, B x1, Val c, Ctrl b);
112  public:
114  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
116  virtual void reschedule(Space& home);
118  virtual size_t dispose(Space& home);
119  };
120 
133  template<class Val, class A, class B>
134  class EqBin : public LinBin<Val,A,B,PC_INT_BND> {
135  protected:
139 
141  EqBin(Space& home, EqBin& p);
143  EqBin(Home home, A x0, B x1, Val c);
144  public:
146  EqBin(Space& home, Propagator& p, A x0, B x1, Val c);
148  virtual Actor* copy(Space& home);
150  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
152  static ExecStatus post(Home home, A x0, B x1, Val c);
153  };
154 
167  template<class Val, class A, class B, class Ctrl, ReifyMode rm>
168  class ReEqBin : public ReLinBin<Val,A,B,PC_INT_BND,Ctrl> {
169  protected:
174 
176  ReEqBin(Space& home, ReEqBin& p);
178  ReEqBin(Home home,A,B,Val,Ctrl);
179  public:
181  virtual Actor* copy(Space& home);
183  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
185  static ExecStatus post(Home home, A x0, B x1, Val c, Ctrl b);
186  };
187 
200  template<class Val, class A, class B>
201  class NqBin : public LinBin<Val,A,B,PC_INT_VAL> {
202  protected:
206 
208  NqBin(Space& home, NqBin& p);
210  NqBin(Home home, A x0, B x1, Val c);
211  public:
213  NqBin(Space& home, Propagator& p, A x0, B x1, Val c);
215  virtual Actor* copy(Space& home);
217  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
219  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
221  static ExecStatus post(Home home, A x0, B x1, Val c);
222  };
223 
236  template<class Val, class A, class B>
237  class LqBin : public LinBin<Val,A,B,PC_INT_BND> {
238  protected:
242 
244  LqBin(Space& home, LqBin& p);
246  LqBin(Home home, A x0, B x1, Val c);
247  public:
249  LqBin(Space& home, Propagator& p, A x0, B x1, Val c);
251  virtual Actor* copy(Space& home);
253  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
255  static ExecStatus post(Home home, A x0, B x1, Val c);
256  };
257 
270  template<class Val, class A, class B>
271  class GqBin : public LinBin<Val,A,B,PC_INT_BND> {
272  protected:
276 
278  GqBin(Space& home, GqBin& p);
280  GqBin(Home home, A x0, B x1, Val c);
281  public:
283  GqBin(Space& home, Propagator& p, A x0, B x1, Val c);
285  virtual Actor* copy(Space& home);
287  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
289  static ExecStatus post(Home home, A x0, B x1, Val c);
290  };
291 
304  template<class Val, class A, class B, ReifyMode rm>
305  class ReLqBin : public ReLinBin<Val,A,B,PC_INT_BND,BoolView> {
306  protected:
311 
313  ReLqBin(Space& home, ReLqBin& p);
315  ReLqBin(Home home, A x0, B x1, Val c, BoolView b);
316  public:
318  virtual Actor* copy(Space& home);
320  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
322  static ExecStatus post(Home home, A x0, B x1, Val c, BoolView b);
323  };
324 
325 }}}
326 
328 
329 namespace Gecode { namespace Int { namespace Linear {
330 
331  /*
332  * Ternary propagators
333  *
334  */
335 
345  template<class Val, class A, class B, class C, PropCond pc>
346  class LinTer : public Propagator {
347  protected:
349  A x0;
351  B x1;
353  C x2;
355  Val c;
357  LinTer(Space& home, LinTer& p);
359  LinTer(Home home, A x0, B x1, C x2, Val c);
361  LinTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
362  public:
364  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
366  virtual void reschedule(Space& home);
368  virtual size_t dispose(Space& home);
369  };
370 
383  template<class Val, class A, class B, class C>
384  class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
385  protected:
390 
392  EqTer(Space& home, EqTer& p);
394  EqTer(Home home, A x0, B x1, C x2, Val c);
395  public:
397  EqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
399  virtual Actor* copy(Space& home);
401  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
403  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
404  };
405 
418  template<class Val, class A, class B, class C>
419  class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
420  protected:
425 
427  NqTer(Space& home, NqTer& p);
429  NqTer(Home home, A x0, B x1, C x2, Val c);
430  public:
432  NqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
434  virtual Actor* copy(Space& home);
436  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
438  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
439  };
440 
453  template<class Val, class A, class B, class C>
454  class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
455  protected:
460 
462  LqTer(Space& home, LqTer& p);
464  LqTer(Home home, A x0, B x1, C x2, Val c);
465  public:
467  LqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
469  virtual Actor* copy(Space& home);
471  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
473  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
474  };
475 
476 }}}
477 
479 
480 namespace Gecode { namespace Int { namespace Linear {
481 
482  /*
483  * n-ary propagators
484  *
485  */
486 
496  template<class Val, class P, class N, PropCond pc>
497  class Lin : public Propagator {
498  protected:
504  Val c;
505 
507  Lin(Space& home, Lin<Val,P,N,pc>& p);
509  Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
510  public:
512  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
514  virtual void reschedule(Space& home);
516  virtual size_t dispose(Space& home);
517  };
518 
528  template<class Val, class P, class N, PropCond pc, class Ctrl>
529  class ReLin : public Lin<Val,P,N,pc> {
530  protected:
531  using Lin<Val,P,N,pc>::x;
532  using Lin<Val,P,N,pc>::y;
534  Ctrl b;
536  ReLin(Space& home, ReLin& p);
538  ReLin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
539  public:
541  virtual void reschedule(Space& home);
543  virtual size_t dispose(Space& home);
544  };
545 
551  template<class Val, class View>
553  Val& c, Val& sl, Val& su);
554 
560  template<class Val, class View>
562  Val& c, Val& sl, Val& su);
563 
576  template<class Val, class P, class N>
577  class Eq : public Lin<Val,P,N,PC_INT_BND> {
578  protected:
582 
584  Eq(Space& home, Eq& p);
585  public:
587  Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
589  virtual Actor* copy(Space& home);
591  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
593  static ExecStatus
594  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
595  };
596 
607  template<class Val, class View>
608  class DomEq
609  : public Lin<Val,View,View,PC_INT_DOM> {
610  protected:
614 
616  DomEq(Space& home, DomEq& p);
617  public:
619  DomEq(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
621  virtual Actor* copy(Space& home);
628  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
630  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
632  static ExecStatus
633  post(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
634  };
635 
648  template<class Val, class P, class N, class Ctrl, ReifyMode rm>
649  class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
650  protected:
655 
657  ReEq(Space& home, ReEq& p);
658  public:
660  ReEq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
662  virtual Actor* copy(Space& home);
664  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
666  static ExecStatus
667  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
668  };
669 
682  template<class Val, class P, class N>
683  class Nq : public Lin<Val,P,N,PC_INT_VAL> {
684  protected:
688 
690  Nq(Space& home, Nq& p);
691  public:
693  Nq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
695  virtual Actor* copy(Space& home);
697  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
699  static ExecStatus
700  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
701  };
702 
715  template<class Val, class P, class N>
716  class Lq : public Lin<Val,P,N,PC_INT_BND> {
717  protected:
721 
723  Lq(Space& home, Lq& p);
724  public:
726  Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
728  virtual Actor* copy(Space& home);
730  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
732  static ExecStatus
733  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
734  };
735 
748  template<class Val, class P, class N, ReifyMode rm>
749  class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
750  protected:
755 
757  ReLq(Space& home, ReLq& p);
758  public:
760  ReLq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
762  virtual Actor* copy(Space& home);
764  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
766  static ExecStatus
767  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
768  };
769 
770 }}}
771 
774 
775 namespace Gecode { namespace Int { namespace Linear {
776 
777  /*
778  * Boolean linear propagators
779  *
780  */
781 
786  template<class VX>
787  class LinBoolInt : public Propagator {
788  protected:
794  int n_as;
796  int n_hs;
798  int c;
800  void normalize(void);
802  LinBoolInt(Space& home, LinBoolInt& p);
804  LinBoolInt(Home home, ViewArray<VX>& x, int n_s, int c);
805  public:
807  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
809  virtual size_t dispose(Space& home);
810  };
811 
818  template<class VX>
819  class EqBoolInt : public LinBoolInt<VX> {
820  protected:
821  using LinBoolInt<VX>::co;
822  using LinBoolInt<VX>::x;
823  using LinBoolInt<VX>::n_as;
824  using LinBoolInt<VX>::n_hs;
825  using LinBoolInt<VX>::c;
828  EqBoolInt(Space& home, EqBoolInt& p);
830  EqBoolInt(Home home, ViewArray<VX>& x, int c);
831  public:
833  virtual Actor* copy(Space& home);
835  virtual void reschedule(Space& home);
837  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
839  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
841  static ExecStatus post(Home home, ViewArray<VX>& x, int c);
842  };
843 
850  template<class VX>
851  class GqBoolInt : public LinBoolInt<VX> {
852  protected:
853  using LinBoolInt<VX>::co;
854  using LinBoolInt<VX>::x;
855  using LinBoolInt<VX>::n_as;
856  using LinBoolInt<VX>::n_hs;
857  using LinBoolInt<VX>::c;
860  GqBoolInt(Space& home, GqBoolInt& p);
862  GqBoolInt(Home home, ViewArray<VX>& x, int c);
863  public:
865  virtual Actor* copy(Space& home);
867  virtual void reschedule(Space& home);
869  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
871  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
873  static ExecStatus post(Home home, ViewArray<VX>& x, int c);
874  };
875 
882  template<class VX>
883  class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
884  protected:
890  int c;
892  bool resubscribe(Space& home, VX& y);
894  NqBoolInt(Home home, ViewArray<VX>& b, int c);
896  NqBoolInt(Space& home, NqBoolInt<VX>& p);
897  public:
899  virtual Actor* copy(Space& home);
901  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
903  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
905  static ExecStatus post(Home home, ViewArray<VX>& b, int c);
907  virtual size_t dispose(Space& home);
908  };
909 
910 
915  template<class VX, class VB>
916  class ReLinBoolInt : public Propagator {
917  protected:
923  int n_s;
925  int c;
927  VB b;
929  void normalize(void);
931  ReLinBoolInt(Space& home, ReLinBoolInt& p);
933  ReLinBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
934  public:
936  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
938  virtual size_t dispose(Space& home);
939  };
940 
941 
945  template<class BV>
946  class BoolNegTraits {};
947 
954  template<class VX, class VB, ReifyMode rm>
955  class ReGqBoolInt : public ReLinBoolInt<VX,VB> {
956  protected:
964  ReGqBoolInt(Space& home, ReGqBoolInt& p);
966  ReGqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
967  public:
969  virtual Actor* copy(Space& home);
971  virtual void reschedule(Space& home);
973  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
975  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
977  static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
978  };
979 
986  template<class VX, class VB, ReifyMode rm>
987  class ReEqBoolInt : public ReLinBoolInt<VX,VB> {
988  protected:
996  ReEqBoolInt(Space& home, ReEqBoolInt& p);
998  ReEqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
999  public:
1001  virtual Actor* copy(Space& home);
1003  virtual void reschedule(Space& home);
1005  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
1007  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1009  static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
1010  };
1011 
1012 }}}
1013 
1015 
1016 namespace Gecode { namespace Int { namespace Linear {
1017 
1022  template<class XV, class YV>
1023  class LinBoolView : public Propagator {
1024  protected:
1028  YV y;
1030  int c;
1032  LinBoolView(Space& home, LinBoolView& p);
1034  LinBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1035  public:
1037  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
1039  virtual void reschedule(Space& home);
1041  virtual size_t dispose(Space& home);
1042  };
1043 
1044 
1051  template<class XV, class YV>
1052  class EqBoolView : public LinBoolView<XV,YV> {
1053  protected:
1054  using LinBoolView<XV,YV>::x;
1055  using LinBoolView<XV,YV>::y;
1056  using LinBoolView<XV,YV>::c;
1057 
1059  EqBoolView(Space& home, EqBoolView& p);
1061  EqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1062  public:
1064  virtual Actor* copy(Space& home);
1066  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1068  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1069  };
1070 
1077  template<class XV, class YV>
1078  class NqBoolView : public LinBoolView<XV,YV> {
1079  protected:
1080  using LinBoolView<XV,YV>::x;
1081  using LinBoolView<XV,YV>::y;
1082  using LinBoolView<XV,YV>::c;
1083 
1085  NqBoolView(Space& home, NqBoolView& p);
1087  NqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1088  public:
1090  virtual Actor* copy(Space& home);
1092  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1094  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1095  };
1096 
1103  template<class XV, class YV>
1104  class GqBoolView : public LinBoolView<XV,YV> {
1105  protected:
1106  using LinBoolView<XV,YV>::x;
1107  using LinBoolView<XV,YV>::y;
1108  using LinBoolView<XV,YV>::c;
1109 
1111  GqBoolView(Space& home, GqBoolView& p);
1113  GqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1114  public:
1116  virtual Actor* copy(Space& home);
1118  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1120  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1121  };
1122 
1123 }}}
1124 
1126 
1127 namespace Gecode { namespace Int { namespace Linear {
1128 
1130  class ScaleBool {
1131  public:
1133  int a;
1136  };
1137 
1140  private:
1142  ScaleBool* _fst;
1144  ScaleBool* _lst;
1145  public:
1147  ScaleBoolArray(void);
1149  ScaleBoolArray(Space& home, int n);
1151  void subscribe(Space& home, Propagator& p);
1153  void cancel(Space& home, Propagator& p);
1155  void reschedule(Space& home, Propagator& p);
1157  void update(Space& home, ScaleBoolArray& sba);
1159  ScaleBool* fst(void) const;
1161  ScaleBool* lst(void) const;
1163  void fst(ScaleBool* f);
1165  void lst(ScaleBool* l);
1167  bool empty(void) const;
1169  int size(void) const;
1170  private:
1172  class ScaleDec {
1173  public:
1174  bool
1175  operator ()(const ScaleBool& x, const ScaleBool& y);
1176  };
1177  public:
1179  void sort(void);
1180  };
1181 
1182 
1185  public:
1187  EmptyScaleBoolArray(void);
1189  EmptyScaleBoolArray(Space& home, int n);
1191  void subscribe(Space& home, Propagator& p);
1193  void cancel(Space& home, Propagator& p);
1195  void reschedule(Space& home, Propagator& p);
1197  void update(Space& home, EmptyScaleBoolArray& esba);
1199  ScaleBool* fst(void) const;
1201  ScaleBool* lst(void) const;
1203  void fst(ScaleBool* f);
1205  void lst(ScaleBool* l);
1207  bool empty(void) const;
1209  int size(void) const;
1211  void sort(void);
1212  };
1213 
1214 
1219  template<class SBAP, class SBAN, class VX, PropCond pcx>
1220  class LinBoolScale : public Propagator {
1221  protected:
1223  SBAP p;
1225  SBAN n;
1227  VX x;
1229  int c;
1230  public:
1232  LinBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1234  LinBoolScale(Space& home, Propagator& pr,
1235  SBAP& p, SBAN& n, VX x, int c);
1237  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
1239  virtual void reschedule(Space& home);
1241  virtual size_t dispose(Space& home);
1242  };
1243 
1250  template<class SBAP, class SBAN, class VX>
1251  class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
1252  protected:
1257  public:
1259  EqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1261  EqBoolScale(Space& home, Propagator& pr,
1262  SBAP& p, SBAN& n, VX x, int c);
1264  virtual Actor* copy(Space& home);
1266  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1268  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1269  };
1270 
1277  template<class SBAP, class SBAN, class VX>
1278  class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
1279  protected:
1284  public:
1286  LqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1288  LqBoolScale(Space& home, Propagator& pr,
1289  SBAP& p, SBAN& n, VX x, int c);
1291  virtual Actor* copy(Space& home);
1293  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1295  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1296  };
1297 
1304  template<class SBAP, class SBAN, class VX>
1305  class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
1306  protected:
1311  public:
1313  NqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1315  NqBoolScale(Space& home, Propagator& pr,
1316  SBAP& p, SBAN& n, VX x, int c);
1318  virtual Actor* copy(Space& home);
1320  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1322  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1323  };
1324 
1325 }}}
1326 
1328 
1329 namespace Gecode { namespace Int { namespace Linear {
1330 
1335  template<class View>
1336  class Term {
1337  public:
1339  int a;
1341  View x;
1342  };
1343 
1358  template<class View>
1359  void estimate(Term<View>* t, int n, int c,
1360  int& l, int& u);
1361 
1389  GECODE_INT_EXPORT void
1390  post(Home home, Term<IntView>* t, int n, IntRelType irt, int c,
1392 
1422  GECODE_INT_EXPORT void
1423  post(Home home, Term<IntView>* t, int n, IntRelType irt, int c, Reify r,
1425 
1453  GECODE_INT_EXPORT void
1454  post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c,
1456 
1485  GECODE_INT_EXPORT void
1486  post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c, Reify r,
1488 
1517  GECODE_INT_EXPORT void
1518  post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y, int c=0,
1520 
1549  GECODE_INT_EXPORT void
1550  post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y,
1552 
1553 }}}
1554 
1555 #include <gecode/int/linear/post.hpp>
1556 
1557 #endif
1558 
1559 // STATISTICS: int-prop
Propagator for bounds consistent binary linear disequality
Definition: linear.hh:201
ViewArray< VX > x
Boolean views.
Definition: linear.hh:792
Council of advisors
Definition: core.hpp:154
NodeType t
Type of node.
Definition: bool-expr.cpp:230
ViewArray< XV > x
Boolean views.
Definition: linear.hh:1026
Propagator for inequality to Boolean sum with coefficients
Definition: linear.hh:1278
BoolView x
Boolean view.
Definition: linear.hh:1135
Propagator for bounds consistent n-ary linear equality
Definition: linear.hh:577
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
Empty array of scale Boolean views.
Definition: linear.hh:1184
ViewArray< N > y
Array of negative views.
Definition: linear.hh:502
Propagator for reified bounds consistent n-ary linear less or equal
Definition: linear.hh:749
Propagator for bounds consistent binary linear greater or equal
Definition: linear.hh:271
int n_s
Number of subscriptions.
Definition: linear.hh:923
Base-class for Boolean linear propagators.
Definition: linear.hh:1023
B x1
View of type B.
Definition: linear.hh:70
int a
Coefficient.
Definition: linear.hh:1339
Propagator for bounds consistent n-ary linear disequality
Definition: linear.hh:683
void cancel(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:81
Propagator for domain consistent n-ary linear equality
Definition: linear.hh:608
ExecStatus resubscribe(Space &home, Propagator &p, VX &x0, ViewArray< VX > &x, VY &x1, ViewArray< VY > &y)
Definition: clause.hpp:138
Baseclass for integer Boolean sum.
Definition: linear.hh:787
Propagator for integer disequal to Boolean sum (cardinality)
Definition: linear.hh:883
Propagator for bounds consistent ternary linear equality
Definition: linear.hh:384
bool normalize(Term< View > *t, int &n, Term< View > *&t_p, int &n_p, Term< View > *&t_n, int &n_n, int &g)
Normalize linear integer constraints.
Definition: post.hpp:115
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: int-bin.hpp:67
Base-class for reified n-ary linear propagators.
Definition: linear.hh:529
Base-class for propagators.
Definition: core.hpp:1023
YV y
View to compare number of assigned Boolean views to.
Definition: linear.hh:1028
Base-class for advisors.
Definition: core.hpp:1251
Base-class for ternary linear propagators.
Definition: linear.hh:346
Base-class for n-ary linear propagators.
Definition: linear.hh:497
Propagator for bounds consistent binary linear equality
Definition: linear.hh:134
Computation spaces.
Definition: core.hpp:1701
Base-class for binary linear propagators.
Definition: linear.hh:65
Propagator for equality to Boolean sum (cardinality)
Definition: linear.hh:1052
Base-class for both propagators and branchers.
Definition: core.hpp:627
int c
Integer constant on right-hand side.
Definition: linear.hh:1229
Propagator for equality to Boolean sum with coefficients
Definition: linear.hh:1251
Gecode::IntSet d(v, 7)
ViewArray< P > x
Array of positive views.
Definition: linear.hh:500
Council< Advisor > co
Council for single advisor.
Definition: linear.hh:919
Propagator for bounds consistent ternary linear less or equal
Definition: linear.hh:454
Propagator for greater or equal to Boolean sum (cardinality)
Definition: linear.hh:1104
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
Definition: sort.hpp:133
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: int-bin.hpp:80
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
virtual void reschedule(Space &home)
Schedule function.
Definition: int-bin.hpp:73
int n_as
Number of active subscriptions.
Definition: linear.hh:794
int c
Righthandside (constant part from Boolean views assigned to 1)
Definition: linear.hh:1030
void bounds_n(ModEventDelta med, ViewArray< View > &y, Val &c, Val &sl, Val &su)
Definition: int-nary.hpp:161
IntRelType
Relation types for integers.
Definition: int.hh:925
Binary propagator.
Definition: pattern.hpp:84
Propagator for integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:851
Propagator for integer equal to Boolean sum (cardinality)
Definition: linear.hh:819
Simple propagation levels.
Definition: int.hh:976
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:71
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1034
Propagator for bounds consistent binary linear less or equal
Definition: linear.hh:237
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
A x0
View of type A.
Definition: linear.hh:349
Reification specification.
Definition: int.hh:876
int c
Righthandside.
Definition: linear.hh:798
size_t size
The size of the propagator (used during subsumption)
Definition: core.hpp:1036
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Advise function.
Definition: core.cpp:67
Propagator for reified bounds consistent n-ary linear equality
Definition: linear.hh:649
B x1
View of type B.
Definition: linear.hh:351
B x1
View of type B.
Definition: linear.hh:103
void bounds_p(ModEventDelta med, ViewArray< View > &x, Val &c, Val &sl, Val &su)
Definition: int-nary.hpp:140
Propagator for reified integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:955
Propagator for reified integer equal to Boolean sum (cardinality)
Definition: linear.hh:987
Propagator for disequality to Boolean sum with coefficients
Definition: linear.hh:1305
SBAN n
Negative Boolean views with coefficients on left-hand side.
Definition: linear.hh:1225
Baseclass for reified integer Boolean sum.
Definition: linear.hh:916
Propagator for reified bounds consistent binary linear less or equal
Definition: linear.hh:305
Base class for linear Boolean constraints with coefficients.
Definition: linear.hh:1220
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:974
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Integer view for integer variables.
Definition: view.hpp:129
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Val c
Value of type Val.
Definition: linear.hh:105
Array of scale Boolean views.
Definition: linear.hh:1139
SBAP p
Positive Boolean views with coefficients on left-hand side.
Definition: linear.hh:1223
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
Traits for Boolean negation view.
Definition: linear.hh:946
Propagation cost.
Definition: core.hpp:485
Base-class for reified binary linear propagators.
Definition: linear.hh:98
ExecStatus
Definition: core.hpp:471
void estimate(Term< View > *t, int n, int c, int &l, int &u)
Estimate lower and upper bounds.
Definition: post.hpp:41
Ctrl b
Control view for reification.
Definition: linear.hh:107
LinBin(Space &home, LinBin &p)
Constructor for cloning p.
Definition: int-bin.hpp:50
Propagator for reified bounds consistent binary linear equality
Definition: linear.hh:168
Coefficient and Boolean view.
Definition: linear.hh:1130
Post propagator for SetVar x
Definition: set.hh:767
Val c
Constant value.
Definition: linear.hh:504
Council< Advisor > co
Council for managing single advisor.
Definition: linear.hh:790
int n_hs
Number of views that have or had subscriptions.
Definition: linear.hh:796
Ctrl b
Control view for reification.
Definition: linear.hh:534
Class for describing linear term .
Definition: linear.hh:1336
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)=0
Propagation function.
ViewArray< VX > x
Views not yet subscribed to.
Definition: linear.hh:888
Val c
Value of type Val.
Definition: linear.hh:355
A x0
View of type A.
Definition: linear.hh:68
Gecode toplevel namespace
A x0
View of type A.
Definition: linear.hh:101
Propagator for bounds consistent n-ary linear less or equal
Definition: linear.hh:716
Propagator for disequality to Boolean sum (cardinality)
Definition: linear.hh:1078
Val c
Value of type Val.
Definition: linear.hh:72
int a
Integer coefficient.
Definition: linear.hh:1133
void post(Home home, Term< BoolView > *t, int n, IntRelType irt, IntView x, int c, IntPropLevel)
Post propagator for linear constraint over Booleans.
Definition: bool-post.cpp:589
#define GECODE_INT_EXPORT
Definition: int.hh:81
Propagator for bounds consistent ternary linear disquality
Definition: linear.hh:419
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
Home class for posting propagators
Definition: core.hpp:853
VX x
Integer view on right-hand side.
Definition: linear.hh:1227
virtual Actor * copy(Space &home)=0
Create copy.
VB b
Control variable.
Definition: linear.hh:927
C x2
View of type C.
Definition: linear.hh:353
void update(IntSet &y, Space &home, IntSet &py)
Definition: rel.hpp:103
int c
Righthandside.
Definition: linear.hh:890
struct Gecode::@593::NNF::@62::@64 a
For atomic nodes.
Boolean view for Boolean variables.
Definition: view.hpp:1380
ViewArray< VX > x
Views.
Definition: linear.hh:921