Skip to content

Commit 303281d

Browse files
author
Christian Schulte
committed
Support afc-size branching
git-svn-id: file:///Users/tack/GecodeGitMigration/gecode-svn-mirror/gecode/trunk@14409 e85b7adc-8362-4630-8c63-7469d557c915
1 parent 2ef7e18 commit 303281d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

examples/magic-square.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class MagicSquare : public Script {
5959
IntVarArray x;
6060

6161
public:
62+
/// Branching to use for model
63+
enum {
64+
BRANCH_SIZE, ///< Branch by size
65+
BRANCH_AFC_SIZE ///< Branch by size over AFC
66+
};
6267
/// Post constraints
6368
MagicSquare(const SizeOptions& opt)
6469
: n(opt.size()), x(*this,n*n,1,n*n) {
@@ -94,7 +99,14 @@ class MagicSquare : public Script {
9499
rel(*this, m(0,0), IRT_GR, m(0,n-1));
95100
rel(*this, m(0,0), IRT_GR, m(n-1,0));
96101

97-
branch(*this, x, INT_VAR_SIZE_MIN(), INT_VAL_SPLIT_MIN());
102+
switch (opt.branching()) {
103+
case BRANCH_SIZE:
104+
branch(*this, x, INT_VAR_SIZE_MIN(), INT_VAL_SPLIT_MIN());
105+
break;
106+
case BRANCH_AFC_SIZE:
107+
branch(*this, x, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_SPLIT_MIN());
108+
break;
109+
}
98110
}
99111

100112
/// Constructor for cloning \a s
@@ -132,6 +144,9 @@ main(int argc, char* argv[]) {
132144
SizeOptions opt("MagicSquare");
133145
opt.iterations(1);
134146
opt.size(7);
147+
opt.branching(MagicSquare::BRANCH_SIZE);
148+
opt.branching(MagicSquare::BRANCH_SIZE, "size");
149+
opt.branching(MagicSquare::BRANCH_AFC_SIZE, "afc-size");
135150
opt.parse(argc,argv);
136151
Script::run<MagicSquare,DFS,SizeOptions>(opt);
137152
return 0;

0 commit comments

Comments
 (0)