money.cc
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 #include "examples/support.hh"
00023 #include "minimodel.hh"
00024
00033 class Money : public Example {
00034 protected:
00036 static const int nl = 8;
00038 IntVarArray le;
00039 public:
00041 Money(const Options& opt) : le(this,nl,0,9) {
00042 IntVar
00043 s(le[0]), e(le[1]), n(le[2]), d(le[3]),
00044 m(le[4]), o(le[5]), r(le[6]), y(le[7]);
00045
00046 rel(this, s, IRT_NQ, 0);
00047 rel(this, m, IRT_NQ, 0);
00048
00049 post(this, 1000*s+100*e+10*n+d
00050 + 1000*m+100*o+10*r+e
00051 == 10000*m+1000*o+100*n+10*e+y);
00052
00053 distinct(this, le, opt.icl);
00054 branch(this, le, BVAR_SIZE_MIN, BVAL_MIN);
00055 }
00057 virtual void
00058 print(void) {
00059 std::cout << "\t";
00060 for (int i = 0; i < nl; i++)
00061 std::cout << le[i] << " ";
00062 std::cout << std::endl;
00063 }
00064
00066 Money(bool share, Money& s) : Example(share,s) {
00067 le.update(this, share, s.le);
00068 }
00070 virtual Space*
00071 copy(bool share) {
00072 return new Money(share,*this);
00073 }
00074 };
00075
00079 int
00080 main(int argc, char** argv) {
00081 Options opt("SEND+MORE=MONEY");
00082 opt.solutions = 0;
00083 opt.iterations = 20000;
00084 opt.parse(argc,argv);
00085 Example::run<Money,DFS>(opt);
00086 return 0;
00087 }
00088
00089
00090