00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "examples/support.hh"
00023 #include "gecode/minimodel.hh"
00024
00041 class Grocery : public Example {
00042 protected:
00044 IntVarArray x;
00046 static const int s = 711;
00047 public:
00049 Grocery(const Options&) : x(this,4,0,s) {
00050
00051
00052 post(this, x[0]+x[1]+x[2]+x[3] == s);
00053
00054
00055 {
00056 IntVar t0(this,0,Limits::Int::int_max);
00057 IntVar t1(this,0,Limits::Int::int_max);
00058 IntVar t2(this,0,Limits::Int::int_max);
00059 rel(this, t2, IRT_EQ, s*100*100*100);
00060 mult(this, x[0], x[1], t0);
00061 mult(this, x[2], x[3], t1);
00062 mult(this, t0, t1, t2);
00063 }
00064
00065
00066 rel(this, x[0], IRT_LQ, x[1]);
00067 rel(this, x[1], IRT_LQ, x[2]);
00068 rel(this, x[2], IRT_LQ, x[3]);
00069
00070 branch(this, x, BVAR_SIZE_MIN, BVAL_SPLIT_MAX);
00071 }
00072
00074 Grocery(bool share, Grocery& s) : Example(share,s) {
00075 x.update(this, share, s.x);
00076 }
00077
00079 virtual Space*
00080 copy(bool share) {
00081 return new Grocery(share,*this);
00082 }
00083
00085 virtual void
00086 print(void) {
00087 std::cout << "\t";
00088 for (int i = 0; i < x.size(); i++)
00089 std::cout << x[i] << ", ";
00090 std::cout << std::endl;
00091 }
00092 };
00093
00097 int
00098 main(int argc, char** argv) {
00099 Options opt("Grocery");
00100 opt.iterations = 20;
00101 opt.parse(argc,argv);
00102 Example::run<Grocery,DFS>(opt);
00103 return 0;
00104 }
00105
00106
00107