/// <summary> /// Initialize an aggregate integer variable with a name, size and domain. /// </summary> /// <param name="variableName">Variable name.</param> /// <param name="size">Size of the aggregate.</param> /// <param name="domain">Aggregate domain.</param> internal AggregateSolverVariable(string variableName, int size, DomainRange domain) : base(variableName, domain) { if (string.IsNullOrWhiteSpace(variableName)) { throw new ArgumentException("Aggregate variable name cannot be empty", nameof(variableName)); } if (size <= 0) { throw new ArgumentOutOfRangeException(nameof(size)); } _variables = CreateVariables(size); }
private static void RemoveTernaryValuesInconsistentWithBinaryConstraint(TernaryConstraintExpressionSolution constraintExpressionSolution, int variableIndex, DomainRange variableDomain) { var valueSetsToRemove = new List <ValueSet>(); foreach (var valueSet in constraintExpressionSolution.DomainValue.GetSets()) { // Make sure the set does not violate the domain values var variableValue = valueSet.GetAt(variableIndex - 1); if (variableDomain.PossibleValues.All(value => value != variableValue)) { valueSetsToRemove.Add(valueSet); } } if (valueSetsToRemove.Any()) { constraintExpressionSolution.DomainValue.RemoveSets(valueSetsToRemove); } }
/// <summary> /// Initialize a solver variable with a name and range. /// </summary> /// <param name="name">Variable name.</param> /// <param name="range">Domain range.</param> internal SolverVariable(string name, DomainRange range) : base(name) { Domain = range; }
private DomainRange CloneFrom(DomainRange template) { return(new DomainRange(template.PossibleValues.ToArray())); }