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 #include <gecode/int/cumulatives.hh>
00035
00036 namespace Gecode {
00037
00038 using namespace Int;
00039
00040 namespace {
00041 ViewArray<IntView>
00042 make_view_array(Space& home, const IntVarArgs& in) {
00043 return ViewArray<Int::IntView>(home, in);
00044 }
00045
00046 ViewArray<ConstIntView>
00047 make_view_array(Space& home, const IntArgs& in) {
00048 ViewArray<Int::ConstIntView> res(home, in.size());
00049 for (int i=0; i<in.size(); i++) {
00050 Int::Limits::check(in[i],"Int::cumulatives");
00051 res[i] = Int::ConstIntView(in[i]);
00052 }
00053
00054 return res;
00055 }
00056
00057 template<class In> class ViewType;
00058
00059 template<>
00060 class ViewType<IntArgs> {
00061 public:
00062 typedef Int::ConstIntView Result;
00063 };
00064
00065 template<>
00066 class ViewType<IntVarArgs> {
00067 public:
00068 typedef Int::IntView Result;
00069 };
00070
00071 template<class Machine, class Processing, class Usage>
00072 void
00073 post_cumulatives(Home home, const Machine& m,
00074 const IntVarArgs& s, const Processing& p,
00075 const IntVarArgs& e, const Usage& u,
00076 const IntArgs& c, bool at_most,
00077 IntPropLevel) {
00078 if (m.size() != s.size() ||
00079 s.size() != p.size() ||
00080 p.size() != e.size() ||
00081 e.size() != u.size())
00082 throw Int::ArgumentSizeMismatch("Int::cumulatives");
00083 GECODE_POST;
00084
00085 ViewArray<typename ViewType<Machine>::Result>
00086 vm = make_view_array(home, m);
00087 ViewArray<typename ViewType<Processing>::Result>
00088 vp = make_view_array(home, p);
00089 ViewArray<typename ViewType<Usage>::Result>
00090 vu = make_view_array(home, u);
00091 ViewArray<IntView>
00092 vs = make_view_array(home, s),
00093 ve = make_view_array(home, e);
00094
00095 SharedArray<int> c_s(c.size());
00096 for (int i=0; i<c.size(); i++)
00097 c_s[i] = c[i];
00098
00099
00100 GECODE_ES_FAIL((Int::Cumulatives::Val<
00101 typename ViewType<Machine>::Result,
00102 typename ViewType<Processing>::Result,
00103 typename ViewType<Usage>::Result,
00104 IntView>::post(home, vm,vs,vp,ve,vu,c_s,at_most)));
00105
00106 }
00107 }
00108
00109 void
00110 cumulatives(Home home, const IntVarArgs& m,
00111 const IntVarArgs& s, const IntVarArgs& p,
00112 const IntVarArgs& e, const IntVarArgs& u,
00113 const IntArgs& c, bool at_most,
00114 IntPropLevel cl) {
00115 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00116 }
00117
00118 void
00119 cumulatives(Home home, const IntArgs& m,
00120 const IntVarArgs& s, const IntVarArgs& p,
00121 const IntVarArgs& e, const IntVarArgs& u,
00122 const IntArgs& c, bool at_most,
00123 IntPropLevel cl) {
00124 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00125 }
00126
00127 void
00128 cumulatives(Home home, const IntVarArgs& m,
00129 const IntVarArgs& s, const IntArgs& p,
00130 const IntVarArgs& e, const IntVarArgs& u,
00131 const IntArgs& c, bool at_most,
00132 IntPropLevel cl) {
00133 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00134 }
00135
00136 void
00137 cumulatives(Home home, const IntArgs& m,
00138 const IntVarArgs& s, const IntArgs& p,
00139 const IntVarArgs& e, const IntVarArgs& u,
00140 const IntArgs& c, bool at_most,
00141 IntPropLevel cl) {
00142 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00143 }
00144
00145 void
00146 cumulatives(Home home, const IntVarArgs& m,
00147 const IntVarArgs& s, const IntVarArgs& p,
00148 const IntVarArgs& e, const IntArgs& u,
00149 const IntArgs& c, bool at_most,
00150 IntPropLevel cl) {
00151 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00152 }
00153
00154 void
00155 cumulatives(Home home, const IntArgs& m,
00156 const IntVarArgs& s, const IntVarArgs& p,
00157 const IntVarArgs& e, const IntArgs& u,
00158 const IntArgs& c, bool at_most,
00159 IntPropLevel cl) {
00160 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00161 }
00162
00163 void
00164 cumulatives(Home home, const IntVarArgs& m,
00165 const IntVarArgs& s, const IntArgs& p,
00166 const IntVarArgs& e, const IntArgs& u,
00167 const IntArgs& c, bool at_most,
00168 IntPropLevel cl) {
00169 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00170 }
00171
00172 void
00173 cumulatives(Home home, const IntArgs& m,
00174 const IntVarArgs& s, const IntArgs& p,
00175 const IntVarArgs& e, const IntArgs& u,
00176 const IntArgs& c, bool at_most,
00177 IntPropLevel cl) {
00178 post_cumulatives(home, m, s, p, e, u, c, at_most, cl);
00179 }
00180
00181 }
00182
00183