38 using namespace Gecode;
70 const int s = nn*(nn+1) / (2*
n);
75 for (
int i =
n;
i--; ) {
83 for (
int i =
n;
i--; ) {
98 switch (
opt.branching()) {
102 case BRANCH_AFC_SIZE:
110 x.update(*
this, s.x);
123 for (
int i = 0;
i<
n;
i++) {
125 for (
int j = 0; j<
n; j++) {
139 main(
int argc,
char* argv[]) {
147 Script::run<MagicSquare,DFS,SizeOptions>(
opt);
int n
Number of negative literals for node type.
Node * x
Pointer to corresponding Boolean expression node.
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.
Slice< A > col(int c) const
Access column c.
Slice< A > row(int r) const
Access row r.
void iterations(unsigned int i)
Set default number of iterations.
void branching(int v)
Set default branching value.
Options for scripts with additional size parameter
virtual Space * copy(void)
Copy during cloning.
@ BRANCH_AFC_SIZE
Branch by size over AFC.
@ BRANCH_SIZE
Branch by size.
MagicSquare(MagicSquare &s)
Constructor for cloning s.
MagicSquare(const SizeOptions &opt)
Post constraints.
virtual void print(std::ostream &os) const
Print solution.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post 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.
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.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode::IntArgs i({1, 2, 3, 4})
int main(int argc, char *argv[])