45 using namespace Gecode;
77 for (
int i=0;
i<w_l;
i++)
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));
101 rel(*
this, words[0],
IRT_LE, words[w_l-1]);
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.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Parametric base-class for scripts.
Passing integer variables.
Matrix-interface for arrays.
void branching(int v)
Set default branching value.
Options for scripts with additional size parameter
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
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 distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
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.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
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::IntArgs i({1, 2, 3, 4})
Dictionary dict
The dictionary to be used.