Beispiel #1
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);
        }
 public InitializationParameters SetHelsimCombinedEstimation(InitializationParameters retParameters)
 {
     retParameters.CostStorage =
         new MaxCostStorage((o =>
                             o[ParticleMovementCost.GetParticleMovementCostType()] +
                             (o.ContainsKey(ConstantSolvingCost.GetConstantSolvingCost())
                 ? o[ConstantSolvingCost.GetConstantSolvingCost()]
                 : 0) +
                             (o.ContainsKey(new SortingCostParticleSwap())
                 ? o[new SortingCostParticleSwap()]
                 : 0) +
                             (o.ContainsKey(new SortingCostParticleComparison())
                 ? o[new SortingCostParticleComparison()]
                 : 0) +
                             (o.ContainsKey(ParticleWpcCoresSectionCoreRole.GetParticleWpcCoresReceiveCost())
                 ? o[ParticleWpcCoresSectionCoreRole.GetParticleWpcCoresReceiveCost()]
                 : 0) +
                             (o.ContainsKey(ParticleWPCCoresHomeCoreRole.GetParticleWpcCoresSend())
                 ? o[ParticleWPCCoresHomeCoreRole.GetParticleWpcCoresSend()]
                 : 0)));
     retParameters.VisualizationParameters.CostName = "SetHelsimCombinedEstimation";
     retParameters.ComCostFactory = new SimpleComCostFactory();
     return(retParameters);
 }