stress-element.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
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
00095