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

magic-sequence-gcc.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 
00037 class MagicSequence : public Example {
00038 private:
00040   const int n;
00042   IntVarArray s;
00043 public:
00045   MagicSequence(const Options& opt)
00046     : n(opt.size), s(this,n,0,n-1) {
00047     gcc(this, s, s, 0, n-1, ICL_BND);
00048     IntArgs c(n);
00049     for (int j = n; j--; )
00050       c[j] = j-1;
00051     linear(this, c, s, IRT_EQ, 0);
00052     branch(this, s, BVAR_NONE, BVAL_SPLIT_MAX);
00053   }
00054 
00056   MagicSequence(bool share, MagicSequence& e) : Example(share,e), n(e.n) {
00057     s.update(this, share, e.s);
00058   }
00060   virtual Space*
00061   copy(bool share) {
00062     return new MagicSequence(share,*this);
00063   }
00065   virtual
00066   void print(void) {
00067     std::cout << "\t";
00068     for (int i = 0; i<n; i++) {
00069       std::cout << s[i] << ", ";
00070       if ((i+1) % 20 == 0)
00071         std::cout << std::endl << "\t";
00072     }
00073     std::cout << std::endl;
00074   }
00075 
00076 };
00077 
00081 int
00082 main(int argc, char** argv) {
00083   Options opt("MagicSequence");
00084   opt.solutions  = 0;
00085   opt.iterations = 4;
00086   opt.size       = 500;
00087   opt.parse(argc,argv);
00088   Example::run<MagicSequence,DFS>(opt);
00089   return 0;
00090 }
00091 
00092 // STATISTICS: example-any
00093