78 for (
int j=
i; j<
w_l; j++)
79 ml(
i,j) = ml(j,
i) =
IntVar(*
this,
'a',
'z');
91 for (
int i=0;
i<
w_l;
i++) {
94 for (
int n=0;
n<n_w;
n++)
96 for (
int j=0; j<
w_l; j++)
97 element(*
this, w2l, words[j], ml(
i,j));
103 switch (
opt.branching()) {
128 for (
int i=0;
i<
w_l;
i++) {
130 for (
int j=0; j<
w_l; j++)
132 os << static_cast<char>(ml(
i,j).val());
155 if (
opt.size() >
static_cast<unsigned int>(
dict.
len())) {
156 std::cerr <<
"Error: size must be between 0 and "
160 Script::run<WordSquare,DFS,SizeOptions>(
opt);
int n
Number of negative literals for node type.
void init(const char *fn)
Perform actual initialization.
int len(void) const
Return maximal length of a word.
const char * word(int l, int i) const
Return word number i with length l.
int words(void) const
Return total number of words.
Parse an additional file option.
Parametric base-class for scripts.
Passing integer variables.
Matrix-interface for arrays.
Options for scripts with additional size parameter
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void parse(int argc, char *argv[])
Parse commandline arguments.
Example: Word-square puzzle
IntVarArray letters
The array of letters.
int main(int argc, char *argv[])
Main-function.
virtual void print(std::ostream &os) const
Print solution.
WordSquare(WordSquare &s)
Constructor for cloning s.
virtual Space * copy(void)
Copy during cloning.
WordSquare(const SizeOptions &opt)
Actual model.
@ BRANCH_LETTERS
Branch on letter variables.
@ BRANCH_WORDS
Branch on word variables.
const int w_l
Length of words.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
bool assigned(View x, int v)
Whether x is assigned to value v.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode toplevel namespace
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
IntVarBranch INT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count divided by domain size with decay factor d.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
void element(Home home, IntSharedArray n, IntVar x0, IntVar x1, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
Gecode::IntArgs i({1, 2, 3, 4})
Dictionary dict
The dictionary to be used.