MCPcopy Create free account
hub / github.com/Gecode/gecode / Partition

Method Partition

examples/partition.cpp:53–93  ·  view source on GitHub ↗

Actual model

Source from the content-addressed store, hash-verified

51public:
52 /// Actual model
53 Partition(const SizeOptions& opt)
54 : Script(opt),
55 x(*this,opt.size(),1,2*opt.size()),
56 y(*this,opt.size(),1,2*opt.size()) {
57 const int n = opt.size();
58
59 // Break symmetries by ordering numbers in each group
60 rel(*this, x, IRT_LE);
61 rel(*this, y, IRT_LE);
62
63 rel(*this, x[0], IRT_LE, y[0]);
64
65 IntVarArgs xy(2*n);
66 for (int i = n; i--; ) {
67 xy[i] = x[i]; xy[n+i] = y[i];
68 }
69 distinct(*this, xy, opt.ipl());
70
71 IntArgs c(2*n);
72 for (int i = n; i--; ) {
73 c[i] = 1; c[n+i] = -1;
74 }
75 linear(*this, c, xy, IRT_EQ, 0);
76
77 // Array of products
78 IntVarArgs sxy(2*n), sx(n), sy(n);
79
80 for (int i = n; i--; ) {
81 sx[i] = sxy[i] = expr(*this, sqr(x[i]));
82 sy[i] = sxy[n+i] = expr(*this, sqr(y[i]));
83 }
84 linear(*this, c, sxy, IRT_EQ, 0);
85
86 // Redundant constraints
87 linear(*this, x, IRT_EQ, 2*n*(2*n+1)/4);
88 linear(*this, y, IRT_EQ, 2*n*(2*n+1)/4);
89 linear(*this, sx, IRT_EQ, 2*n*(2*n+1)*(4*n+1)/12);
90 linear(*this, sy, IRT_EQ, 2*n*(2*n+1)*(4*n+1)/12);
91
92 branch(*this, xy, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN());
93 }
94
95 /// Constructor used during cloning \a s
96 Partition(Partition& s) : Script(s) {

Callers

nothing calls this directly

Calls 12

distinctFunction · 0.85
INT_VAR_AFC_SIZE_MAXFunction · 0.85
INT_VAL_MINFunction · 0.85
relFunction · 0.50
linearFunction · 0.50
exprFunction · 0.50
sqrFunction · 0.50
branchFunction · 0.50
sizeMethod · 0.45
iplMethod · 0.45
decayMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected