Generated on Thu Mar 7 2013 10:21:18 for Gecode by doxygen 1.8.3.1
arithmetic.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  *
7  * Copyright:
8  * Christian Schulte, 2002
9  * Guido Tack, 2004
10  *
11  * Last modified:
12  * $Date: 2009-11-03 03:10:59 +1100 (Tue, 03 Nov 2009) $ by $Author: tack $
13  * $Revision: 10021 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #ifndef __GECODE_INT_ARITHMETIC_HH__
41 #define __GECODE_INT_ARITHMETIC_HH__
42 
43 #include <gecode/int.hh>
44 
45 #include <gecode/int/rel.hh>
46 #include <gecode/int/linear.hh>
47 
53 namespace Gecode { namespace Int { namespace Arithmetic {
54 
61  template<class View>
62  class AbsBnd : public BinaryPropagator<View,PC_INT_BND> {
63  protected:
66 
68  AbsBnd(Space& home, bool share, AbsBnd& p);
70  AbsBnd(Home home, View x0, View x1);
71  public:
72 
74  virtual Actor* copy(Space& home, bool share);
81  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
83  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
85  static ExecStatus post(Home home, View x0, View x1);
86  };
87 
94  template<class View>
95  class AbsDom : public BinaryPropagator<View,PC_INT_DOM> {
96  protected:
99 
101  AbsDom(Space& home, bool share, AbsDom& p);
103  AbsDom(Home home, View x0, View x1);
104  public:
106  virtual Actor* copy(Space& home, bool share);
114  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
116  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
118  static ExecStatus post(Home home, View x0, View x1);
119  };
120 
121 
122 
129  template<class View>
130  class MaxBnd : public TernaryPropagator<View,PC_INT_BND> {
131  protected:
135 
137  MaxBnd(Space& home, bool share, MaxBnd& p);
139  MaxBnd(Home home, View x0, View x1, View x2);
140  public:
142  MaxBnd(Space& home, bool share, Propagator& p, View x0, View x1, View x2);
144  virtual Actor* copy(Space& home, bool share);
146  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
148  static ExecStatus post(Home home, View x0, View x1, View x2);
149  };
150 
157  template<class View>
158  class NaryMaxBnd : public NaryOnePropagator<View,PC_INT_BND> {
159  protected:
162 
164  NaryMaxBnd(Space& home, bool share, NaryMaxBnd& p);
166  NaryMaxBnd(Home home, ViewArray<View>& x, View y);
167  public:
169  virtual Actor* copy(Space& home, bool share);
171  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
173  static ExecStatus post(Home home, ViewArray<View>& x, View y);
174  };
175 
182  template<class View>
183  class MaxDom : public TernaryPropagator<View,PC_INT_DOM> {
184  protected:
188 
190  MaxDom(Space& home, bool share, MaxDom& p);
192  MaxDom(Home home, View x0, View x1, View x2);
193  public:
195  MaxDom(Space& home, bool share, Propagator& p, View x0, View x1, View x2);
197  virtual Actor* copy(Space& home, bool share);
204  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
206  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
208  static ExecStatus post(Home home, View x0, View x1, View x2);
209  };
210 
217  template<class View>
218  class NaryMaxDom : public NaryOnePropagator<View,PC_INT_DOM> {
219  protected:
222 
224  NaryMaxDom(Space& home, bool share, NaryMaxDom& p);
226  NaryMaxDom(Home home, ViewArray<View>& x, View y);
227  public:
229  virtual Actor* copy(Space& home, bool share);
236  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
238  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
240  static ExecStatus post(Home home, ViewArray<View>& x, View y);
241  };
242 
243 
244 
245 
251  template<class VA, class VB>
252  class SqrPlusBnd : public MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND> {
253  protected:
257  SqrPlusBnd(Home home, VA x0, VB x1);
259  SqrPlusBnd(Space& home, bool share, SqrPlusBnd<VA,VB>& p);
260  public:
262  static ExecStatus post(Home home, VA x0, VB x1);
264  virtual Actor* copy(Space& home, bool share);
266  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
267  };
268 
275  template<class View>
276  class SqrBnd : public BinaryPropagator<View,PC_INT_BND> {
277  protected:
280 
282  SqrBnd(Space& home, bool share, SqrBnd<View>& p);
284  SqrBnd(Home home, View x0, View x1);
285  public:
287  virtual Actor* copy(Space& home, bool share);
289  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
291  static ExecStatus post(Home home, View x0, View x1);
292  };
293 
294 
295 
301  template<class VA, class VB>
302  class SqrPlusDom : public MixBinaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM> {
303  protected:
307  SqrPlusDom(Home home, VA x0, VB x1);
309  SqrPlusDom(Space& home, bool share, SqrPlusDom<VA,VB>& p);
310  public:
312  static ExecStatus post(Home home, VA x0, VB x1);
314  virtual Actor* copy(Space& home, bool share);
322  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
324  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
325  };
326 
333  template<class View>
334  class SqrDom : public BinaryPropagator<View,PC_INT_DOM> {
335  protected:
338 
340  SqrDom(Space& home, bool share, SqrDom<View>& p);
342  SqrDom(Home home, View x0, View x1);
343  public:
345  virtual Actor* copy(Space& home, bool share);
347  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
355  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
357  static ExecStatus post(Home home, View x0, View x1);
358  };
359 
360 
361 
368  template<class View>
369  class SqrtBnd : public BinaryPropagator<View,PC_INT_BND> {
370  protected:
373 
375  SqrtBnd(Space& home, bool share, SqrtBnd<View>& p);
377  SqrtBnd(Home home, View x0, View x1);
378  public:
380  virtual Actor* copy(Space& home, bool share);
382  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
384  static ExecStatus post(Home home, View x0, View x1);
385  };
386 
393  template<class View>
394  class SqrtDom : public BinaryPropagator<View,PC_INT_DOM> {
395  protected:
398 
400  SqrtDom(Space& home, bool share, SqrtDom<View>& p);
402  SqrtDom(Home home, View x0, View x1);
403  public:
405  virtual Actor* copy(Space& home, bool share);
407  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
415  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
417  static ExecStatus post(Home home, View x0, View x1);
418  };
419 
420 
421 
428  template<class View, PropCond pc>
429  class MultZeroOne : public BinaryPropagator<View,pc> {
430  protected:
433 
435  MultZeroOne(Space& home, bool share, MultZeroOne<View,pc>& p);
437  MultZeroOne(Home home, View x0, View x1);
439  static RelTest equal(View x, int n);
440  public:
442  virtual Actor* copy(Space& home, bool share);
444  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
446  static ExecStatus post(Home home, View x0, View x1);
447  };
448 
449 
450 
456  template<class Val, class VA, class VB, class VC>
457  class MultPlusBnd :
458  public MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND> {
459  protected:
463  public:
465  MultPlusBnd(Home home, VA x0, VB x1, VC x2);
467  MultPlusBnd(Space& home, bool share, MultPlusBnd<Val,VA,VB,VC>& p);
469  static ExecStatus post(Home home, VA x0, VB x1, VC x2);
471  virtual Actor* copy(Space& home, bool share);
473  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
474  };
475 
483  template<class View>
484  class MultBnd : public TernaryPropagator<View,PC_INT_BND> {
485  protected:
489 
491  MultBnd(Space& home, bool share, MultBnd<View>& p);
492  public:
494  MultBnd(Home home, View x0, View x1, View x2);
496  static ExecStatus post(Home home, View x0, View x1, View x2);
498  virtual Actor* copy(Space& home, bool share);
500  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
501  };
502 
503 
504 
510  template<class Val, class VA, class VB, class VC>
511  class MultPlusDom :
512  public MixTernaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM,VC,PC_INT_DOM> {
513  protected:
517  public:
519  MultPlusDom(Home home, VA x0, VB x1, VC x2);
521  MultPlusDom(Space& home, bool share, MultPlusDom<Val,VA,VB,VC>& p);
523  static ExecStatus post(Home home, VA x0, VB x1, VC x2);
525  virtual Actor* copy(Space& home, bool share);
532  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
534  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
535  };
536 
544  template<class View>
545  class MultDom : public TernaryPropagator<View,PC_INT_DOM> {
546  protected:
550 
552  MultDom(Space& home, bool share, MultDom<View>& p);
553  public:
555  MultDom(Home home, View x0, View x1, View x2);
557  static ExecStatus post(Home home, View x0, View x1, View x2);
559  virtual Actor* copy(Space& home, bool share);
566  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
568  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
569  };
570 
576  template<class Val, class VA, class VB, class VC>
577  class DivPlusBnd :
578  public MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND> {
579  protected:
583  public:
585  DivPlusBnd(Home home, VA x0, VB x1, VC x2);
587  DivPlusBnd(Space& home, bool share,
590  static ExecStatus post(Home home, VA x0, VB x1, VC x2);
592  virtual Actor* copy(Space& home, bool share);
594  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
595  };
596 
604  template<class View>
605  class DivBnd : public TernaryPropagator<View,PC_INT_BND> {
606  protected:
610 
612  DivBnd(Space& home, bool share, DivBnd<View>& p);
613  public:
615  DivBnd(Home home, View x0, View x1, View x2);
617  static ExecStatus post(Home home, View x0, View x1, View x2);
619  virtual Actor* copy(Space& home, bool share);
621  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
622  };
623 
634  template<class View>
635  class DivMod : public TernaryPropagator<View,PC_INT_BND> {
636  protected:
640 
642  DivMod(Space& home, bool share, DivMod<View>& p);
643  public:
645  DivMod(Home home, View x0, View x1, View x2);
647  static ExecStatus post(Home home, View x0, View x1, View x2);
649  virtual Actor* copy(Space& home, bool share);
651  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
652  };
653 
654 }}}
655 
662 
663 #endif
664 
665 // STATISTICS: int-prop
666