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 #include <gecode/driver.hh>
00035
00036 #include <gecode/int.hh>
00037 #include <gecode/minimodel.hh>
00038
00039 using namespace Gecode;
00040
00049 class Alpha : public Script {
00050 protected:
00052 static const int n = 26;
00054 IntVarArray le;
00055 public:
00057 enum {
00058 BRANCH_NONE,
00059 BRANCH_INVERSE,
00060 BRANCH_SIZE
00061 };
00063 Alpha(const Options& opt)
00064 : Script(opt), le(*this,n,1,n) {
00065 IntVar
00066 a(le[ 0]), b(le[ 1]), c(le[ 2]), e(le[ 4]), f(le[ 5]),
00067 g(le[ 6]), h(le[ 7]), i(le[ 8]), j(le[ 9]), k(le[10]),
00068 l(le[11]), m(le[12]), n(le[13]), o(le[14]), p(le[15]),
00069 q(le[16]), r(le[17]), s(le[18]), t(le[19]), u(le[20]),
00070 v(le[21]), w(le[22]), x(le[23]), y(le[24]), z(le[25]);
00071
00072 rel(*this, b+a+l+l+e+t == 45, opt.ipl());
00073 rel(*this, c+e+l+l+o == 43, opt.ipl());
00074 rel(*this, c+o+n+c+e+r+t == 74, opt.ipl());
00075 rel(*this, f+l+u+t+e == 30, opt.ipl());
00076 rel(*this, f+u+g+u+e == 50, opt.ipl());
00077 rel(*this, g+l+e+e == 66, opt.ipl());
00078 rel(*this, j+a+z+z == 58, opt.ipl());
00079 rel(*this, l+y+r+e == 47, opt.ipl());
00080 rel(*this, o+b+o+e == 53, opt.ipl());
00081 rel(*this, o+p+e+r+a == 65, opt.ipl());
00082 rel(*this, p+o+l+k+a == 59, opt.ipl());
00083 rel(*this, q+u+a+r+t+e+t == 50, opt.ipl());
00084 rel(*this, s+a+x+o+p+h+o+n+e == 134, opt.ipl());
00085 rel(*this, s+c+a+l+e == 51, opt.ipl());
00086 rel(*this, s+o+l+o == 37, opt.ipl());
00087 rel(*this, s+o+n+g == 61, opt.ipl());
00088 rel(*this, s+o+p+r+a+n+o == 82, opt.ipl());
00089 rel(*this, t+h+e+m+e == 72, opt.ipl());
00090 rel(*this, v+i+o+l+i+n == 100, opt.ipl());
00091 rel(*this, w+a+l+t+z == 34, opt.ipl());
00092
00093 distinct(*this, le, opt.ipl());
00094
00095 switch (opt.branching()) {
00096 case BRANCH_NONE:
00097 branch(*this, le, INT_VAR_NONE(), INT_VAL_MIN());
00098 break;
00099 case BRANCH_INVERSE:
00100 branch(*this, le.slice(le.size()-1,-1), INT_VAR_NONE(), INT_VAL_MIN());
00101 break;
00102 case BRANCH_SIZE:
00103 branch(*this, le, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
00104 break;
00105 }
00106 }
00107
00109 Alpha(Alpha& s) : Script(s) {
00110 le.update(*this, s.le);
00111 }
00113 virtual Space*
00114 copy(void) {
00115 return new Alpha(*this);
00116 }
00118 virtual void
00119 print(std::ostream& os) const {
00120 os << "\t";
00121 for (int i = 0; i < n; i++) {
00122 os << ((char) (i+'a')) << '=' << le[i] << ((i<n-1)?", ":"\n");
00123 if ((i+1) % 8 == 0)
00124 os << std::endl << "\t";
00125 }
00126 os << std::endl;
00127 }
00128 };
00129
00133 int
00134 main(int argc, char* argv[]) {
00135 Options opt("Alpha");
00136 opt.solutions(0);
00137 opt.iterations(10);
00138 opt.branching(Alpha::BRANCH_NONE);
00139 opt.branching(Alpha::BRANCH_NONE, "none");
00140 opt.branching(Alpha::BRANCH_INVERSE, "inverse");
00141 opt.branching(Alpha::BRANCH_SIZE, "size");
00142 opt.parse(argc,argv);
00143 Script::run<Alpha,DFS,Options>(opt);
00144 return 0;
00145 }
00146
00147
00148