Пример #1
0
        /// <summary>
        /// Creates and returns an integer variable that represents the difference of <paramref name="a"/> and <paramref name="b"/>
        /// </summary>
        public static IntegerVariable Subtract(IntegerVariable a, IntegerVariable b)
        {
            IntegerVariable difference = new IntegerVariable(a.ConstraintThingySolver, null, IntegerVariable.DefaultRange);

            Constraint.InRange(difference, a.AllowableValues - b.AllowableValues);

            Difference(difference, a, b);

            return(difference);
        }
Пример #2
0
        /// <summary>
        /// Creates and returns an integer variable that represents the sum of <paramref name="a"/> and <paramref name="b"/>
        /// </summary>
        public static IntegerVariable Add(IntegerVariable a, IntegerVariable b)
        {
            IntegerVariable sum = new IntegerVariable(a.ConstraintThingySolver, null, IntegerVariable.DefaultRange);

            Constraint.InRange(sum, a.AllowableValues + b.AllowableValues);

            Sum(sum, a, b);

            return(sum);
        }
Пример #3
0
 /// <summary>
 /// Constrains <paramref name="variable" /> to be in <paramref name="range"/>
 /// </summary>
 public static void InRange(IntegerVariable variable, IntegerInterval range)
 {
     variable.BackdoorSet(IntegerInterval.Intersection(variable.AllowableValues, range));
 }
Пример #4
0
 /// <summary>
 /// Constraints <paramref name="variable"/> to be exactly <paramref name="value"/>
 /// </summary>
 public static void Equal(IntegerVariable variable, int value)
 {
     InRange(variable, value, value);
 }
Пример #5
0
 /// <summary>
 /// Creates and returns an integer variable that represents the difference of <paramref name="a"/> and <paramref name="b"/>
 /// </summary>
 public static void Difference(IntegerVariable difference, IntegerVariable a, IntegerVariable b)
 {
     new IntegerDifferenceConstraint(difference, a, b);
 }
Пример #6
0
 /// <summary>
 /// Constrains <paramref name="sum"/> to be the sum of <paramref name="a"/> and <paramref name="b"/>
 /// </summary>
 public static void Sum(IntegerVariable sum, IntegerVariable a, IntegerVariable b)
 {
     new IntegerSumConstraint(sum, a, b);
 }
Пример #7
0
 /// <summary>
 /// Constrains that the values of <paramref name="a"/> and <paramref name="b"/> are not equal.
 /// </summary>
 public static void NotEqual(IntegerVariable a, IntegerVariable b)
 {
     new IntegerInequalityConstraint(a, b);
 }
Пример #8
0
 /// <summary>
 /// Constrains <paramref name="variable"/> to be at least <paramref name="value"/>
 /// </summary>
 public static void GreaterThanOrEqual(IntegerVariable variable, int value)
 {
     InRange(variable, value, int.MaxValue);
 }
Пример #9
0
 /// <summary>
 /// Constraints <paramref name="variable"/> to be at most <paramref name="value"/>
 /// </summary>
 public static void LessThanOrEqual(IntegerVariable variable, int value)
 {
     InRange(variable, int.MinValue, value);
 }
Пример #10
0
 /// <summary>
 /// Constrains <paramref name="variable"/> to be between <paramref name="minValue"/> and <paramref name="maxValue"/>
 /// </summary>
 public static void InRange(IntegerVariable variable, int minValue, int maxValue)
 {
     InRange(variable, new IntegerInterval(minValue, maxValue));
 }