3
* Christian Schulte <schulte@gecode.org>
4
* Guido Tack <tack@gecode.org>
7
* Christian Schulte, 2002
11
* $Date: 2005-11-01 16:35:02 +0100 (Tue, 01 Nov 2005) $ by $Author: schulte $
14
* This file is part of Gecode, the generic constraint
15
* development environment:
16
* http://www.gecode.org
18
* See the file "LICENSE" for information on usage and
19
* redistribution of this file, and for a
20
* DISCLAIMER OF ALL WARRANTIES.
24
#ifndef __GECODE_INT_LINEAR_HH__
25
#define __GECODE_INT_LINEAR_HH__
30
* \namespace Gecode::Int::Linear
31
* \brief %Linear propagators
34
namespace Gecode { namespace Int { namespace Linear {
42
* \brief Base-class for binary linear propagators
44
* The type \a Val can be either \c double or \c int, defining the
45
* numerical precision during propagation. The types \a A and \a B
46
* give the types of the views.
48
* The propagation condition \a pc refers to both views.
50
template <class Val, class A, class B, PropCond pc>
51
class LinBin : public Propagator {
57
/// Value of type \a Val
59
/// Constructor for cloning \a p
60
LinBin(Space* home, bool share, LinBin& p);
61
/// Constructor for creation
62
LinBin(Space* home, A x0, B x1, Val c);
64
/// Cost function (defined as PC_BINARY_LO)
65
virtual PropCost cost(void) const;
67
virtual ~LinBin(void);
71
* \brief Base-class for reified binary linear propagators
73
* The type \a Val can be either \c double or \c int, defining the
74
* numerical precision during propagation. The types \a A and \a B
75
* give the types of the views.
77
* The propagation condition \a pc refers to both views.
79
template <class Val, class A, class B, PropCond pc, class Ctrl>
80
class ReLinBin : public Propagator {
86
/// Value of type \a Val
88
/// Control view for reification
90
/// Constructor for cloning \a p
91
ReLinBin(Space* home, bool share, ReLinBin& p);
92
/// Constructor for creation
93
ReLinBin(Space* home, A x0, B x1, Val c, Ctrl b);
95
/// Cost function (defined as PC_BINARY_LO)
96
virtual PropCost cost(void) const;
98
virtual ~ReLinBin(void);
102
* \brief %Propagator for bounds-consistent binary linear equality
104
* The type \a Val can be either \c double or \c int, defining the
105
* numerical precision during propagation. The types \a A and \a B
106
* give the types of the views.
108
* The propagation condition \a pc refers to both views.
110
* Requires \code #include "int/linear.hh" \endcode
111
* \ingroup FuncIntProp
113
template <class Val, class A, class B>
114
class EqBin : public LinBin<Val,A,B,PC_INT_BND> {
116
using LinBin<Val,A,B,PC_INT_BND>::x0;
117
using LinBin<Val,A,B,PC_INT_BND>::x1;
118
using LinBin<Val,A,B,PC_INT_BND>::c;
120
/// Constructor for cloning \a p
121
EqBin(Space* home, bool share, EqBin& p);
122
/// Constructor for creation
123
EqBin(Space* home, A x0, B x1, Val c);
125
/// Create copy during cloning
126
virtual Actor* copy(Space* home, bool share);
127
/// Perform propagation
128
virtual ExecStatus propagate(Space* home);
129
/// Post propagator for \f$x_0+x_1 = c\f$
130
static ExecStatus post(Space* home, A x0, B x1, Val c);
134
* \brief %Propagator for reified bounds-consistent binary linear equality
136
* The type \a Val can be either \c double or \c int, defining the
137
* numerical precision during propagation. The types \a A and \a B
138
* give the types of the views.
140
* The propagation condition \a pc refers to both views.
142
* Requires \code #include "int/linear.hh" \endcode
143
* \ingroup FuncIntProp
145
template <class Val, class A, class B, class Ctrl>
146
class ReEqBin : public ReLinBin<Val,A,B,PC_INT_BND,Ctrl> {
148
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x0;
149
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x1;
150
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::c;
151
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::b;
153
/// Constructor for cloning \a p
154
ReEqBin(Space* home, bool share, ReEqBin& p);
155
/// Constructor for creation
156
ReEqBin(Space* home,A,B,Val,Ctrl);
158
/// Create copy during cloning
159
virtual Actor* copy(Space* home, bool share);
160
/// Perform propagation
161
virtual ExecStatus propagate(Space* home);
162
/// Post propagator for \f$(x_0+x_1 = c)\Leftrightarrow b\f$
163
static ExecStatus post(Space* home, A x0, B x1, Val c, Ctrl b);
167
* \brief %Propagator for bounds-consistent binary linear disequality
169
* The type \a Val can be either \c double or \c int, defining the
170
* numerical precision during propagation. The types \a A and \a B
171
* give the types of the views.
173
* The propagation condition \a pc refers to both views.
175
* Requires \code #include "int/linear.hh" \endcode
176
* \ingroup FuncIntProp
178
template <class Val, class A, class B>
179
class NqBin : public LinBin<Val,A,B,PC_INT_VAL> {
181
using LinBin<Val,A,B,PC_INT_VAL>::x0;
182
using LinBin<Val,A,B,PC_INT_VAL>::x1;
183
using LinBin<Val,A,B,PC_INT_VAL>::c;
185
/// Constructor for cloning \a p
186
NqBin(Space* home, bool share, NqBin& p);
187
/// Constructor for creation
188
NqBin(Space* home,A,B,Val);
190
/// Create copy during cloning
191
virtual Actor* copy(Space* home, bool share);
192
/// Perform propagation
193
virtual ExecStatus propagate(Space* home);
194
/// Cost function (defined as PC_UNARY_LO)
195
virtual PropCost cost(void) const;
196
/// Post propagator for \f$x_0+x_1 \neq c\f$
197
static ExecStatus post(Space* home, A x0, B x1, Val c);
201
* \brief %Propagator for bounds-consistent binary linear less or equal
203
* The type \a Val can be either \c double or \c int, defining the
204
* numerical precision during propagation. The types \a A and \a B
205
* give the types of the views.
207
* The propagation condition \a pc refers to both views.
209
* Requires \code #include "int/linear.hh" \endcode
210
* \ingroup FuncIntProp
212
template <class Val, class A, class B>
213
class LqBin : public LinBin<Val,A,B,PC_INT_BND> {
215
using LinBin<Val,A,B,PC_INT_BND>::x0;
216
using LinBin<Val,A,B,PC_INT_BND>::x1;
217
using LinBin<Val,A,B,PC_INT_BND>::c;
219
/// Constructor for cloning \a p
220
LqBin(Space* home, bool share, LqBin& p);
221
/// Constructor for creation
222
LqBin(Space* home, A x0, B x1, Val c);
224
/// Create copy during cloning
225
virtual Actor* copy(Space* home, bool share);
226
/// Perform propagation
227
virtual ExecStatus propagate(Space* home);
228
/// Post propagator for \f$x_0+x_1 \leq c\f$
229
static ExecStatus post(Space* home, A x0, B x1, Val c);
233
* \brief %Propagator for bounds-consistent binary linear greater or equal
235
* The type \a Val can be either \c double or \c int, defining the
236
* numerical precision during propagation. The types \a A and \a B
237
* give the types of the views.
239
* The propagation condition \a pc refers to both views.
241
* Requires \code #include "int/linear.hh" \endcode
242
* \ingroup FuncIntProp
244
template <class Val, class A, class B>
245
class GqBin : public LinBin<Val,A,B,PC_INT_BND> {
247
using LinBin<Val,A,B,PC_INT_BND>::x0;
248
using LinBin<Val,A,B,PC_INT_BND>::x1;
249
using LinBin<Val,A,B,PC_INT_BND>::c;
251
/// Constructor for cloning \a p
252
GqBin(Space* home, bool share, GqBin& p);
253
/// Constructor for creation
254
GqBin(Space* home, A x0, B x1, Val c);
256
/// Create copy during cloning
257
virtual Actor* copy(Space* home, bool share);
258
/// Perform propagation
259
virtual ExecStatus propagate(Space* home);
260
/// Post propagator for \f$x_0+x_1 \geq c\f$
261
static ExecStatus post(Space* home, A x0, B x1, Val c);
265
* \brief %Propagator for reified bounds-consistent binary linear less or equal
267
* The type \a Val can be either \c double or \c int, defining the
268
* numerical precision during propagation. The types \a A and \a B
269
* give the types of the views.
271
* The propagation condition \a pc refers to both views.
273
* Requires \code #include "int/linear.hh" \endcode
274
* \ingroup FuncIntProp
276
template <class Val, class A, class B>
277
class ReLqBin : public ReLinBin<Val,A,B,PC_INT_BND,BoolView> {
279
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x0;
280
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x1;
281
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::c;
282
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::b;
284
/// Constructor for cloning \a p
285
ReLqBin(Space* home, bool share, ReLqBin& p);
286
/// Constructor for creation
287
ReLqBin(Space* home, A x0, B x1, Val c, BoolView b);
289
/// Create copy during cloning
290
virtual Actor* copy(Space* home, bool share);
291
/// Perform propagation
292
virtual ExecStatus propagate(Space* home);
293
/// Post propagator for \f$(x_0+x_1 \leq c)\Leftrightarrow b\f$
294
static ExecStatus post(Space* home, A x0, B x1, Val c, BoolView b);
299
#include "int/linear/binary.icc"
301
namespace Gecode { namespace Int { namespace Linear {
304
* Ternary propagators
309
* \brief Base-class for ternary linear propagators
311
* The type \a Val can be either \c double or \c int, defining the
312
* numerical precision during propagation. The types \a A, \a B,
313
* and \a C give the types of the views.
315
* The propagation condition \a pc refers to all three views.
317
template <class Val, class A, class B, class C, PropCond pc>
318
class LinTer : public Propagator {
320
/// View of type \a A
322
/// View of type \a B
324
/// View of type \a C
326
/// Value of type \a Val
328
/// Constructor for cloning \a p
329
LinTer(Space* home, bool share, LinTer& p);
330
/// Constructor for creation
331
LinTer(Space* home, A x0, B x1, C x2, Val c);
333
/// Cost function (defined as PC_TERNARY_LO)
334
virtual PropCost cost(void) const;
336
virtual ~LinTer(void);
340
* \brief %Propagator for bounds-consistent ternary linear equality
342
* The type \a Val can be either \c double or \c int, defining the
343
* numerical precision during propagation. The types \a A, \a B,
344
* and \a C give the types of the views.
346
* The propagation condition \a pc refers to all three views.
348
* Requires \code #include "int/linear.hh" \endcode
349
* \ingroup FuncIntProp
351
template <class Val, class A, class B, class C>
352
class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
354
using LinTer<Val,A,B,C,PC_INT_BND>::x0;
355
using LinTer<Val,A,B,C,PC_INT_BND>::x1;
356
using LinTer<Val,A,B,C,PC_INT_BND>::x2;
357
using LinTer<Val,A,B,C,PC_INT_BND>::c;
359
/// Constructor for cloning \a p
360
EqTer(Space* home, bool share, EqTer& p);
361
/// Constructor for creation
362
EqTer(Space* home, A x0, B x1, C x2, Val c);
364
/// Create copy during cloning
365
virtual Actor* copy(Space* home, bool share);
366
/// Perform propagation
367
virtual ExecStatus propagate(Space* home);
368
/// Post propagator for \f$x_0+x_1+x_2 = c\f$
369
static ExecStatus post(Space* home, A x0, B x1, C x2, Val c);
373
* \brief %Propagator for bounds-consistent ternary linear disquality
375
* The type \a Val can be either \c double or \c int, defining the
376
* numerical precision during propagation. The types \a A, \a B,
377
* and \a C give the types of the views.
379
* The propagation condition \a pc refers to all three views.
381
* Requires \code #include "int/linear.hh" \endcode
382
* \ingroup FuncIntProp
384
template <class Val, class A, class B, class C>
385
class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
387
using LinTer<Val,A,B,C,PC_INT_VAL>::x0;
388
using LinTer<Val,A,B,C,PC_INT_VAL>::x1;
389
using LinTer<Val,A,B,C,PC_INT_VAL>::x2;
390
using LinTer<Val,A,B,C,PC_INT_VAL>::c;
392
/// Constructor for cloning \a p
393
NqTer(Space* home, bool share, NqTer& p);
394
/// Constructor for creation
395
NqTer(Space* home, A x0, B x1, C x2, Val c);
397
/// Create copy during cloning
398
virtual Actor* copy(Space* home, bool share);
399
/// Perform propagation
400
virtual ExecStatus propagate(Space* home);
401
/// Post propagator for \f$x_0+x_1+x_2 \neq c\f$
402
static ExecStatus post(Space* home, A x0, B x1, C x2, Val c);
406
* \brief %Propagator for bounds-consistent ternary linear less or equal
408
* The type \a Val can be either \c double or \c int, defining the
409
* numerical precision during propagation. The types \a A, \a B,
410
* and \a C give the types of the views.
412
* The propagation condition \a pc refers to all three views.
414
* Requires \code #include "int/linear.hh" \endcode
415
* \ingroup FuncIntProp
417
template <class Val, class A, class B, class C>
418
class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
420
using LinTer<Val,A,B,C,PC_INT_BND>::x0;
421
using LinTer<Val,A,B,C,PC_INT_BND>::x1;
422
using LinTer<Val,A,B,C,PC_INT_BND>::x2;
423
using LinTer<Val,A,B,C,PC_INT_BND>::c;
425
/// Constructor for cloning \a p
426
LqTer(Space* home, bool share, LqTer& p);
427
/// Constructor for creation
428
LqTer(Space* home, A x0, B x1, C x2, Val c);
430
/// Create copy during cloning
431
virtual Actor* copy(Space* home, bool share);
432
/// Perform propagation
433
virtual ExecStatus propagate(Space* home);
434
/// Post propagator for \f$x_0+x_1+x_2 \leq c\f$
435
static ExecStatus post(Space* home, A x0, B x1, C x2, Val c);
440
#include "int/linear/ternary.icc"
442
namespace Gecode { namespace Int { namespace Linear {
450
* \brief Base-class for n-ary linear propagators
452
* The type \a Val can be either \c double or \c int, defining the
453
* numerical precision during propagation. Positive views are of
454
* type \a P whereas negative views are of type \a N.
456
* The propagation condition \a pc refers to all views.
458
template <class Val, class P, class N, PropCond pc>
459
class Lin : public Propagator {
461
/// Array of positive views
463
/// Array of negative views
468
/// Constructor for cloning \a p
469
Lin(Space* home, bool share, Lin& p);
470
/// Constructor for creation
471
Lin(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
473
/// Cost function (defined as dynamic PC_LINEAR_LO)
474
virtual PropCost cost(void) const;
480
* \brief Base-class for reified n-ary linear propagators
482
* The type \a Val can be either \c double or \c int, defining the
483
* numerical precision during propagation. Positive views are of
484
* type \a P whereas negative views are of type \a N.
486
* The propagation condition \a pc refers to all views.
488
template <class Val, class P, class N, PropCond pc, class Ctrl>
489
class ReLin : public Lin<Val,P,N,pc> {
491
/// Control view for reification
493
/// Constructor for cloning \a p
494
ReLin(Space* home, bool share, ReLin& p);
495
/// Constructor for creation
496
ReLin(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
499
virtual ~ReLin(void);
503
* \brief Compute bounds information for positive views
507
template <class Val, class View>
508
void bounds_p(const Propagator*, ViewArray<View>& x,
509
Val& c, Val& sl, Val& su);
512
* \brief Compute bounds information for negative views
516
template <class Val, class View>
517
void bounds_n(const Propagator*, ViewArray<View>& y,
518
Val& c, Val& sl, Val& su);
521
* \brief %Propagator for bounds-consistent n-ary linear equality
523
* The type \a Val can be either \c double or \c int, defining the
524
* numerical precision during propagation. The types \a A, \a B,
525
* and \a C give the types of the views.
527
* The propagation condition \a pc refers to all three views.
529
* Requires \code #include "int/linear.hh" \endcode
530
* \ingroup FuncIntProp
532
template <class Val, class P, class N>
533
class Eq : public Lin<Val,P,N,PC_INT_BND> {
535
using Lin<Val,P,N,PC_INT_BND>::x;
536
using Lin<Val,P,N,PC_INT_BND>::y;
537
using Lin<Val,P,N,PC_INT_BND>::c;
539
/// Constructor for cloning \a p
540
Eq(Space* home, bool share, Eq& p);
542
/// Constructor for creation
543
Eq(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
544
/// Create copy during cloning
545
virtual Actor* copy(Space* home, bool share);
546
/// Perform propagation
547
virtual ExecStatus propagate(Space* home);
548
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\f$
550
post(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
554
* \brief %Propagator for reified bounds-consistent n-ary linear equality
556
* The type \a Val can be either \c double or \c int, defining the
557
* numerical precision during propagation. The types \a A, \a B,
558
* and \a C give the types of the views.
560
* The propagation condition \a pc refers to all three views.
562
* Requires \code #include "int/linear.hh" \endcode
563
* \ingroup FuncIntProp
565
template <class Val, class P, class N, class Ctrl>
566
class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
568
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::x;
569
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::y;
570
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::c;
571
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::b;
573
/// Constructor for cloning \a p
574
ReEq(Space* home, bool share, ReEq& p);
576
/// Constructor for creation
577
ReEq(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
578
/// Create copy during cloning
579
virtual Actor* copy(Space* home, bool share);
580
/// Perform propagation
581
virtual ExecStatus propagate(Space* home);
582
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\right)\Leftrightarrow b\f$
584
post(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
588
* \brief %Propagator for bounds-consistent n-ary linear disequality
590
* The type \a Val can be either \c double or \c int, defining the
591
* numerical precision during propagation. The types \a A, \a B,
592
* and \a C give the types of the views.
594
* The propagation condition \a pc refers to all three views.
596
* Requires \code #include "int/linear.hh" \endcode
597
* \ingroup FuncIntProp
599
template <class Val, class P, class N>
600
class Nq : public Lin<Val,P,N,PC_INT_VAL> {
602
using Lin<Val,P,N,PC_INT_VAL>::x;
603
using Lin<Val,P,N,PC_INT_VAL>::y;
604
using Lin<Val,P,N,PC_INT_VAL>::c;
606
/// Constructor for cloning \a p
607
Nq(Space* home, bool share, Nq& p);
609
/// Constructor for creation
610
Nq(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
611
/// Create copy during cloning
612
virtual Actor* copy(Space* home, bool share);
613
/// Perform propagation
614
virtual ExecStatus propagate(Space* home);
615
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\neq c\f$
617
post(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
621
* \brief %Propagator for bounds-consistent n-ary linear less or equal
623
* The type \a Val can be either \c double or \c int, defining the
624
* numerical precision during propagation. The types \a A, \a B,
625
* and \a C give the types of the views.
627
* The propagation condition \a pc refers to all three views.
629
* Requires \code #include "int/linear.hh" \endcode
630
* \ingroup FuncIntProp
632
template <class Val, class P, class N>
633
class Lq : public Lin<Val,P,N,PC_INT_BND> {
635
using Lin<Val,P,N,PC_INT_BND>::x;
636
using Lin<Val,P,N,PC_INT_BND>::y;
637
using Lin<Val,P,N,PC_INT_BND>::c;
639
/// Constructor for cloning \a p
640
Lq(Space* home, bool share, Lq& p);
642
/// Constructor for creation
643
Lq(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
644
/// Create copy during cloning
645
virtual Actor* copy(Space* home, bool share);
646
/// Perform propagation
647
virtual ExecStatus propagate(Space* home);
648
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\leq c\f$
650
post(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c);
654
* \brief %Propagator for reified bounds-consistent n-ary linear less or equal
656
* The type \a Val can be either \c double or \c int, defining the
657
* numerical precision during propagation. The types \a A, \a B,
658
* and \a C give the types of the views.
660
* The propagation condition \a pc refers to all three views.
662
* Requires \code #include "int/linear.hh" \endcode
663
* \ingroup FuncIntProp
665
template <class Val, class P, class N>
666
class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
668
using ReLin<Val,P,N,PC_INT_BND,BoolView>::x;
669
using ReLin<Val,P,N,PC_INT_BND,BoolView>::y;
670
using ReLin<Val,P,N,PC_INT_BND,BoolView>::c;
671
using ReLin<Val,P,N,PC_INT_BND,BoolView>::b;
673
/// Constructor for cloning \a p
674
ReLq(Space* home, bool share, ReLq& p);
676
/// Constructor for creation
677
ReLq(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
678
/// Create copy during cloning
679
virtual Actor* copy(Space* home, bool share);
680
/// Perform propagation
681
virtual ExecStatus propagate(Space* home);
682
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\leq c\right)\Leftrightarrow b\f$
684
post(Space* home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
689
#include "int/linear/nary.icc"
691
namespace Gecode { namespace Int { namespace Linear {
694
* Boolean linear propagators
699
* \brief Base-class for Boolean linear propagators
702
template <class View>
703
class LinBool : public Propagator {
706
ViewArray<BoolView> x;
707
/// Number of Boolean views assigned to 1
709
/// View to compare number of assigned Boolean views to
712
/// Eliminate assigned Boolean views
713
void eliminate(void);
714
/// Post that all remaining Boolean views must be one
715
void all_one(Space* home);
716
/// Post that all remaining Boolean views must be zero
717
void all_zero(Space* home);
719
/// Constructor for cloning \a p
720
LinBool(Space* home, bool share, LinBool& p);
721
/// Constructor for creation
722
LinBool(Space* home, ViewArray<BoolView>& x, int n, View y);
724
/// Cost function (defined as dynamic PC_LINEAR_LO)
725
virtual PropCost cost(void) const;
727
virtual ~LinBool(void);
732
* \brief %Propagator for equality to Boolean sum (cardinality)
734
* Requires \code #include "int/linear.hh" \endcode
735
* \ingroup FuncIntProp
737
template <class View>
738
class EqBool : public LinBool<View> {
740
using LinBool<View>::x;
741
using LinBool<View>::n;
742
using LinBool<View>::y;
744
/// Constructor for cloning \a p
745
EqBool(Space* home, bool share, EqBool& p);
746
/// Constructor for creation
747
EqBool(Space* home, ViewArray<BoolView>& x, int n, View y);
749
/// Create copy during cloning
750
virtual Actor* copy(Space* home, bool share);
751
/// Perform propagation
752
virtual ExecStatus propagate(Space* home);
753
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i+n = y\f$
754
static ExecStatus post(Space* home, ViewArray<BoolView>& x, int n, View y);
758
* \brief %Propagator for disequality to Boolean sum (cardinality)
760
* Requires \code #include "int/linear.hh" \endcode
761
* \ingroup FuncIntProp
763
template <class View>
764
class NqBool : public LinBool<View> {
766
using LinBool<View>::x;
767
using LinBool<View>::n;
768
using LinBool<View>::y;
770
/// Constructor for cloning \a p
771
NqBool(Space* home, bool share, NqBool& p);
772
/// Constructor for creation
773
NqBool(Space* home, ViewArray<BoolView>& x, int n, View y);
775
/// Create copy during cloning
776
virtual Actor* copy(Space* home, bool share);
777
/// Perform propagation
778
virtual ExecStatus propagate(Space* home);
779
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i+n \neq y\f$
780
static ExecStatus post(Space* home, ViewArray<BoolView>& x, int n, View y);
784
* \brief %Propagator for less or equal to Boolean sum (cardinality)
786
* Requires \code #include "int/linear.hh" \endcode
787
* \ingroup FuncIntProp
789
template <class View>
790
class LqBool : public LinBool<View> {
792
using LinBool<View>::x;
793
using LinBool<View>::n;
794
using LinBool<View>::y;
796
/// Constructor for cloning \a p
797
LqBool(Space* home, bool share, LqBool& p);
798
/// Constructor for creation
799
LqBool(Space* home, ViewArray<BoolView>& x, int n, View y);
801
/// Create copy during cloning
802
virtual Actor* copy(Space* home, bool share);
803
/// Perform propagation
804
virtual ExecStatus propagate(Space* home);
805
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i+n \leq y\f$
806
static ExecStatus post(Space* home, ViewArray<BoolView>& x, int n, View y);
810
* \brief %Propagator for greater or equal to Boolean sum (cardinality)
812
* Requires \code #include "int/linear.hh" \endcode
813
* \ingroup FuncIntProp
815
template <class View>
816
class GqBool : public LinBool<View> {
818
using LinBool<View>::x;
819
using LinBool<View>::n;
820
using LinBool<View>::y;
822
/// Constructor for cloning \a p
823
GqBool(Space* home, bool share, GqBool& p);
824
/// Constructor for creation
825
GqBool(Space* home, ViewArray<BoolView>& x, int n, View y);
827
/// Create copy during cloning
828
virtual Actor* copy(Space* home, bool share);
829
/// Perform propagation
830
virtual ExecStatus propagate(Space* home);
831
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i+n \geq y\f$
832
static ExecStatus post(Space* home, ViewArray<BoolView>& x, int n, View y);
837
#include "int/linear/bool.icc"
839
namespace Gecode { namespace Int { namespace Linear {
843
* Support for preprocessing and posting
848
* \brief Class for describing linear term \f$a\cdot x\f$
860
* \brief Post propagator for linear constraint
861
* \param e array of linear terms
862
* \param n size of array
863
* \param r type of relation
864
* \param c result of linear constraint
866
* All variants for linear constraints share the following properties:
867
* - Only bounds-consistency is supported.
868
* - Variables occuring multiply in the term array are replaced
869
* by a single occurence: for example, \f$ax+bx\f$ becomes
871
* - If in the above simplification the value for \f$(a+b)\f$ (or for
872
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
873
* defined in Limits::Int, an exception of type
874
* Int::NumericalOverflow is thrown.
875
* - Assume linear terms for the constraint
876
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_r c\f$.
877
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
878
* for doubles as defined in Limits::Int, an exception of
879
* type Int::NumericalOverflow is thrown.
880
* - In all other cases, the created propagators are accurate (that
881
* is, they will not silently overflow during propagation).
883
* Requires \code #include "int/linear.hh" \endcode
884
* \ingroup FuncIntProp
886
GECODE_INT_EXPORT void
887
post(Space* home, Term t[], int n, IntRelType r, int c);
890
* \brief Post reified propagator for linear constraint
891
* \param e array of linear terms
892
* \param n size of array
893
* \param r type of relation
894
* \param c result of linear constraint
895
* \param b Boolean control view
897
* All variants for linear constraints share the following properties:
898
* - Only bounds-consistency is supported.
899
* - Variables occuring multiply in the term array are replaced
900
* by a single occurence: for example, \f$ax+bx\f$ becomes
902
* - If in the above simplification the value for \f$(a+b)\f$ (or for
903
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
904
* defined in Limits::Int, an exception of type
905
* Int::NumericalOverflow is thrown.
906
* - Assume linear terms for the constraint
907
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_r c\f$.
908
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
909
* for doubles as defined in Limits::Int, an exception of
910
* type Int::NumericalOverflow is thrown.
911
* - In all other cases, the created propagators are accurate (that
912
* is, they will not silently overflow during propagation).
914
* Requires \code #include "int/linear.hh" \endcode
915
* \ingroup FuncIntProp
917
GECODE_INT_EXPORT void
918
post(Space* home, Term t[], int n, IntRelType r, int c, BoolView b);
924
// STATISTICS: int-prop