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

alpha.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 Alpha : public Example {
00034 protected:
00036   static const int n = 26;
00038   IntVarArray      le;
00039 public:
00041   Alpha(const Options& opt) : le(this,n,1,n) {
00042     IntVar
00043       a(le[ 0]), b(le[ 1]), c(le[ 2]), e(le[ 4]), f(le[ 5]),
00044       g(le[ 6]), h(le[ 7]), i(le[ 8]), j(le[ 9]), k(le[10]),
00045       l(le[11]), m(le[12]), n(le[13]), o(le[14]), p(le[15]),
00046       q(le[16]), r(le[17]), s(le[18]), t(le[19]), u(le[20]),
00047       v(le[21]), w(le[22]), x(le[23]), y(le[24]), z(le[25]);
00048 
00049     post(this, b+a+l+l+e+t       == 45,  opt.icl);
00050     post(this, c+e+l+l+o         == 43,  opt.icl);
00051     post(this, c+o+n+c+e+r+t     == 74,  opt.icl);
00052     post(this, f+l+u+t+e         == 30,  opt.icl);
00053     post(this, f+u+g+u+e         == 50,  opt.icl);
00054     post(this, g+l+e+e           == 66,  opt.icl);
00055     post(this, j+a+z+z           == 58,  opt.icl);
00056     post(this, l+y+r+e           == 47,  opt.icl);
00057     post(this, o+b+o+e           == 53,  opt.icl);
00058     post(this, o+p+e+r+a         == 65,  opt.icl);
00059     post(this, p+o+l+k+a         == 59,  opt.icl);
00060     post(this, q+u+a+r+t+e+t     == 50,  opt.icl);
00061     post(this, s+a+x+o+p+h+o+n+e == 134, opt.icl);
00062     post(this, s+c+a+l+e         == 51,  opt.icl);
00063     post(this, s+o+l+o           == 37,  opt.icl);
00064     post(this, s+o+n+g           == 61,  opt.icl);
00065     post(this, s+o+p+r+a+n+o     == 82,  opt.icl);
00066     post(this, t+h+e+m+e         == 72,  opt.icl);
00067     post(this, v+i+o+l+i+n       == 100, opt.icl);
00068     post(this, w+a+l+t+z         == 34,  opt.icl);
00069 
00070     distinct(this, le, opt.icl);
00071 
00072     branch(this, le, opt.naive ? BVAR_NONE : BVAR_SIZE_MIN, BVAL_MIN);
00073   }
00074 
00076   Alpha(bool share, Alpha& s) : Example(share,s) {
00077     le.update(this, share, s.le);
00078   }
00080   virtual Space*
00081   copy(bool share) {
00082     return new Alpha(share,*this);
00083   }
00085   virtual void
00086   print(void) {
00087     std::cout << "\t";
00088     for (int i = 0; i < n; i++) {
00089       std::cout << ((char) (i+'a')) << '=' << le[i] << ((i<n-1)?", ":"\n");
00090       if ((i+1) % 8 == 0)
00091         std::cout << std::endl << "\t";
00092     }
00093     std::cout << std::endl;
00094   }
00095 };
00096 
00100 int
00101 main(int argc, char** argv) {
00102   Options opt("Alpha");
00103   opt.solutions  = 0;
00104   opt.iterations = 10;
00105   opt.naive      = true;
00106   opt.parse(argc,argv);
00107   Example::run<Alpha,DFS>(opt);
00108   return 0;
00109 }
00110 
00111 // STATISTICS: example-any
00112