77 : w_l(opt.
size()), letters(*this, w_l*w_l) {
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]);
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());
151 main(
int argc,
char* argv[]) {
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.
virtual void print(std::ostream &os) const
Print solution.
Options for scripts with additional size parameter
Branch on word variables.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Branch on letter variables.
Parametric base-class for scripts.
void decay(double d)
Set default decay factor.
const int w_l
Length of words.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
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.
WordSquare(const SizeOptions &opt)
Actual model.
const char * word(int l, int i) const
Return word number i with length l.
int len(void) const
Return maximal length of a word.
IntVarArray letters
The array of letters.
void branching(int v)
Set default branching value.
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntConLevel)
Post domain consistent propagator for .
Passing integer variables.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
bool assigned(View x, int v)
Whether x is assigned to value v.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
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...
Example: Word-square puzzle
WordSquare(bool share, WordSquare &s)
Constructor for cloning s.
void distinct(Home home, const IntVarArgs &x, IntConLevel icl)
Post propagator for for all .
Matrix-interface for arrays.
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
int main(int argc, char *argv[])
Gecode toplevel namespace
BrancherHandle 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.
int words(void) const
Return total number of words.