private void Update(IntVar intVar) { int val = intVar.Value; for (int idx = 0; idx < m_VarList.Count; ++idx) { IntVar var = m_VarList[idx]; if (!ReferenceEquals(var, intVar) && var.Domain.Contains(val)) { if (var.Domain.Min == val && var.Domain.Max == val) { m_Constraint.Violate(); return; } var.Difference(val); if (var.IsBound()) { Update(var); } } } }
public override void Update() { for (int idx = 0; idx < m_VarList.Count; ++idx) { IntVar var = m_VarList[idx]; if (var.IsBound()) { Update(var); } } }
static public bool UpdateOnCount(IntVarList varList) { int min = varList.MinInterval.Min; int max = varList.MaxInterval.Max; int count = max - min + 1; if (count < 256) { Value[] valList = new Value[count]; int valCount = 0; foreach (IntVar var in varList) { foreach (int val in var) { int idx = val - min; if (valList[idx].m_Value == 0) { ++valCount; valList[idx].m_Variable = var; } ++valList[idx].m_Value; } } if (valCount < varList.Count) { return(true); } for (int idx = 0; idx < count; ++idx) { if (valList[idx].m_Value == 1) { IntVar var = valList[idx].m_Variable; if (!var.IsBound()) { int val = min + idx; var.Intersect(val); } } } } return(false); }