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

donald.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 Donald : public Example {
00034 private:
00036   static const int nl = 10;
00038   IntVarArray le;
00039 public:
00040   Donald(const Options& opt) : 
00041     le(this,nl,0,9) {
00042     IntVar
00043       d(le[0]), o(le[1]), n(le[2]), a(le[3]), l(le[4]),
00044       g(le[5]), e(le[6]), r(le[7]), b(le[8]), t(le[9]);
00045     rel(this, d, IRT_NQ, 0);
00046     rel(this, g, IRT_NQ, 0);
00047     rel(this, r, IRT_NQ, 0);
00048 
00049     post(this,    100000*d+10000*o+1000*n+100*a+10*l+d
00050                 + 100000*g+10000*e+1000*r+100*a+10*l+d
00051                == 100000*r+10000*o+1000*b+100*e+10*r+t);
00052 
00053     distinct(this, le, opt.icl);
00054 
00055     branch(this, le, BVAR_SIZE_MIN, BVAL_MIN);
00056   }
00057 
00058   Donald(bool share, Donald& s) : Example(share,s) {
00059     le.update(this, share, s.le);
00060   }
00061 
00062   virtual Space*
00063   copy(bool share) {
00064     return new Donald(share,*this);
00065   }
00066 
00067   virtual void
00068   print(void) {
00069     std::cout << "\t";
00070     for (int i = 0; i < nl; i++)
00071       std::cout << le[i] << ' ';
00072     std::cout << std::endl;
00073   }
00074 
00075 };
00076 
00077 
00081 int
00082 main(int argc, char** argv) {
00083   Options opt("Donald+Gerald=Robert");
00084   opt.solutions  = 0;
00085   opt.iterations = 1500;
00086   opt.parse(argc,argv);
00087   Example::run<Donald,DFS>(opt);
00088   return 0;
00089 }
00090 
00091 // STATISTICS: example-any
00092