73 :
Script(opt), w_l(opt.
size()), letters(*this, w_l*w_l) {
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]);
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());
153 opt.
parse(argc,argv);
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);
WordSquare(WordSquare &s)
Constructor for cloning s.
Parse an additional file option.
void init(const char *fn)
Perform actual initialization.
void size(unsigned int s)
Set default size.
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.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
virtual void print(std::ostream &os) const
Print solution.
Parametric base-class for scripts.
void decay(double d)
Set default decay factor.
const int w_l
Length of words.
const char * word(int l, int i) const
Return word number i with length l.
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.
int main(int argc, char *argv[])
Main-function.
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
Branch on letter variables.
Dictionary dict
The dictionary to be used.
Branch on word variables.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
virtual Space * copy(void)
Copy during cloning.
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.
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
const char * file(void) const
Return file name (NULL if none given)
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 .