magic-sequence-gcc.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 #include "gecode/minimodel.hh"
00024
00037 class MagicSequence : public Example {
00038 private:
00040 const int n;
00042 IntVarArray s;
00043 public:
00045 MagicSequence(const Options& opt)
00046 : n(opt.size), s(this,n,0,n-1) {
00047 gcc(this, s, s, 0, n-1, ICL_BND);
00048 IntArgs c(n);
00049 for (int j = n; j--; )
00050 c[j] = j-1;
00051 linear(this, c, s, IRT_EQ, 0);
00052 branch(this, s, BVAR_NONE, BVAL_SPLIT_MAX);
00053 }
00054
00056 MagicSequence(bool share, MagicSequence& e) : Example(share,e), n(e.n) {
00057 s.update(this, share, e.s);
00058 }
00060 virtual Space*
00061 copy(bool share) {
00062 return new MagicSequence(share,*this);
00063 }
00065 virtual
00066 void print(void) {
00067 std::cout << "\t";
00068 for (int i = 0; i<n; i++) {
00069 std::cout << s[i] << ", ";
00070 if ((i+1) % 20 == 0)
00071 std::cout << std::endl << "\t";
00072 }
00073 std::cout << std::endl;
00074 }
00075
00076 };
00077
00081 int
00082 main(int argc, char** argv) {
00083 Options opt("MagicSequence");
00084 opt.solutions = 0;
00085 opt.iterations = 4;
00086 opt.size = 500;
00087 opt.parse(argc,argv);
00088 Example::run<MagicSequence,DFS>(opt);
00089 return 0;
00090 }
00091
00092
00093