MCPcopy Create free account
hub / github.com/Gecode/gecode / Donald

Method Donald

examples/donald.cpp:61–95  ·  view source on GitHub ↗

Actual model

Source from the content-addressed store, hash-verified

59 };
60 /// Actual model
61 Donald(const Options& opt)
62 : Script(opt), le(*this,nl,0,9) {
63 IntVar
64 d(le[0]), o(le[1]), n(le[2]), a(le[3]), l(le[4]),
65 g(le[5]), e(le[6]), r(le[7]), b(le[8]), t(le[9]);
66 rel(*this, d, IRT_NQ, 0);
67 rel(*this, g, IRT_NQ, 0);
68 rel(*this, r, IRT_NQ, 0);
69
70 distinct(*this, le, opt.ipl());
71
72 switch (opt.model()) {
73 case MODEL_SINGLE:
74 rel(*this, 100000*d+10000*o+1000*n+100*a+10*l+d
75 + 100000*g+10000*e+1000*r+100*a+10*l+d
76 == 100000*r+10000*o+1000*b+100*e+10*r+t,
77 opt.ipl());
78 break;
79 case MODEL_CARRY:
80 {
81 IntVar c0(*this,0,1), c1(*this,0,1), c2(*this,0,1),
82 c3(*this,0,1), c4(*this,0,1);
83 rel(*this, d+d == t+10*c0, opt.ipl());
84 rel(*this, c0+l+l == r+10*c1, opt.ipl());
85 rel(*this, c1+a+a == e+10*c2, opt.ipl());
86 rel(*this, c2+n+r == b+10*c3, opt.ipl());
87 rel(*this, c3+o+e == o+10*c4, opt.ipl());
88 rel(*this, c4+d+g == r, opt.ipl());
89 }
90 break;
91 default: GECODE_NEVER;
92 }
93
94 branch(*this, le, INT_VAR_SIZE_MIN(), INT_VAL_MAX());
95 }
96 /// Constructor for cloning \a s
97 Donald(Donald& s) : Script(s) {
98 le.update(*this, s.le);

Callers

nothing calls this directly

Calls 8

distinctFunction · 0.85
INT_VAR_SIZE_MINFunction · 0.85
INT_VAL_MAXFunction · 0.85
modelMethod · 0.80
relFunction · 0.50
branchFunction · 0.50
iplMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected