Пример #1
0
        /// <summary>
        /// Creates a variable over a specified set of allowed values within a finite domain
        /// </summary>
        public FiniteDomainVariable(ConstraintThingySolver constraintThingySolver, string name, FiniteDomain <T> finiteDomain, params T[] items)
            : base(constraintThingySolver, name, finiteDomain.CreateBitSet(items))
        {
            FiniteDomain = finiteDomain;

            Priority = 1;
        }
Пример #2
0
        /// <summary>
        /// Creates a new mapping between values in <paramref name="x"/> to values in <paramref name="y"/>
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public Mapping(FiniteDomain <T1> x, FiniteDomain <T2> y)
        {
            Start = x;
            End   = y;

            _mapping         = new UInt64[x.Count];
            _backwardMapping = new UInt64[y.Count];
        }
Пример #3
0
        /// <summary>
        /// Creates a new score mapping
        /// </summary>
        public ScoreMapping(FiniteDomain <T> finitedomain, params Interval[] scores)
        {
            FiniteDomain = finitedomain;

            _scores = new Interval[FiniteDomain.Count];

            Array.Copy(scores, _scores, scores.Length);
        }
Пример #4
0
        /// <summary>
        /// Creates a new score mapping
        /// </summary>
        public ScoreMapping(FiniteDomain <T> finiteDomain, IEnumerable <Pair <T, Interval> > scores)
        {
            FiniteDomain = finiteDomain;

            _scores = new Interval[FiniteDomain.Count];

            foreach (var score in scores)
            {
                _scores[FiniteDomain.IndexOf(score.First)] = score.Second;
            }
        }
Пример #5
0
        public static String MakeString <T>(this UInt64 set, FiniteDomain <T> domain)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append('{');

            foreach (var index in set.GetSetIndices())
            {
                builder.Append(domain[index]);
                builder.Append(", ");
            }

            // remove the last comma
            if (builder.Length > 2)
            {
                builder.Remove(builder.Length - 2, 2);
            }

            builder.Append('}');

            return(builder.ToString());
        }
Пример #6
0
 /// <summary>
 /// Creates a variable over a specified set of allowed values within a finite domain
 /// </summary>
 public FiniteDomainVariable(ConstraintThingySolver constraintThingySolver, string name, FiniteDomain <T> finiteDomain, IEnumerable <T> items)
     : this(constraintThingySolver, name, finiteDomain, items.ToArray())
 {
 }
Пример #7
0
 /// <summary>
 /// Creates a new score mapping
 /// </summary>
 public ScoreMapping(FiniteDomain <T> finiteDomain, params Pair <T, Interval>[] scores)
     : this(finiteDomain, (IEnumerable <Pair <T, Interval> >)scores)
 {
 }