Пример #1
0
        }//end:FirstPass

        /// <summary>
        /// Splits ets list based on 'MagicNumbers' and processes produced sublists
        /// </summary>
        public static StatsList FindBestRunWithShifting(Zakaz ets)
        {
            //Given ets become immutable, because NormalizeAndSort() returns new object,
            //and sorted from max to min by ryn
            Zakaz _ets = ets.NormalizeAndSort();

            //For small Zakaz just find the best run
            if (_ets.Count <= Constants.ETS_ON_SHEET)
            {
                return(new StatsList()
                {
                    FindBestRun(_ets)
                });
            }

            StatsList  result       = new StatsList();
            Zakaz      tmpEts       = new Zakaz();
            List <int> magicNumbers = _ets.SplitMarkers;

            for (int i = 0; i < _ets.Count; i++)
            {
                if (!magicNumbers.Contains(i))
                {
                    tmpEts.Add(_ets[i]);
                }
                else
                {
                    result.Add(FindBestRun(tmpEts));
                    tmpEts = new Zakaz()
                    {
                        _ets[i]
                    };
                }
            }//end:for

            if (tmpEts.Count > 0 && tmpEts.Count <= Constants.ETS_ON_SHEET)
            {
                result.Add(FindBestRun(tmpEts));
            }
            else if (tmpEts.Count <= Constants.ETS_ON_SHEET * 2)
            {
                result.AddRange(TwoPartsRebalancer(tmpEts));
            }
            else if (tmpEts.Count > Constants.ETS_ON_SHEET * 2)
            {
                result.AddRange(SplitFromMinToMax(tmpEts));
            }

            return(result);
        }//end:FindBestRunWithShifting
Пример #2
0
        }//end:FindBestRunWithShifting

        ///<summary>
        ///Splits provided ets by GCD and applies FirstPass on each sublist.
        ///Collects OutStats from each FirstPass and returns them as single list.
        ///</summary>
        public static StatsList SplitByGcd(Zakaz ets)
        {
            //ets.NormalizeAndSort();
            Zakaz _ets = new Zakaz(ets);

            _ets.Sort(new CompareEtsByRunMinToMax());

            List <Zakaz> groups       = new List <Zakaz>();
            Zakaz        garbageGroup = new Zakaz();

            foreach (Zakaz group in SplitByGcdToGroups(_ets))
            {
                //Sort ets of current group from max to min run
                group.Sort(new CompareEtsByRunMaxToMin());

                //Split big groups to smaller ones
                while (group.Count >= Constants.ETS_ON_SHEET)
                {
                    groups.Add(new Zakaz(group.Take(Constants.ETS_ON_SHEET)));
                    group.RemoveRange(0, Constants.ETS_ON_SHEET);
                }

                //All groups of one et are merged into one 'garbage' group
                if (group.Count < 2)
                {
                    garbageGroup.AddRange(group);
                }
                else
                {
                    groups.Add(group);
                }
            }
            if (garbageGroup.Count > 0)
            {
                groups.Add(garbageGroup);
            }

            StatsList result = new StatsList();

            foreach (Zakaz z in groups)
            {
                result.AddRange(FirstPass(z));
            }
            return(result);
        }//end:SplitByGcd