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');
82 const int n_w =
dict.words(
w_l);
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++)
131 if (ml(i,j).assigned()) {
132 os << static_cast<char>(ml(i,j).val());
153 opt.
parse(argc,argv);
154 dict.init(opt.file());
155 if (opt.size() >
static_cast<unsigned int>(
dict.len())) {
156 std::cerr <<
"Error: size must be between 0 and "
157 <<
dict.len() << std::endl;
Parse an additional file option.
static void run(const Options &opt, Script *s=NULL)
Passing integer variables.
Matrix-interface for arrays.
Options for scripts with additional size parameter
void parse(int argc, char *argv[])
Parse commandline arguments.
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.
@ BRANCH_LETTERS
Branch on letter variables.
@ BRANCH_WORDS
Branch on word variables.
virtual Space * copy(void)
Copy during cloning.
WordSquare(const SizeOptions &opt)
Actual model.
const int w_l
Length of words.
Driver::ScriptBase< Driver::IgnoreStepOption< Space > > Script
Base-class for scripts.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
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.
SharedArray< int > IntSharedArray
Arrays of integers that can be shared among several element constraints.
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.
Dictionary dict
The dictionary to be used.