81 for (
int i=0;
i<w_l;
i++)
82 for (
int j=
i; j<w_l; j++)
83 ml(
i,j) = ml(j,
i) =
IntVar(*
this,
'a',
'z');
95 for (
int i=0;
i<w_l;
i++) {
98 for (
int n=n_w;
n--; )
100 for (
int j=0; j<w_l; j++)
101 element(*
this, w2l, words[j], ml(
i,j));
105 rel(*
this, words[0],
IRT_LE, words[w_l-1]);
107 switch (
opt.branching()) {
120 :
Script(share,s), w_l(s.w_l) {
132 for (
int i=0;
i<w_l;
i++) {
134 for (
int j=0; j<w_l; j++)
136 os << static_cast<char>(ml(
i,j).val());
159 if (
opt.size() > static_cast<unsigned int>(
dict.
len())) {
160 std::cerr <<
"Error: size must be between 0 and " 164 Script::run<WordSquare,DFS,SizeOptions>(
opt);
Parse an additional file option.
void init(const char *fn)
Perform actual initialization.
Options for scripts with additional size parameter
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
virtual void print(std::ostream &os) const
Print solution.
Branch on word variables.
Parametric base-class for scripts.
const int w_l
Length of words.
const char * word(int l, int i) const
Return word number i with length l.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
IntVarBranch INT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d.
int words(void) const
Return total number of words.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int main(int argc, char *argv[])
Main-function.
int n
Number of negative literals for node type.
Branch on letter variables.
Dictionary dict
The dictionary to be used.
virtual Space * copy(bool share)
Copy during cloning.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
WordSquare(const SizeOptions &opt)
Actual model.
IntVarArray letters
The array of letters.
void branching(int v)
Set default branching value.
Passing integer variables.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
int len(void) const
Return maximal length of a word.
bool assigned(View x, int v)
Whether x is assigned to value v.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Example: Word-square puzzle
WordSquare(bool share, WordSquare &s)
Constructor for cloning s.
Matrix-interface for arrays.
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
Gecode toplevel namespace
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .