grocery.cpp
Go to the documentation of this file.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/driver.hh>
00039 #include <gecode/int.hh>
00040 #include <gecode/minimodel.hh>
00041
00042 using namespace Gecode;
00043
00060 class Grocery : public Script {
00061 protected:
00063 IntVarArray abcd;
00065 static const int s = 711;
00067 static const int p = 711 * 100 * 100 * 100;
00068 public:
00070 Grocery(const Options& opt) : abcd(*this,4,0,s) {
00071 IntVar a(abcd[0]), b(abcd[1]), c(abcd[2]), d(abcd[3]);
00072
00073 post(*this, a+b+c+d == s, opt.icl());
00074
00075
00076 rel(*this,
00077 mult(*this,
00078 mult(*this, a, b, opt.icl()),
00079 mult(*this, c, d, opt.icl()),
00080 opt.icl()),
00081 IRT_EQ, p);
00082
00083
00084 rel(*this, a, IRT_LQ, b);
00085 rel(*this, b, IRT_LQ, c);
00086 rel(*this, c, IRT_LQ, d);
00087
00088 branch(*this, abcd, INT_VAR_NONE, INT_VAL_SPLIT_MAX);
00089 }
00090
00092 Grocery(bool share, Grocery& s) : Script(share,s) {
00093 abcd.update(*this, share, s.abcd);
00094 }
00095
00097 virtual Space*
00098 copy(bool share) {
00099 return new Grocery(share,*this);
00100 }
00101
00103 virtual void
00104 print(std::ostream& os) const {
00105 os << "\t" << abcd << std::endl;
00106 }
00107 };
00108
00112 int
00113 main(int argc, char* argv[]) {
00114 Options opt("Grocery");
00115 opt.iterations(20);
00116 opt.parse(argc,argv);
00117 Script::run<Grocery,DFS,Options>(opt);
00118 return 0;
00119 }
00120
00121
00122