00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __GECODE_INT_ARITHMETIC_HH__
00041 #define __GECODE_INT_ARITHMETIC_HH__
00042
00043 #include <gecode/int.hh>
00044
00045 #include <gecode/int/rel.hh>
00046 #include <gecode/int/linear.hh>
00047
00053 namespace Gecode { namespace Int { namespace Arithmetic {
00054
00061 template<class View>
00062 class AbsBnd : public BinaryPropagator<View,PC_INT_BND> {
00063 protected:
00064 using BinaryPropagator<View,PC_INT_BND>::x0;
00065 using BinaryPropagator<View,PC_INT_BND>::x1;
00066
00068 AbsBnd(Space& home, bool share, AbsBnd& p);
00070 AbsBnd(Home home, View x0, View x1);
00071 public:
00072
00074 virtual Actor* copy(Space& home, bool share);
00081 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00083 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00085 static ExecStatus post(Home home, View x0, View x1);
00086 };
00087
00094 template<class View>
00095 class AbsDom : public BinaryPropagator<View,PC_INT_DOM> {
00096 protected:
00097 using BinaryPropagator<View,PC_INT_DOM>::x0;
00098 using BinaryPropagator<View,PC_INT_DOM>::x1;
00099
00101 AbsDom(Space& home, bool share, AbsDom& p);
00103 AbsDom(Home home, View x0, View x1);
00104 public:
00106 virtual Actor* copy(Space& home, bool share);
00114 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00116 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00118 static ExecStatus post(Home home, View x0, View x1);
00119 };
00120
00121
00122
00129 template<class View>
00130 class MaxBnd : public TernaryPropagator<View,PC_INT_BND> {
00131 protected:
00132 using TernaryPropagator<View,PC_INT_BND>::x0;
00133 using TernaryPropagator<View,PC_INT_BND>::x1;
00134 using TernaryPropagator<View,PC_INT_BND>::x2;
00135
00137 MaxBnd(Space& home, bool share, MaxBnd& p);
00139 MaxBnd(Home home, View x0, View x1, View x2);
00140 public:
00142 MaxBnd(Space& home, bool share, Propagator& p, View x0, View x1, View x2);
00144 virtual Actor* copy(Space& home, bool share);
00146 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00148 static ExecStatus post(Home home, View x0, View x1, View x2);
00149 };
00150
00157 template<class View>
00158 class NaryMaxBnd : public NaryOnePropagator<View,PC_INT_BND> {
00159 protected:
00160 using NaryOnePropagator<View,PC_INT_BND>::x;
00161 using NaryOnePropagator<View,PC_INT_BND>::y;
00162
00164 NaryMaxBnd(Space& home, bool share, NaryMaxBnd& p);
00166 NaryMaxBnd(Home home, ViewArray<View>& x, View y);
00167 public:
00169 virtual Actor* copy(Space& home, bool share);
00171 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00173 static ExecStatus post(Home home, ViewArray<View>& x, View y);
00174 };
00175
00182 template<class View>
00183 class MaxDom : public TernaryPropagator<View,PC_INT_DOM> {
00184 protected:
00185 using TernaryPropagator<View,PC_INT_DOM>::x0;
00186 using TernaryPropagator<View,PC_INT_DOM>::x1;
00187 using TernaryPropagator<View,PC_INT_DOM>::x2;
00188
00190 MaxDom(Space& home, bool share, MaxDom& p);
00192 MaxDom(Home home, View x0, View x1, View x2);
00193 public:
00195 MaxDom(Space& home, bool share, Propagator& p, View x0, View x1, View x2);
00197 virtual Actor* copy(Space& home, bool share);
00204 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00206 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00208 static ExecStatus post(Home home, View x0, View x1, View x2);
00209 };
00210
00217 template<class View>
00218 class NaryMaxDom : public NaryOnePropagator<View,PC_INT_DOM> {
00219 protected:
00220 using NaryOnePropagator<View,PC_INT_DOM>::x;
00221 using NaryOnePropagator<View,PC_INT_DOM>::y;
00222
00224 NaryMaxDom(Space& home, bool share, NaryMaxDom& p);
00226 NaryMaxDom(Home home, ViewArray<View>& x, View y);
00227 public:
00229 virtual Actor* copy(Space& home, bool share);
00236 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00238 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00240 static ExecStatus post(Home home, ViewArray<View>& x, View y);
00241 };
00242
00243
00244
00245
00251 template<class VA, class VB>
00252 class SqrPlusBnd : public MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND> {
00253 protected:
00254 using MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND>::x0;
00255 using MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND>::x1;
00257 SqrPlusBnd(Home home, VA x0, VB x1);
00259 SqrPlusBnd(Space& home, bool share, SqrPlusBnd<VA,VB>& p);
00260 public:
00262 static ExecStatus post(Home home, VA x0, VB x1);
00264 virtual Actor* copy(Space& home, bool share);
00266 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00267 };
00268
00275 template<class View>
00276 class SqrBnd : public BinaryPropagator<View,PC_INT_BND> {
00277 protected:
00278 using BinaryPropagator<View,PC_INT_BND>::x0;
00279 using BinaryPropagator<View,PC_INT_BND>::x1;
00280
00282 SqrBnd(Space& home, bool share, SqrBnd<View>& p);
00284 SqrBnd(Home home, View x0, View x1);
00285 public:
00287 virtual Actor* copy(Space& home, bool share);
00289 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00291 static ExecStatus post(Home home, View x0, View x1);
00292 };
00293
00294
00295
00301 template<class VA, class VB>
00302 class SqrPlusDom : public MixBinaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM> {
00303 protected:
00304 using MixBinaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM>::x0;
00305 using MixBinaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM>::x1;
00307 SqrPlusDom(Home home, VA x0, VB x1);
00309 SqrPlusDom(Space& home, bool share, SqrPlusDom<VA,VB>& p);
00310 public:
00312 static ExecStatus post(Home home, VA x0, VB x1);
00314 virtual Actor* copy(Space& home, bool share);
00322 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00324 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00325 };
00326
00333 template<class View>
00334 class SqrDom : public BinaryPropagator<View,PC_INT_DOM> {
00335 protected:
00336 using BinaryPropagator<View,PC_INT_DOM>::x0;
00337 using BinaryPropagator<View,PC_INT_DOM>::x1;
00338
00340 SqrDom(Space& home, bool share, SqrDom<View>& p);
00342 SqrDom(Home home, View x0, View x1);
00343 public:
00345 virtual Actor* copy(Space& home, bool share);
00347 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00355 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00357 static ExecStatus post(Home home, View x0, View x1);
00358 };
00359
00360
00361
00368 template<class View>
00369 class SqrtBnd : public BinaryPropagator<View,PC_INT_BND> {
00370 protected:
00371 using BinaryPropagator<View,PC_INT_BND>::x0;
00372 using BinaryPropagator<View,PC_INT_BND>::x1;
00373
00375 SqrtBnd(Space& home, bool share, SqrtBnd<View>& p);
00377 SqrtBnd(Home home, View x0, View x1);
00378 public:
00380 virtual Actor* copy(Space& home, bool share);
00382 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00384 static ExecStatus post(Home home, View x0, View x1);
00385 };
00386
00393 template<class View>
00394 class SqrtDom : public BinaryPropagator<View,PC_INT_DOM> {
00395 protected:
00396 using BinaryPropagator<View,PC_INT_DOM>::x0;
00397 using BinaryPropagator<View,PC_INT_DOM>::x1;
00398
00400 SqrtDom(Space& home, bool share, SqrtDom<View>& p);
00402 SqrtDom(Home home, View x0, View x1);
00403 public:
00405 virtual Actor* copy(Space& home, bool share);
00407 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00415 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00417 static ExecStatus post(Home home, View x0, View x1);
00418 };
00419
00420
00421
00428 template<class View, PropCond pc>
00429 class MultZeroOne : public BinaryPropagator<View,pc> {
00430 protected:
00431 using BinaryPropagator<View,pc>::x0;
00432 using BinaryPropagator<View,pc>::x1;
00433
00435 MultZeroOne(Space& home, bool share, MultZeroOne<View,pc>& p);
00437 MultZeroOne(Home home, View x0, View x1);
00439 static RelTest equal(View x, int n);
00440 public:
00442 virtual Actor* copy(Space& home, bool share);
00444 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00446 static ExecStatus post(Home home, View x0, View x1);
00447 };
00448
00449
00450
00456 template<class Val, class VA, class VB, class VC>
00457 class MultPlusBnd :
00458 public MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND> {
00459 protected:
00460 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x0;
00461 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x1;
00462 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x2;
00463 public:
00465 MultPlusBnd(Home home, VA x0, VB x1, VC x2);
00467 MultPlusBnd(Space& home, bool share, MultPlusBnd<Val,VA,VB,VC>& p);
00469 static ExecStatus post(Home home, VA x0, VB x1, VC x2);
00471 virtual Actor* copy(Space& home, bool share);
00473 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00474 };
00475
00483 template<class View>
00484 class MultBnd : public TernaryPropagator<View,PC_INT_BND> {
00485 protected:
00486 using TernaryPropagator<View,PC_INT_BND>::x0;
00487 using TernaryPropagator<View,PC_INT_BND>::x1;
00488 using TernaryPropagator<View,PC_INT_BND>::x2;
00489
00491 MultBnd(Space& home, bool share, MultBnd<View>& p);
00492 public:
00494 MultBnd(Home home, View x0, View x1, View x2);
00496 static ExecStatus post(Home home, View x0, View x1, View x2);
00498 virtual Actor* copy(Space& home, bool share);
00500 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00501 };
00502
00503
00504
00510 template<class Val, class VA, class VB, class VC>
00511 class MultPlusDom :
00512 public MixTernaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM,VC,PC_INT_DOM> {
00513 protected:
00514 using MixTernaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM,VC,PC_INT_DOM>::x0;
00515 using MixTernaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM,VC,PC_INT_DOM>::x1;
00516 using MixTernaryPropagator<VA,PC_INT_DOM,VB,PC_INT_DOM,VC,PC_INT_DOM>::x2;
00517 public:
00519 MultPlusDom(Home home, VA x0, VB x1, VC x2);
00521 MultPlusDom(Space& home, bool share, MultPlusDom<Val,VA,VB,VC>& p);
00523 static ExecStatus post(Home home, VA x0, VB x1, VC x2);
00525 virtual Actor* copy(Space& home, bool share);
00532 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00534 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00535 };
00536
00544 template<class View>
00545 class MultDom : public TernaryPropagator<View,PC_INT_DOM> {
00546 protected:
00547 using TernaryPropagator<View,PC_INT_DOM>::x0;
00548 using TernaryPropagator<View,PC_INT_DOM>::x1;
00549 using TernaryPropagator<View,PC_INT_DOM>::x2;
00550
00552 MultDom(Space& home, bool share, MultDom<View>& p);
00553 public:
00555 MultDom(Home home, View x0, View x1, View x2);
00557 static ExecStatus post(Home home, View x0, View x1, View x2);
00559 virtual Actor* copy(Space& home, bool share);
00566 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00568 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00569 };
00570
00576 template<class Val, class VA, class VB, class VC>
00577 class DivPlusBnd :
00578 public MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND> {
00579 protected:
00580 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x0;
00581 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x1;
00582 using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x2;
00583 public:
00585 DivPlusBnd(Home home, VA x0, VB x1, VC x2);
00587 DivPlusBnd(Space& home, bool share,
00588 DivPlusBnd<Val,VA,VB,VC>& p);
00590 static ExecStatus post(Home home, VA x0, VB x1, VC x2);
00592 virtual Actor* copy(Space& home, bool share);
00594 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00595 };
00596
00604 template<class View>
00605 class DivBnd : public TernaryPropagator<View,PC_INT_BND> {
00606 protected:
00607 using TernaryPropagator<View,PC_INT_BND>::x0;
00608 using TernaryPropagator<View,PC_INT_BND>::x1;
00609 using TernaryPropagator<View,PC_INT_BND>::x2;
00610
00612 DivBnd(Space& home, bool share, DivBnd<View>& p);
00613 public:
00615 DivBnd(Home home, View x0, View x1, View x2);
00617 static ExecStatus post(Home home, View x0, View x1, View x2);
00619 virtual Actor* copy(Space& home, bool share);
00621 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00622 };
00623
00634 template<class View>
00635 class DivMod : public TernaryPropagator<View,PC_INT_BND> {
00636 protected:
00637 using TernaryPropagator<View,PC_INT_BND>::x0;
00638 using TernaryPropagator<View,PC_INT_BND>::x1;
00639 using TernaryPropagator<View,PC_INT_BND>::x2;
00640
00642 DivMod(Space& home, bool share, DivMod<View>& p);
00643 public:
00645 DivMod(Home home, View x0, View x1, View x2);
00647 static ExecStatus post(Home home, View x0, View x1, View x2);
00649 virtual Actor* copy(Space& home, bool share);
00651 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00652 };
00653
00654 }}}
00655
00656 #include <gecode/int/arithmetic/abs.hpp>
00657 #include <gecode/int/arithmetic/max.hpp>
00658 #include <gecode/int/arithmetic/sqr.hpp>
00659 #include <gecode/int/arithmetic/sqrt.hpp>
00660 #include <gecode/int/arithmetic/mult.hpp>
00661 #include <gecode/int/arithmetic/divmod.hpp>
00662
00663 #endif
00664
00665
00666