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

Method Hamming

test/nogoods.cpp:136–164  ·  view source on GitHub ↗

Actual model

Source from the content-addressed store, hash-verified

134 public:
135 /// Actual model
136 Hamming(SetValBranch svb, bool assign, bool null) :
137 x(*this,size,IntSet::empty,1,bits) {
138 SetVarArgs cx(x.size());
139 for (int i=x.size(); i--;)
140 cx[i] = expr(*this, -x[i]);
141
142 for (int i=0; i<x.size(); i++)
143 for (int j=i+1; j<x.size(); j++)
144 rel(*this,
145 cardinality(x[j] & cx[i]) +
146 cardinality(x[i] & cx[j]) >= distance);
147
148 if (assign) {
149 IntVar x(*this,0,1); Gecode::assign(*this, x, INT_ASSIGN_MIN());
150 }
151 {
152 SetVarArgs x1(size/2), x2(size/2);
153 for (int i=0; i<size/2; i++) {
154 x1[i] = x[i]; x2[i] = x[size/2 + i];
155 }
156 branch(*this, x1, SET_VAR_NONE(), svb);
157 if (null)
158 branch(*this, &dummy);
159 branch(*this, x2, SET_VAR_NONE(), svb);
160 }
161 if (assign) {
162 IntVar x(*this,0,1); Gecode::assign(*this, x, INT_ASSIGN_MIN());
163 }
164 }
165 /// Constructor for copying \a s
166 Hamming(Hamming& s) : Space(s) {
167 x.update(*this, s.x);

Callers

nothing calls this directly

Calls 9

INT_ASSIGN_MINFunction · 0.85
SET_VAR_NONEFunction · 0.85
exprFunction · 0.50
relFunction · 0.50
cardinalityFunction · 0.50
assignFunction · 0.50
branchFunction · 0.50
sizeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected