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

stress-min.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-07-25 12:42:29 +0200 (Tue, 25 Jul 2006) $ by $Author: schulte $
00010  *     $Revision: 3456 $
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 
00030 class StressMin : public Example {
00031 protected:
00033   const int n;
00035   IntVarArray x;
00036 public:
00038   StressMin(const Options& opt)
00039     : n(opt.size), x(this,n,0,2*n-1) {
00040     for (int i=1; i<n; i++) {
00041       IntVarArgs y(i);
00042       for (int j=0; j<i; j++)
00043         y[j]=x[j];
00044       IntVar m(this,0,2*n);
00045       min(this, y, m);
00046       rel(this, m, IRT_GR, x[i]);
00047     }
00048     branch(this, x, BVAR_NONE, BVAL_SPLIT_MAX);
00049   }
00050 
00052   StressMin(bool share, StressMin& s) : Example(share,s), n(s.n) {
00053     x.update(this, share, s.x);
00054   }
00055 
00057   virtual Space*
00058   copy(bool share) {
00059     return new StressMin(share,*this);
00060   }
00061 
00063   virtual void
00064   print(void) {
00065     std::cout << "\tx[" << n << "] = {";
00066     for (int i = 0; i < n; i++)
00067       std::cout << x[i] << ((i<n-1)?",":"};\n");
00068   }
00069 };
00070 
00071 
00075 int
00076 main(int argc, char** argv) {
00077   Options opt("StressMin");
00078   opt.parse(argc,argv);
00079   opt.size = 200;
00080   Example::run<StressMin,DFS>(opt);
00081   return 0;
00082 }
00083 
00084 // STATISTICS: example-any