stress-min.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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