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

stress-element.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2006
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 
00024 static const int n = 15;
00025 static const int m = 90;
00026 static const int p[n] = {16,35,90,42,88,6,40,42,64,48,46,5,90,29,70};
00027 
00037 class StressElement : public Example {
00038 protected:
00040   IntVarArray x;
00041 public:
00043   StressElement(const Options& opt)
00044     : x(this,n,0,n-1) {
00045 
00046     IntVarArgs s(n);
00047     for (int i=0; i<n; i++) {
00048       IntVar si(this,0,m); s[i]=si;
00049     }
00050 
00051     for (int i=0; i<n-1; i++)
00052       rel(this, s[i], IRT_LQ, s[i+1]);
00053 
00054     IntArgs e(n,p);
00055 
00056     for (int i=0; i<n; i++)
00057       element(this, e, x[i], s[i]);
00058 
00059     distinct(this, x);
00060     branch(this, x, BVAR_SIZE_MIN, BVAL_MIN);
00061   }
00062 
00064   StressElement(bool share, StressElement& s) : Example(share,s) {
00065     x.update(this, share, s.x);
00066   }
00067 
00069   virtual Space*
00070   copy(bool share) {
00071     return new StressElement(share,*this);
00072   }
00073 
00075   virtual void
00076   print(void) {
00077     std::cout << "\tx[" << n << "] = {";
00078     for (int i = 0; i < n; i++)
00079       std::cout << x[i] << ((i<n-1)?",":"};\n");
00080   }
00081 };
00082 
00086 int
00087 main(int argc, char** argv) {
00088   Options opt("StressElement");
00089   opt.parse(argc,argv);
00090   Example::run<StressElement,DFS>(opt);
00091   return 0;
00092 }
00093 
00094 // STATISTICS: example-any
00095