Generated on Wed Nov 1 15:04:27 2006 for Gecode by doxygen 1.4.5

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: 2006-08-04 16:06:52 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3517 $
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 "gecode/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          opt.icl);
00053 
00054     distinct(this, le, opt.icl);
00055 
00056     branch(this, le, BVAR_SIZE_MIN, BVAL_MIN);
00057   }
00058 
00059   Donald(bool share, Donald& s) : Example(share,s) {
00060     le.update(this, share, s.le);
00061   }
00062 
00063   virtual Space*
00064   copy(bool share) {
00065     return new Donald(share,*this);
00066   }
00067 
00068   virtual void
00069   print(void) {
00070     std::cout << "\t";
00071     for (int i = 0; i < nl; i++)
00072       std::cout << le[i] << ' ';
00073     std::cout << std::endl;
00074   }
00075 
00076 };
00077 
00078 
00082 int
00083 main(int argc, char** argv) {
00084   Options opt("Donald+Gerald=Robert");
00085   opt.solutions  = 0;
00086   opt.iterations = 1500;
00087   opt.parse(argc,argv);
00088   Example::run<Donald,DFS>(opt);
00089   return 0;
00090 }
00091 
00092 // STATISTICS: example-any
00093