52 static const int nl = 8;
64 s(
le[0]), e(
le[1]), n(
le[2]), d(
le[3]),
69 trace(*
this, opt.trace());
77 switch (opt.model()) {
79 rel(*
this, 1000*s+100*e+10*n+d
81 == 10000*m+1000*o+100*n+10*e+
y,
86 IntVar c0(*
this,0,1), c1(*
this,0,1), c2(*
this,0,1), c3(*
this,0,1);
87 rel(*
this, d+e ==
y+10*c0, opt.ipl());
88 rel(*
this, c0+n+
r == e+10*c1, opt.ipl());
89 rel(*
this, c1+e+o == n+10*c2, opt.ipl());
90 rel(*
this, c2+s+m == o+10*c3, opt.ipl());
91 rel(*
this, c3 == m, opt.ipl());
99 IntVar,
int i,
const int& n,
101 static char name[8] = {
's',
'e',
'n',
'd',
104 << ((a == 0) ?
" = " :
" != ")
111 os <<
"\t" <<
le << std::endl;
116 le.update(*
this, s.
le);
121 return new Money(*
this);
130 Options opt(
"SEND+MORE=MONEY");
135 opt.iterations(20000);
136 opt.
parse(argc,argv);
Base-class for branchers.
static void run(const Options &opt, Script *s=NULL)
int main(int argc, char *argv[])
Main-function.
IntVarArray le
Array of letters.
static const int nl
Number of letters.
virtual Space * copy(void)
Copy during cloning.
Money(Money &s)
Constructor for cloning s.
@ MODEL_CARRY
Use carries.
@ MODEL_SINGLE
Use single linear equation.
Money(const Options &opt)
Actual model.
virtual void print(std::ostream &os) const
Print solution.
void parse(int argc, char *argv[])
Parse commandline arguments.
Driver::ScriptBase< Driver::IgnoreStepOption< Space > > Script
Base-class for scripts.
GECODE_FLOAT_EXPORT void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te=(TE_INIT|TE_PRUNE|TE_FIX|TE_FAIL|TE_DONE), FloatTracer &t=StdFloatTracer::def)
Create a tracer for float variables.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
Post propagator for SetVar SetOpType SetVar y
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
#define GECODE_NEVER
Assert that this command is never executed.