예제 #1
0
        /// <summary>
        /// Helper to calc Cars to get
        /// </summary>
        /// <param name="split">the split</param>
        /// <param name="classId">the class id you want to fill</param>
        /// <param name="exceptionClassId">the class ids which are not (or not allowed) in this split</param>
        /// <param name="fieldSizeOrLimit">the available slots count to fill (with every splits)</param>
        /// <returns>the number of cars to get, which is the part of 'fieldSizeOrLimit' corresponding the the classId</returns>
        private int TakeCars(List <int> carClassesIds, List <Split> splits, Split split, int classId, List <int> exceptionClassId, int fieldSizeOrLimit)
        {
            if (exceptionClassId == null)
            {
                exceptionClassId = new List <int>();
            }

            List <int>            classesToSelect  = new List <int>();
            Dictionary <int, int> classesRemaining = new Dictionary <int, int>();

            foreach (int id in carClassesIds)
            {
                if (!exceptionClassId.Contains(id))
                {
                    classesToSelect.Add(id);
                    classesRemaining.Add(id, 1);
                }
            }

            return(algo.TakeClassCars(fieldSizeOrLimit, classesToSelect.Count, classesRemaining, classId, null, split.Number));
        }
예제 #2
0
        /// <summary>
        /// Helper to calc Cars to get
        /// </summary>
        /// <param name="split">the split</param>
        /// <param name="classId">the class id you want to fill</param>
        /// <param name="exceptionClassId">the class ids which are not (or not allowed) in this split</param>
        /// <param name="fieldSizeOrLimit">the available slots count to fill (with every splits)</param>
        /// <returns>the number of cars to get, which is the part of 'fieldSizeOrLimit' corresponding the the classId</returns>
        internal virtual int TakeCars(List <Split> splits, Split split, int classId, List <int> exceptionClassId, int fieldSizeOrLimit)
        {
            if (exceptionClassId == null)
            {
                exceptionClassId = new List <int>();
            }

            List <int>            classesToSelect  = new List <int>();
            Dictionary <int, int> classesRemaining = new Dictionary <int, int>();

            foreach (int id in carClassesIds)
            {
                if (!exceptionClassId.Contains(id))
                {
                    classesToSelect.Add(id);
                    classesRemaining.Add(id, 1);
                }
            }
            ClassicAffineDistribution algo = baseAlgorithm as ClassicAffineDistribution;

            return(algo.TakeClassCars(fieldSizeOrLimit, classesToSelect.Count, classesRemaining, classId, null, split.Number));
        }