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

Method symmetric

gecode/int/ldsb/sym-imp.hpp:224–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222 /// Compute symmetric literals
223 template <class View>
224 ArgArray<Literal>
225 VariableSequenceSymmetryImp<View>
226 ::symmetric(Literal l, const ViewArray<View>& x) const {
227 Region region;
228 Support::DynamicStack<Literal,Region> s(region);
229 if (l._variable < (int)lookup_size) {
230 int posIt = lookup[l._variable];
231 if (posIt == -1) {
232 return dynamicStackToArgArray(s);
233 }
234 unsigned int seqNum = posIt / seq_size;
235 unsigned int seqPos = posIt % seq_size;
236 for (unsigned int seq = 0 ; seq < n_seqs ; seq++) {
237 if (seq == seqNum) {
238 continue;
239 }
240 if (x[getVal(seq, seqPos)].assigned()) {
241 continue;
242 }
243 bool active = true;
244 const unsigned int *firstSeq = &indices[seqNum*seq_size];
245 const unsigned int *secondSeq = &indices[seq*seq_size];
246 for (unsigned int i = 0 ; i < seq_size ; i++) {
247 const View& xv = x[firstSeq[i]];
248 const View& yv = x[secondSeq[i]];
249 if ((!xv.assigned() && !yv.assigned())
250 || (xv.assigned() && yv.assigned() && xv.val() == yv.val())) {
251 continue;
252 } else {
253 active = false;
254 break;
255 }
256 }
257
258 if (active) {
259 s.push(Literal(secondSeq[seqPos], l._value));
260 }
261 }
262 }
263 return dynamicStackToArgArray(s);
264 }
265
266
267 template <class View>

Callers

nothing calls this directly

Calls 5

dynamicStackToArgArrayFunction · 0.85
LiteralClass · 0.85
assignedMethod · 0.45
valMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected