00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gecode/int/arithmetic.hh"
00023
00024 namespace Gecode {
00025
00026 using namespace Int;
00027
00028 void
00029 abs(Space* home, IntVar x0, IntVar x1, IntConLevel cl) {
00030 if (home->failed()) return;
00031 switch (cl) {
00032 case ICL_DOM:
00033 GECODE_ES_FAIL(home,Arithmetic::AbsDom<IntView>::post(home,x0,x1));
00034 break;
00035 default:
00036 GECODE_ES_FAIL(home,Arithmetic::AbsBnd<IntView>::post(home,x0,x1));
00037 break;
00038 }
00039 }
00040
00041
00042 void
00043 max(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00044 if (home->failed()) return;
00045 GECODE_ES_FAIL(home,Arithmetic::Max<IntView>::post(home,x0,x1,x2));
00046 }
00047
00048 void
00049 max(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00050 if (x.size() == 0)
00051 throw ArgumentEmpty("Int::max");
00052 if (home->failed()) return;
00053 ViewArray<IntView> xv(home,x);
00054 GECODE_ES_FAIL(home,Arithmetic::NaryMax<IntView>::post(home,xv,y));
00055 }
00056
00057
00058 void
00059 min(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00060 if (home->failed()) return;
00061 MinusView m0(x0); MinusView m1(x1); MinusView m2(x2);
00062 GECODE_ES_FAIL(home,Arithmetic::Max<MinusView>::post(home,m0,m1,m2));
00063 }
00064
00065 void
00066 min(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00067 if (x.size() == 0)
00068 throw ArgumentEmpty("Int::min");
00069 if (home->failed()) return;
00070 ViewArray<MinusView> m(home,x.size());
00071 for (int i=x.size(); i--; )
00072 m[i].init(x[i]);
00073 MinusView my(y);
00074 GECODE_ES_FAIL(home,Arithmetic::NaryMax<MinusView>::post(home,m,my));
00075 }
00076
00077
00078 void
00079 mult(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00080 if (home->failed()) return;
00081 GECODE_ES_FAIL(home,Arithmetic::Mult<IntView>::post(home,x0,x1,x2));
00082 }
00083
00084 }
00085
00086
00087