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 "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 IntVar t3(this,0,Limits::Int::int_max);
00060 rel(this, t2, IRT_EQ, s*100*100*100);
00061 mult(this, x[0], x[1], t0);
00062 mult(this, x[2], x[3], t1);
00063 mult(this, t0, t1, t2);
00064 }
00065
00066
00067 rel(this, x[0], IRT_LQ, x[1]);
00068 rel(this, x[1], IRT_LQ, x[2]);
00069 rel(this, x[2], IRT_LQ, x[3]);
00070
00071 branch(this, x, BVAR_SIZE_MIN, BVAL_SPLIT_MAX);
00072 }
00073
00075 Grocery(bool share, Grocery& s) : Example(share,s) {
00076 x.update(this, share, s.x);
00077 }
00078
00080 virtual Space*
00081 copy(bool share) {
00082 return new Grocery(share,*this);
00083 }
00084
00086 virtual void
00087 print(void) {
00088 std::cout << "\t";
00089 for (int i = 0; i < x.size(); i++)
00090 std::cout << x[i] << ", ";
00091 std::cout << std::endl;
00092 }
00093 };
00094
00098 int
00099 main(int argc, char** argv) {
00100 Options opt("Grocery");
00101 opt.iterations = 20;
00102 opt.parse(argc,argv);
00103 Example::run<Grocery,DFS>(opt);
00104 return 0;
00105 }
00106
00107
00108