Ejemplo n.º 1
0
        public override Distribution Copy()
        {
            ShortDistribution copyDistribution = new ShortDistribution()
            {
                distribution  = new Dictionary <int, List <DistributionUnit> >(),
                TodayPlans    = new Dictionary <int, List <DistributionUnit> >(),
                TomorrowPlans = new Dictionary <int, List <DistributionUnit> >()
            };

            foreach (var unitPair in this.distribution)
            {
                var copyUnits = GetUnitsCopy(unitPair.Value);
                copyDistribution.distribution.Add(unitPair.Key, copyUnits);
            }

            foreach (var unitPair in this.TodayPlans)
            {
                var copyUnits = GetUnitsCopy(unitPair.Value);
                copyDistribution.TodayPlans.Add(unitPair.Key, copyUnits);
            }

            foreach (var unitPair in this.TomorrowPlans)
            {
                var copyUnits = GetUnitsCopy(unitPair.Value);
                copyDistribution.TomorrowPlans.Add(unitPair.Key, copyUnits);
            }

            return(copyDistribution);
        }
Ejemplo n.º 2
0
        private static void PrintResultShort()
        {
            ShortDistribution bestDistribution = GetBestDistribution() as ShortDistribution;
            var TodayPlans    = bestDistribution.TodayPlans;
            var TomorrowPlans = bestDistribution.TomorrowPlans;

            foreach (var todayPlan in TodayPlans)
            {
                PrintShortPlan(todayPlan, true);
            }

            foreach (var tomorrowPlan in TomorrowPlans)
            {
                PrintShortPlan(tomorrowPlan, false);
            }

            Console.WriteLine($"total cost: {bestDistribution.Cost.ToString("F2")}");
        }
Ejemplo n.º 3
0
        private static void InitSolutionSet()
        {
            distributions = new Distribution[GroupCount];
            for (int i = 0; i < GroupCount; ++i)
            {
                switch (Constant.PlanType)
                {
                case ModelType.LONG:
                    distributions[i] = new LongDistribution();
                    break;

                case ModelType.SHORT:
                    distributions[i] = new ShortDistribution();
                    break;

                case ModelType.SHORT_CRAZY:
                    distributions[i] = new ShortCrazyDistribution();
                    break;

                default:
                    throw new InvalidModelTypeException();
                }
            }
        }