stress-element.cpp
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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <gecode/driver.hh>
00039 #include <gecode/int.hh>
00040
00041 using namespace Gecode;
00042
00052 class StressElement : public Script {
00053 protected:
00055 static const int n = 15;
00057 static const int m = 90;
00059 static const int p[n];
00060
00062 IntVarArray x;
00063 public:
00065 StressElement(const Options&)
00066 : x(*this,n,0,n-1) {
00067
00068 IntVarArgs s(n);
00069 for (int i=0; i<n; i++)
00070 s[i].init(*this,0,m);
00071
00072 rel(*this, s, IRT_LQ);
00073
00074 IntArgs e(n,p);
00075
00076 for (int i=0; i<n; i++)
00077 element(*this, e, x[i], s[i]);
00078
00079 distinct(*this, x);
00080 branch(*this, x, INT_VAR_SIZE_MIN, INT_VAL_MIN);
00081 }
00082
00084 StressElement(bool share, StressElement& s) : Script(share,s) {
00085 x.update(*this, share, s.x);
00086 }
00087
00089 virtual Space*
00090 copy(bool share) {
00091 return new StressElement(share,*this);
00092 }
00093
00095 virtual void
00096 print(std::ostream& os) const {
00097 os << "\tx[" << n << "] = " << x << std::endl;
00098 }
00099 };
00100
00101 const int StressElement::p[15] = {16,35,90,42,88,6,40,42,64,48,46,5,90,29,70};
00102
00106 int
00107 main(int argc, char* argv[]) {
00108 Options opt("StressElement");
00109 opt.parse(argc,argv);
00110 Script::run<StressElement,DFS,Options>(opt);
00111 return 0;
00112 }
00113
00114
00115