Ejemplo n.º 1
0
        /// <summary>
        /// Constrains <paramref name="variable"/> to one element of <paramref name="values"/>
        /// </summary>
        public static void ElementOf <T>(FiniteDomainVariable <T> variable, IEnumerable <T> values)
        {
            ulong mask = 0UL;

            foreach (var value in values)
            {
                mask = mask.SetBit(variable.FiniteDomain.IndexOf(value));
            }

            variable.BackdoorSet(variable.AllowableValues & mask);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Prohibits <paramref name="variable"/> from assuming <paramref name="value"/>
        /// </summary>
        public static void NotEqual <T>(FiniteDomainVariable <T> variable, T value)
        {
            UInt64 newValue = variable.AllowableValues.ClearBit(variable.FiniteDomain.IndexOf(value));

            variable.BackdoorSet(newValue);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constrains <paramref name="variable"/> to <paramref name="value"/>
 /// </summary>
 public static void Equal <T>(FiniteDomainVariable <T> variable, T value)
 {
     variable.BackdoorSet(variable.AllowableValues & BitHelper.GetMask(variable.FiniteDomain.IndexOf(value)));
 }