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()) {
110 x.update(*
this, s.x);
123 for (
int i = 0;
i<
n;
i++) {
125 for (
int j = 0; j<
n; j++) {
139main(
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.
int main(int argc, char *argv[])
Main-function.
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.
Options for scripts with additional size parameter
@ 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.
virtual Space * copy(void)
Copy during cloning.
void parse(int argc, char *argv[])
Parse commandline arguments.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
unsigned int size(I &i)
Size of all ranges of range iterator i.
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.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
Gecode::IntArgs i({1, 2, 3, 4})