public Dictionary <ICore, Dictionary <ICostType, double> > GetCost(int step)
        {
            var accumCost = new Dictionary <ICore, Dictionary <ICostType, double> >();

            for (var i = 0; i <= step; i++)
            {
                var costs = storage.GetCost(i);
                foreach (var coreCostPair in costs)
                {
                    if (!accumCost.ContainsKey(coreCostPair.Key))
                    {
                        accumCost.Add(coreCostPair.Key, new Dictionary <ICostType, double>());
                    }
                    foreach (var typeCostPair in coreCostPair.Value)
                    {
                        var coreDict = accumCost[coreCostPair.Key];
                        if (!coreDict.ContainsKey(typeCostPair.Key))
                        {
                            coreDict.Add(typeCostPair.Key, 0);
                        }
                        var curVal = coreDict[typeCostPair.Key];
                        coreDict.Remove(typeCostPair.Key);
                        coreDict.Add(typeCostPair.Key, curVal + typeCostPair.Value);
                    }
                }
            }
            return(accumCost);
        }
Example #2
0
        private string GetPrintText(int step)
        {
            var build = new StringBuilder();

            foreach (var cost in storage.GetCost(step))
            {
                build.AppendLine("Core");
                var coreCosts = cost.Value;
                var sum       = 0d;

                foreach (var coreCost in coreCosts)
                {
                    if (coreCosts.Count > 4)
                    {
                        throw new Exception();
                    }
                    build.AppendLine("  " + coreCost.Key.GetCostName());
                    build.AppendLine("    " + coreCost.Value);
                    build.AppendLine("");
                    sum += coreCost.Value;
                }
                build.AppendLine("  CoreTotal");
                build.AppendLine("    " + sum);
                build.AppendLine("");
            }
            return(build.ToString());
        }
Example #3
0
        public Dictionary <ICore, Dictionary <ICostType, double> > GetCost(int step)
        {
            var maxComCost   = 0d;
            var maxSortCost  = 0d;
            var maxPartCost  = 0d;
            var maxConstCost = 0d;

            foreach (var corecostp in decoReviewer.GetCost(step))
            {
                var curComCost   = 0d;
                var curSortCost  = 0d;
                var curPartCost  = 0d;
                var curConstCost = 0d;
                foreach (var d in corecostp.Value)
                {
                    if (d.Key is SortingCostReceiveParticle || d.Key is SortingCostSendParticle ||
                        d.Key is SortingCostParticleSwap || d.Key is SortingCostParticleComparison)
                    {
                        curSortCost += d.Value; continue;
                    }
                    if (d.Key is ParticleWpcCoresSectionCoreRole || d.Key is ParticleWPCCoresHomeCoreRole)
                    {
                        curComCost += d.Value;
                        continue;
                    }
                    if (d.Key is ParticleMovementCost)
                    {
                        curPartCost += d.Value;
                        continue;
                    }
                    if (d.Key is ConstantSolvingCost)
                    {
                        curConstCost += d.Value;
                        continue;
                    }
                    throw new Exception("Strange type of cost occurred");
                }
                maxComCost   = Math.Max(curComCost, maxComCost);
                maxSortCost  = Math.Max(curSortCost, maxSortCost);
                maxPartCost  = Math.Max(curPartCost, maxPartCost);
                maxConstCost = Math.Max(curConstCost, maxConstCost);
            }
            var retDic    = new Dictionary <ICore, Dictionary <ICostType, double> >();
            var dummyCore = new DummyCore();

            retDic.Add(dummyCore, new Dictionary <ICostType, double>());
            retDic[dummyCore].Add(new SortingCostParticleComparison(), maxSortCost);
            retDic[dummyCore].Add(ParticleWpcCoresSectionCoreRole.GetParticleWpcCoresReceiveCost(), maxComCost);
            retDic[dummyCore].Add(ConstantSolvingCost.GetConstantSolvingCost(), maxConstCost);
            retDic[dummyCore].Add(ParticleMovementCost.GetParticleMovementCostType(), maxPartCost);
            return(retDic);
        }
Example #4
0
        public Bitmap GetCostOfStep(int step)
        {
            var retMap     = new Bitmap(size.X, size.Y);
            var drawGraph  = Graphics.FromImage(retMap);
            var titleFont  = new Font("Times New Roman", 16);
            var smallFont  = new Font("Times New Roman", 12);
            var solidBrush = new SolidBrush(Color.Red);

            drawGraph.DrawString(name, titleFont, solidBrush, 0, 0);
            var currentPosition = new Point(2, 30);

            foreach (var costs in showStorage.GetCost(step))
            {
                var unsort = costs.Value;
                var toAdd  = new SortedDictionary <ICostType, double>(new CostTypeComparer());
                foreach (var d in unsort)
                {
                    toAdd.Add(d.Key, d.Value);
                }
                foreach (var d in toAdd)
                {
                    drawGraph.DrawString(d.Key.GetCostName(), smallFont, solidBrush, currentPosition.X, currentPosition.Y);

                    const int newX = 220;
                    drawGraph.DrawString("" + d.Value, smallFont, solidBrush, newX, currentPosition.Y);
                    currentPosition = new Point(2, currentPosition.Y + 15);
                }
            }
            drawGraph.DrawString("Step: " + step, smallFont, solidBrush, 0, currentPosition.Y);


            /*
             *
             * var sortedCost = new Dictionary<ICore, SortedDictionary<ICostType, double>>();
             *  foreach (var VARIABLE in unsortedSet)
             *  {
             *      var toAdd = new SortedDictionary<ICostType, double>();
             *
             *      foreach (var kPair in VARIABLE.Value)
             *      {
             *          toAdd.Add(kPair.Key,kPair.Value);
             *      }
             *      sortedCost.Add(VARIABLE.Key,toAdd);
             *  }
             */
            drawGraph.Dispose();
            return(retMap);
        }
Example #5
0
        public Dictionary <ICore, Dictionary <ICostType, double> > GetCost(int step)
        {
            var decoResult = decoCostStorage.GetCost(step);
            var retDic     = new Dictionary <ICore, Dictionary <ICostType, double> >();

            retDic.Add(singeCostCore, new Dictionary <ICostType, double>());
            foreach (var d in decoResult.SelectMany(CoreCostPair => CoreCostPair.Value))
            {
                if (!retDic[singeCostCore].ContainsKey(d.Key))
                {
                    retDic[singeCostCore].Add(d.Key, d.Value);
                    continue;
                }
                var value = retDic[singeCostCore][d.Key];
                retDic[singeCostCore].Remove(d.Key);
                retDic[singeCostCore].Add(d.Key, value + d.Value);
            }
            return(retDic);
        }
Example #6
0
 //Op 1 core wil ik maximum iedere cost van iedere step.
 public Dictionary <ICore, Dictionary <ICostType, double> > GetCost(int step)
 {
     return(maxStepCostCalc.GetCost(step));
 }