//***********************************************************************************
@Override
public void propagate(int evtmask) throws ContradictionException {
if (PropagatorEventType.isFullPropagation(evtmask)) {
SetVar union = vars[k];
for (int i = 0; i < k; i++) {
for (int j = vars[i].getKernelFirst(); j != SetVar.END; j = vars[i].getKernelNext())
union.addToKernel(j, aCause);
for (int j = vars[i].getEnvelopeFirst(); j != SetVar.END; j = vars[i].getEnvelopeNext())
if (!union.envelopeContains(j))
vars[i].removeFromEnvelope(j, aCause);
}
for (int j = union.getEnvelopeFirst(); j != SetVar.END; j = union.getEnvelopeNext()) {
if (union.kernelContains(j)) {
int mate = -1;
for (int i = 0; i < k && mate != -2; i++) {
if (vars[i].envelopeContains(j)) {
if (mate == -1) {
mate = i;
} else {
mate = -2;
}
}
}
if (mate == -1) {
contradiction(vars[k], "");
} else if (mate != -2) {
vars[mate].addToKernel(j, aCause);
}
} else {
int mate = -1;
for (int i = 0; i < k; i++) {
if (vars[i].envelopeContains(j)) {
mate = i;
break;
}
}
if (mate == -1) union.removeFromEnvelope(j, aCause);
}
}
// ------------------
for (int i = 0; i <= k; i++)
sdm[i].unfreeze();