Generated on Mon Aug 25 11:35:32 2008 for Gecode by doxygen 1.5.6

alpha.cc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2001
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-02-21 05:52:18 +0100 (Thu, 21 Feb 2008) $ by $Author: schulte $
00011  *     $Revision: 6259 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include "examples/support.hh"
00039 #include "gecode/minimodel.hh"
00040 
00049 class Alpha : public Example {
00050 protected:
00052   static const int n = 26;
00054   IntVarArray      le;
00055 public:
00057   enum {
00058     BRANCH_NONE, 
00059     BRANCH_SIZE  
00060   };
00062   Alpha(const Options& opt) : le(this,n,1,n) {
00063     IntVar
00064       a(le[ 0]), b(le[ 1]), c(le[ 2]), e(le[ 4]), f(le[ 5]),
00065       g(le[ 6]), h(le[ 7]), i(le[ 8]), j(le[ 9]), k(le[10]),
00066       l(le[11]), m(le[12]), n(le[13]), o(le[14]), p(le[15]),
00067       q(le[16]), r(le[17]), s(le[18]), t(le[19]), u(le[20]),
00068       v(le[21]), w(le[22]), x(le[23]), y(le[24]), z(le[25]);
00069 
00070     post(this, b+a+l+l+e+t       == 45,  opt.icl());
00071     post(this, c+e+l+l+o         == 43,  opt.icl());
00072     post(this, c+o+n+c+e+r+t     == 74,  opt.icl());
00073     post(this, f+l+u+t+e         == 30,  opt.icl());
00074     post(this, f+u+g+u+e         == 50,  opt.icl());
00075     post(this, g+l+e+e           == 66,  opt.icl());
00076     post(this, j+a+z+z           == 58,  opt.icl());
00077     post(this, l+y+r+e           == 47,  opt.icl());
00078     post(this, o+b+o+e           == 53,  opt.icl());
00079     post(this, o+p+e+r+a         == 65,  opt.icl());
00080     post(this, p+o+l+k+a         == 59,  opt.icl());
00081     post(this, q+u+a+r+t+e+t     == 50,  opt.icl());
00082     post(this, s+a+x+o+p+h+o+n+e == 134, opt.icl());
00083     post(this, s+c+a+l+e         == 51,  opt.icl());
00084     post(this, s+o+l+o           == 37,  opt.icl());
00085     post(this, s+o+n+g           == 61,  opt.icl());
00086     post(this, s+o+p+r+a+n+o     == 82,  opt.icl());
00087     post(this, t+h+e+m+e         == 72,  opt.icl());
00088     post(this, v+i+o+l+i+n       == 100, opt.icl());
00089     post(this, w+a+l+t+z         == 34,  opt.icl());
00090 
00091     distinct(this, le, opt.icl());
00092 
00093     branch(this, le, 
00094            (opt.branching() == BRANCH_NONE) ? INT_VAR_NONE : INT_VAR_SIZE_MIN,
00095            INT_VAL_MIN);
00096   }
00097 
00099   Alpha(bool share, Alpha& s) : Example(share,s) {
00100     le.update(this, share, s.le);
00101   }
00103   virtual Space*
00104   copy(bool share) {
00105     return new Alpha(share,*this);
00106   }
00108   virtual void
00109   print(std::ostream& os) {
00110     os << "\t";
00111     for (int i = 0; i < n; i++) {
00112       os << ((char) (i+'a')) << '=' << le[i] << ((i<n-1)?", ":"\n");
00113       if ((i+1) % 8 == 0)
00114         os << std::endl << "\t";
00115     }
00116     os << std::endl;
00117   }
00118 };
00119 
00123 int
00124 main(int argc, char* argv[]) {
00125   Options opt("Alpha");
00126   opt.solutions(0);
00127   opt.iterations(10);
00128   opt.branching(Alpha::BRANCH_NONE);
00129   opt.branching(Alpha::BRANCH_NONE, "none");
00130   opt.branching(Alpha::BRANCH_SIZE, "size");
00131   opt.parse(argc,argv);
00132   Example::run<Alpha,DFS,Options>(opt);
00133   return 0;
00134 }
00135 
00136 // STATISTICS: example-any
00137