Generated on Wed Jan 4 17:49:07 2006 for Gecode by doxygen 1.4.6

money.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2001
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-11-04 15:30:42 +0100 (Fri, 04 Nov 2005) $ by $Author: schulte $
00010  *     $Revision: 2499 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: example-any
00090