Generated on Tue Jul 18 2017 18:41:42 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  * Last modified:
14  * $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
15  * $Revision: 15137 $
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 #ifndef __GECODE_INT_LINEAR_HH__
43 #define __GECODE_INT_LINEAR_HH__
44 
45 #include <gecode/int.hh>
46 
52 namespace Gecode { namespace Int { namespace Linear {
53 
54  /*
55  * Binary propagators
56  *
57  */
58 
68  template<class Val, class A, class B, PropCond pc>
69  class LinBin : public Propagator {
70  protected:
72  A x0;
74  B x1;
76  Val c;
78  LinBin(Space& home, bool share, LinBin& p);
80  LinBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
82  LinBin(Home home, A x0, B x1, Val c);
83  public:
85  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
87  virtual void reschedule(Space& home);
89  virtual size_t dispose(Space& home);
90  };
91 
101  template<class Val, class A, class B, PropCond pc, class Ctrl>
102  class ReLinBin : public Propagator {
103  protected:
105  A x0;
107  B x1;
109  Val c;
111  Ctrl b;
113  ReLinBin(Space& home, bool share, ReLinBin& p);
115  ReLinBin(Home home, A x0, B x1, Val c, Ctrl b);
116  public:
118  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
120  virtual void reschedule(Space& home);
122  virtual size_t dispose(Space& home);
123  };
124 
137  template<class Val, class A, class B>
138  class EqBin : public LinBin<Val,A,B,PC_INT_BND> {
139  protected:
143 
145  EqBin(Space& home, bool share, EqBin& p);
147  EqBin(Home home, A x0, B x1, Val c);
148  public:
150  EqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
152  virtual Actor* copy(Space& home, bool share);
154  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
156  static ExecStatus post(Home home, A x0, B x1, Val c);
157  };
158 
171  template<class Val, class A, class B, class Ctrl, ReifyMode rm>
172  class ReEqBin : public ReLinBin<Val,A,B,PC_INT_BND,Ctrl> {
173  protected:
178 
180  ReEqBin(Space& home, bool share, ReEqBin& p);
182  ReEqBin(Home home,A,B,Val,Ctrl);
183  public:
185  virtual Actor* copy(Space& home, bool share);
187  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
189  static ExecStatus post(Home home, A x0, B x1, Val c, Ctrl b);
190  };
191 
204  template<class Val, class A, class B>
205  class NqBin : public LinBin<Val,A,B,PC_INT_VAL> {
206  protected:
210 
212  NqBin(Space& home, bool share, NqBin& p);
214  NqBin(Home home, A x0, B x1, Val c);
215  public:
217  NqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
219  virtual Actor* copy(Space& home, bool share);
221  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
223  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
225  static ExecStatus post(Home home, A x0, B x1, Val c);
226  };
227 
240  template<class Val, class A, class B>
241  class LqBin : public LinBin<Val,A,B,PC_INT_BND> {
242  protected:
246 
248  LqBin(Space& home, bool share, LqBin& p);
250  LqBin(Home home, A x0, B x1, Val c);
251  public:
253  LqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
255  virtual Actor* copy(Space& home, bool share);
257  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
259  static ExecStatus post(Home home, A x0, B x1, Val c);
260  };
261 
274  template<class Val, class A, class B>
275  class GqBin : public LinBin<Val,A,B,PC_INT_BND> {
276  protected:
280 
282  GqBin(Space& home, bool share, GqBin& p);
284  GqBin(Home home, A x0, B x1, Val c);
285  public:
287  GqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
289  virtual Actor* copy(Space& home, bool share);
291  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
293  static ExecStatus post(Home home, A x0, B x1, Val c);
294  };
295 
308  template<class Val, class A, class B, ReifyMode rm>
309  class ReLqBin : public ReLinBin<Val,A,B,PC_INT_BND,BoolView> {
310  protected:
315 
317  ReLqBin(Space& home, bool share, ReLqBin& p);
319  ReLqBin(Home home, A x0, B x1, Val c, BoolView b);
320  public:
322  virtual Actor* copy(Space& home, bool share);
324  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
326  static ExecStatus post(Home home, A x0, B x1, Val c, BoolView b);
327  };
328 
329 }}}
330 
332 
333 namespace Gecode { namespace Int { namespace Linear {
334 
335  /*
336  * Ternary propagators
337  *
338  */
339 
349  template<class Val, class A, class B, class C, PropCond pc>
350  class LinTer : public Propagator {
351  protected:
353  A x0;
355  B x1;
357  C x2;
359  Val c;
361  LinTer(Space& home, bool share, LinTer& p);
363  LinTer(Home home, A x0, B x1, C x2, Val c);
365  LinTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
366  public:
368  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
370  virtual void reschedule(Space& home);
372  virtual size_t dispose(Space& home);
373  };
374 
387  template<class Val, class A, class B, class C>
388  class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
389  protected:
394 
396  EqTer(Space& home, bool share, EqTer& p);
398  EqTer(Home home, A x0, B x1, C x2, Val c);
399  public:
401  EqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
403  virtual Actor* copy(Space& home, bool share);
405  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
407  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
408  };
409 
422  template<class Val, class A, class B, class C>
423  class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
424  protected:
429 
431  NqTer(Space& home, bool share, NqTer& p);
433  NqTer(Home home, A x0, B x1, C x2, Val c);
434  public:
436  NqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
438  virtual Actor* copy(Space& home, bool share);
440  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
442  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
443  };
444 
457  template<class Val, class A, class B, class C>
458  class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
459  protected:
464 
466  LqTer(Space& home, bool share, LqTer& p);
468  LqTer(Home home, A x0, B x1, C x2, Val c);
469  public:
471  LqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
473  virtual Actor* copy(Space& home, bool share);
475  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
477  static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
478  };
479 
480 }}}
481 
483 
484 namespace Gecode { namespace Int { namespace Linear {
485 
486  /*
487  * n-ary propagators
488  *
489  */
490 
500  template<class Val, class P, class N, PropCond pc>
501  class Lin : public Propagator {
502  protected:
508  Val c;
509 
511  Lin(Space& home, bool share, Lin<Val,P,N,pc>& p);
513  Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
514  public:
516  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
518  virtual void reschedule(Space& home);
520  virtual size_t dispose(Space& home);
521  };
522 
532  template<class Val, class P, class N, PropCond pc, class Ctrl>
533  class ReLin : public Lin<Val,P,N,pc> {
534  protected:
535  using Lin<Val,P,N,pc>::x;
536  using Lin<Val,P,N,pc>::y;
538  Ctrl b;
540  ReLin(Space& home, bool share, ReLin& p);
542  ReLin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
543  public:
545  virtual void reschedule(Space& home);
547  virtual size_t dispose(Space& home);
548  };
549 
555  template<class Val, class View>
557  Val& c, Val& sl, Val& su);
558 
564  template<class Val, class View>
566  Val& c, Val& sl, Val& su);
567 
580  template<class Val, class P, class N>
581  class Eq : public Lin<Val,P,N,PC_INT_BND> {
582  protected:
586 
588  Eq(Space& home, bool share, Eq& p);
589  public:
591  Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
593  virtual Actor* copy(Space& home, bool share);
595  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
597  static ExecStatus
598  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
599  };
600 
611  template<class Val, class View>
612  class DomEq
613  : public Lin<Val,View,View,PC_INT_DOM> {
614  protected:
618 
620  DomEq(Space& home, bool share, DomEq& p);
621  public:
623  DomEq(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
625  virtual Actor* copy(Space& home, bool share);
632  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
634  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
636  static ExecStatus
637  post(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
638  };
639 
652  template<class Val, class P, class N, class Ctrl, ReifyMode rm>
653  class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
654  protected:
659 
661  ReEq(Space& home, bool share, ReEq& p);
662  public:
664  ReEq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
666  virtual Actor* copy(Space& home, bool share);
668  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
670  static ExecStatus
671  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
672  };
673 
686  template<class Val, class P, class N>
687  class Nq : public Lin<Val,P,N,PC_INT_VAL> {
688  protected:
692 
694  Nq(Space& home, bool share, Nq& p);
695  public:
697  Nq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
699  virtual Actor* copy(Space& home, bool share);
701  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
703  static ExecStatus
704  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
705  };
706 
719  template<class Val, class P, class N>
720  class Lq : public Lin<Val,P,N,PC_INT_BND> {
721  protected:
725 
727  Lq(Space& home, bool share, Lq& p);
728  public:
730  Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
732  virtual Actor* copy(Space& home, bool share);
734  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
736  static ExecStatus
737  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
738  };
739 
752  template<class Val, class P, class N, ReifyMode rm>
753  class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
754  protected:
759 
761  ReLq(Space& home, bool share, ReLq& p);
762  public:
764  ReLq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
766  virtual Actor* copy(Space& home, bool share);
768  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
770  static ExecStatus
771  post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
772  };
773 
774 }}}
775 
778 
779 namespace Gecode { namespace Int { namespace Linear {
780 
781  /*
782  * Boolean linear propagators
783  *
784  */
785 
790  template<class VX>
791  class LinBoolInt : public Propagator {
792  protected:
798  int n_as;
800  int n_hs;
802  int c;
804  void normalize(void);
806  LinBoolInt(Space& home, bool share, LinBoolInt& p);
808  LinBoolInt(Home home, ViewArray<VX>& x, int n_s, int c);
809  public:
811  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
813  virtual size_t dispose(Space& home);
814  };
815 
822  template<class VX>
823  class EqBoolInt : public LinBoolInt<VX> {
824  protected:
825  using LinBoolInt<VX>::co;
826  using LinBoolInt<VX>::x;
827  using LinBoolInt<VX>::n_as;
828  using LinBoolInt<VX>::n_hs;
829  using LinBoolInt<VX>::c;
832  EqBoolInt(Space& home, bool share, EqBoolInt& p);
834  EqBoolInt(Home home, ViewArray<VX>& x, int c);
835  public:
837  virtual Actor* copy(Space& home, bool share);
839  virtual void reschedule(Space& home);
841  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
843  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
845  static ExecStatus post(Home home, ViewArray<VX>& x, int c);
846  };
847 
854  template<class VX>
855  class GqBoolInt : public LinBoolInt<VX> {
856  protected:
857  using LinBoolInt<VX>::co;
858  using LinBoolInt<VX>::x;
859  using LinBoolInt<VX>::n_as;
860  using LinBoolInt<VX>::n_hs;
861  using LinBoolInt<VX>::c;
864  GqBoolInt(Space& home, bool share, GqBoolInt& p);
866  GqBoolInt(Home home, ViewArray<VX>& x, int c);
867  public:
869  virtual Actor* copy(Space& home, bool share);
871  virtual void reschedule(Space& home);
873  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
875  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
877  static ExecStatus post(Home home, ViewArray<VX>& x, int c);
878  };
879 
886  template<class VX>
887  class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
888  protected:
894  int c;
896  bool resubscribe(Space& home, VX& y);
898  NqBoolInt(Home home, ViewArray<VX>& b, int c);
900  NqBoolInt(Space& home, bool share, NqBoolInt<VX>& p);
901  public:
903  virtual Actor* copy(Space& home, bool share);
905  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
907  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
909  static ExecStatus post(Home home, ViewArray<VX>& b, int c);
911  virtual size_t dispose(Space& home);
912  };
913 
914 
919  template<class VX, class VB>
920  class ReLinBoolInt : public Propagator {
921  protected:
927  int n_s;
929  int c;
931  VB b;
933  void normalize(void);
935  ReLinBoolInt(Space& home, bool share, ReLinBoolInt& p);
937  ReLinBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
938  public:
940  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
942  virtual size_t dispose(Space& home);
943  };
944 
945 
949  template<class BV>
950  class BoolNegTraits {};
951 
958  template<class VX, class VB, ReifyMode rm>
959  class ReGqBoolInt : public ReLinBoolInt<VX,VB> {
960  protected:
968  ReGqBoolInt(Space& home, bool share, ReGqBoolInt& p);
970  ReGqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
971  public:
973  virtual Actor* copy(Space& home, bool share);
975  virtual void reschedule(Space& home);
977  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
979  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
981  static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
982  };
983 
990  template<class VX, class VB, ReifyMode rm>
991  class ReEqBoolInt : public ReLinBoolInt<VX,VB> {
992  protected:
1000  ReEqBoolInt(Space& home, bool share, ReEqBoolInt& p);
1002  ReEqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
1003  public:
1005  virtual Actor* copy(Space& home, bool share);
1007  virtual void reschedule(Space& home);
1009  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
1011  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1013  static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
1014  };
1015 
1016 }}}
1017 
1019 
1020 namespace Gecode { namespace Int { namespace Linear {
1021 
1026  template<class XV, class YV>
1027  class LinBoolView : public Propagator {
1028  protected:
1032  YV y;
1034  int c;
1036  LinBoolView(Space& home, bool share, LinBoolView& p);
1038  LinBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1039  public:
1041  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
1043  virtual void reschedule(Space& home);
1045  virtual size_t dispose(Space& home);
1046  };
1047 
1048 
1055  template<class XV, class YV>
1056  class EqBoolView : public LinBoolView<XV,YV> {
1057  protected:
1058  using LinBoolView<XV,YV>::x;
1059  using LinBoolView<XV,YV>::y;
1060  using LinBoolView<XV,YV>::c;
1061 
1063  EqBoolView(Space& home, bool share, EqBoolView& p);
1065  EqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1066  public:
1068  virtual Actor* copy(Space& home, bool share);
1070  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1072  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1073  };
1074 
1081  template<class XV, class YV>
1082  class NqBoolView : public LinBoolView<XV,YV> {
1083  protected:
1084  using LinBoolView<XV,YV>::x;
1085  using LinBoolView<XV,YV>::y;
1086  using LinBoolView<XV,YV>::c;
1087 
1089  NqBoolView(Space& home, bool share, NqBoolView& p);
1091  NqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1092  public:
1094  virtual Actor* copy(Space& home, bool share);
1096  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1098  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1099  };
1100 
1107  template<class XV, class YV>
1108  class GqBoolView : public LinBoolView<XV,YV> {
1109  protected:
1110  using LinBoolView<XV,YV>::x;
1111  using LinBoolView<XV,YV>::y;
1112  using LinBoolView<XV,YV>::c;
1113 
1115  GqBoolView(Space& home, bool share, GqBoolView& p);
1117  GqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
1118  public:
1120  virtual Actor* copy(Space& home, bool share);
1122  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1124  static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
1125  };
1126 
1127 }}}
1128 
1130 
1131 namespace Gecode { namespace Int { namespace Linear {
1132 
1134  class ScaleBool {
1135  public:
1137  int a;
1140  };
1141 
1144  private:
1146  ScaleBool* _fst;
1148  ScaleBool* _lst;
1149  public:
1151  ScaleBoolArray(void);
1153  ScaleBoolArray(Space& home, int n);
1155  void subscribe(Space& home, Propagator& p);
1157  void cancel(Space& home, Propagator& p);
1159  void reschedule(Space& home, Propagator& p);
1161  void update(Space& home, bool share, ScaleBoolArray& sba);
1163  ScaleBool* fst(void) const;
1165  ScaleBool* lst(void) const;
1167  void fst(ScaleBool* f);
1169  void lst(ScaleBool* l);
1171  bool empty(void) const;
1173  int size(void) const;
1174  private:
1176  class ScaleDec {
1177  public:
1178  bool
1179  operator ()(const ScaleBool& x, const ScaleBool& y);
1180  };
1181  public:
1183  void sort(void);
1184  };
1185 
1186 
1189  public:
1191  EmptyScaleBoolArray(void);
1193  EmptyScaleBoolArray(Space& home, int n);
1195  void subscribe(Space& home, Propagator& p);
1197  void cancel(Space& home, Propagator& p);
1199  void reschedule(Space& home, Propagator& p);
1201  void update(Space& home, bool share, EmptyScaleBoolArray& esba);
1203  ScaleBool* fst(void) const;
1205  ScaleBool* lst(void) const;
1207  void fst(ScaleBool* f);
1209  void lst(ScaleBool* l);
1211  bool empty(void) const;
1213  int size(void) const;
1215  void sort(void);
1216  };
1217 
1218 
1223  template<class SBAP, class SBAN, class VX, PropCond pcx>
1224  class LinBoolScale : public Propagator {
1225  protected:
1227  SBAP p;
1229  SBAN n;
1231  VX x;
1233  int c;
1234  public:
1236  LinBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1238  LinBoolScale(Space& home, bool share, Propagator& pr,
1239  SBAP& p, SBAN& n, VX x, int c);
1241  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
1243  virtual void reschedule(Space& home);
1245  virtual size_t dispose(Space& home);
1246  };
1247 
1254  template<class SBAP, class SBAN, class VX>
1255  class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
1256  protected:
1261  public:
1263  EqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1265  EqBoolScale(Space& home, bool share, Propagator& pr,
1266  SBAP& p, SBAN& n, VX x, int c);
1268  virtual Actor* copy(Space& home, bool share);
1270  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1272  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1273  };
1274 
1281  template<class SBAP, class SBAN, class VX>
1282  class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
1283  protected:
1288  public:
1290  LqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1292  LqBoolScale(Space& home, bool share, Propagator& pr,
1293  SBAP& p, SBAN& n, VX x, int c);
1295  virtual Actor* copy(Space& home, bool share);
1297  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1299  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1300  };
1301 
1308  template<class SBAP, class SBAN, class VX>
1309  class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
1310  protected:
1315  public:
1317  NqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
1319  NqBoolScale(Space& home, bool share, Propagator& pr,
1320  SBAP& p, SBAN& n, VX x, int c);
1322  virtual Actor* copy(Space& home, bool share);
1324  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
1326  static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
1327  };
1328 
1329 }}}
1330 
1332 
1333 namespace Gecode { namespace Int { namespace Linear {
1334 
1339  template<class View>
1340  class Term {
1341  public:
1343  int a;
1345  View x;
1346  };
1347 
1362  template<class View>
1363  void estimate(Term<View>* t, int n, int c,
1364  int& l, int& u);
1365 
1393  GECODE_INT_EXPORT void
1394  post(Home home, Term<IntView>* t, int n, IntRelType irt, int c,
1396 
1426  GECODE_INT_EXPORT void
1427  post(Home home, Term<IntView>* t, int n, IntRelType irt, int c, Reify r,
1429 
1457  GECODE_INT_EXPORT void
1458  post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c,
1460 
1489  GECODE_INT_EXPORT void
1490  post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c, Reify r,
1492 
1521  GECODE_INT_EXPORT void
1522  post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y, int c=0,
1524 
1553  GECODE_INT_EXPORT void
1554  post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y,
1556 
1557 }}}
1558 
1559 #include <gecode/int/linear/post.hpp>
1560 
1561 #endif
1562 
1563 // STATISTICS: int-prop
Propagator for bounds consistent binary linear disequality
Definition: linear.hh:205
ViewArray< VX > x
Boolean views.
Definition: linear.hh:796
Council of advisors
Definition: core.hpp:232
NodeType t
Type of node.
Definition: bool-expr.cpp:234
ViewArray< XV > x
Boolean views.
Definition: linear.hh:1030
Propagator for inequality to Boolean sum with coefficients
Definition: linear.hh:1282
BoolView x
Boolean view.
Definition: linear.hh:1139
Propagator for bounds consistent n-ary linear equality
Definition: linear.hh:581
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
Empty array of scale Boolean views.
Definition: linear.hh:1188
ViewArray< N > y
Array of negative views.
Definition: linear.hh:506
Propagator for reified bounds consistent n-ary linear less or equal
Definition: linear.hh:753
Propagator for bounds consistent binary linear greater or equal
Definition: linear.hh:275
int n_s
Number of subscriptions.
Definition: linear.hh:927
virtual Actor * copy(Space &home, bool share)=0
Create copy.
Base-class for Boolean linear propagators.
Definition: linear.hh:1027
B x1
View of type B.
Definition: linear.hh:74
int a
Coefficient.
Definition: linear.hh:1343
Propagator for bounds consistent n-ary linear disequality
Definition: linear.hh:687
void cancel(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:85
Propagator for domain consistent n-ary linear equality
Definition: linear.hh:612
ExecStatus resubscribe(Space &home, Propagator &p, VX &x0, ViewArray< VX > &x, VY &x1, ViewArray< VY > &y)
Definition: clause.hpp:142
Baseclass for integer Boolean sum.
Definition: linear.hh:791
Propagator for integer disequal to Boolean sum (cardinality)
Definition: linear.hh:887
Propagator for bounds consistent ternary linear equality
Definition: linear.hh:388
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:119
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low binary)
Definition: int-bin.hpp:71
Base-class for reified n-ary linear propagators.
Definition: linear.hh:533
Base-class for propagators.
Definition: core.hpp:1092
YV y
View to compare number of assigned Boolean views to.
Definition: linear.hh:1032
Base-class for advisors.
Definition: core.hpp:1294
Base-class for ternary linear propagators.
Definition: linear.hh:350
Base-class for n-ary linear propagators.
Definition: linear.hh:501
Propagator for bounds consistent binary linear equality
Definition: linear.hh:138
Computation spaces.
Definition: core.hpp:1748
Base-class for binary linear propagators.
Definition: linear.hh:69
Propagator for equality to Boolean sum (cardinality)
Definition: linear.hh:1056
Base-class for both propagators and branchers.
Definition: core.hpp:696
int c
Integer constant on right-hand side.
Definition: linear.hh:1233
Propagator for equality to Boolean sum with coefficients
Definition: linear.hh:1255
Gecode::IntSet d(v, 7)
ViewArray< P > x
Array of positive views.
Definition: linear.hh:504
Council< Advisor > co
Council for single advisor.
Definition: linear.hh:923
Propagator for bounds consistent ternary linear less or equal
Definition: linear.hh:458
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Propagator for greater or equal to Boolean sum (cardinality)
Definition: linear.hh:1108
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
Definition: sort.hpp:137
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: int-bin.hpp:84
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
virtual void reschedule(Space &home)
Schedule function.
Definition: int-bin.hpp:77
int n_as
Number of active subscriptions.
Definition: linear.hh:798
int c
Righthandside (constant part from Boolean views assigned to 1)
Definition: linear.hh:1034
void bounds_n(ModEventDelta med, ViewArray< View > &y, Val &c, Val &sl, Val &su)
Definition: int-nary.hpp:165
IntRelType
Relation types for integers.
Definition: int.hh:906
Binary propagator.
Definition: propagator.hpp:89
Propagator for integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:855
Propagator for integer equal to Boolean sum (cardinality)
Definition: linear.hh:823
Simple propagation levels.
Definition: int.hh:957
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:75
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1103
Propagator for bounds consistent binary linear less or equal
Definition: linear.hh:241
A x0
View of type A.
Definition: linear.hh:353
Reification specification.
Definition: int.hh:857
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
int c
Righthandside.
Definition: linear.hh:802
size_t size
The size of the propagator (used during subsumption)
Definition: core.hpp:1105
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:653
B x1
View of type B.
Definition: linear.hh:355
B x1
View of type B.
Definition: linear.hh:107
void bounds_p(ModEventDelta med, ViewArray< View > &x, Val &c, Val &sl, Val &su)
Definition: int-nary.hpp:144
Propagator for reified integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:959
Propagator for reified integer equal to Boolean sum (cardinality)
Definition: linear.hh:991
Propagator for disequality to Boolean sum with coefficients
Definition: linear.hh:1309
SBAN n
Negative Boolean views with coefficients on left-hand side.
Definition: linear.hh:1229
Baseclass for reified integer Boolean sum.
Definition: linear.hh:920
Propagator for reified bounds consistent binary linear less or equal
Definition: linear.hh:309
Base class for linear Boolean constraints with coefficients.
Definition: linear.hh:1224
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:784
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:955
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:784
Val c
Value of type Val.
Definition: linear.hh:109
Array of scale Boolean views.
Definition: linear.hh:1143
SBAP p
Positive Boolean views with coefficients on left-hand side.
Definition: linear.hh:1227
Generic domain change information to be supplied to advisors.
Definition: core.hpp:281
Traits for Boolean negation view.
Definition: linear.hh:950
Propagation cost.
Definition: core.hpp:554
Base-class for reified binary linear propagators.
Definition: linear.hh:102
ExecStatus
Definition: core.hpp:540
void estimate(Term< View > *t, int n, int c, int &l, int &u)
Estimate lower and upper bounds.
Definition: post.hpp:45
Ctrl b
Control view for reification.
Definition: linear.hh:111
Propagator for reified bounds consistent binary linear equality
Definition: linear.hh:172
Coefficient and Boolean view.
Definition: linear.hh:1134
Post propagator for SetVar x
Definition: set.hh:784
Val c
Constant value.
Definition: linear.hh:508
Council< Advisor > co
Council for managing single advisor.
Definition: linear.hh:794
int n_hs
Number of views that have or had subscriptions.
Definition: linear.hh:800
Ctrl b
Control view for reification.
Definition: linear.hh:538
Class for describing linear term .
Definition: linear.hh:1340
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)=0
Propagation function.
ViewArray< VX > x
Views not yet subscribed to.
Definition: linear.hh:892
Val c
Value of type Val.
Definition: linear.hh:359
A x0
View of type A.
Definition: linear.hh:72
LinBin(Space &home, bool share, LinBin &p)
Constructor for cloning p.
Definition: int-bin.hpp:54
Gecode toplevel namespace
A x0
View of type A.
Definition: linear.hh:105
Propagator for bounds consistent n-ary linear less or equal
Definition: linear.hh:720
Propagator for disequality to Boolean sum (cardinality)
Definition: linear.hh:1082
Val c
Value of type Val.
Definition: linear.hh:76
int a
Integer coefficient.
Definition: linear.hh:1137
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:593
#define GECODE_INT_EXPORT
Definition: int.hh:81
Propagator for bounds consistent ternary linear disquality
Definition: linear.hh:423
int ModEventDelta
Modification event deltas.
Definition: core.hpp:169
Home class for posting propagators
Definition: core.hpp:922
VX x
Integer view on right-hand side.
Definition: linear.hh:1231
VB b
Control variable.
Definition: linear.hh:931
C x2
View of type C.
Definition: linear.hh:357
int c
Righthandside.
Definition: linear.hh:894
Boolean view for Boolean variables.
Definition: view.hpp:1315
ViewArray< VX > x
Views.
Definition: linear.hh:925