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