@Override public void onUpdate(Variable var, EventType evt) { if (evt == EventType.INSTANTIATE) { int nbp = var.getNbProps(); for (int p = 0; p < nbp; p++) { Propagator prop = var.getPropagator(p); int pid = prop.getId(); pid2ari.get(pid).add(-1); } } }
@Override public void updatePropagationConditions(Propagator propagator, int idxInProp) { modificationEvents |= propagator.getPropagationConditions(idxInProp); if (!reactOnRemoval && ((modificationEvents & EventType.REMOVE.mask) != 0)) { delta = new Delta(); reactOnRemoval = true; } }
private int weight(IntVar v) { int w = 0; int nbp = v.getNbProps(); for (int p = 0; p < nbp; p++) { Propagator prop = v.getPropagator(p); int pid = prop.getId(); if (pid2arity.get(pid) > 1) { w += counter.getFails(prop); } else { int a = pid2ari.get(pid).get(); pid2arity.put(pid, a); if (a > 1) { w += counter.getFails(prop); } } } return w; }
@Override public void explain(Deduction d, Explanation e) { if (d.getVar() == vars[0]) { e.add(aCause); if (d.getmType() == Deduction.Type.ValRem) { vars[1].explain(VariableState.REM, ((ValueRemoval) d).getVal(), e); vars[1].explain(VariableState.REM, -((ValueRemoval) d).getVal(), e); } else { throw new UnsupportedOperationException( "PropAbsolute only knows how to explain ValueRemovals"); } } else if (d.getVar() == vars[1]) { e.add(aCause); if (d.getmType() == Deduction.Type.ValRem) { vars[0].explain(VariableState.REM, Math.abs(((ValueRemoval) d).getVal()), e); } else { throw new UnsupportedOperationException( "PropAbsolute only knows how to explain ValueRemovals"); } } else { super.explain(d, e); } }
@Override public void attachPropagator(Propagator propagator, int idxInProp) { IRequest<IntVar> request = propagator.makeRequest(this, idxInProp); propagator.addRequest(request); this.addRequest(request); }